--------------------------------Linux Guide---------------------------------- by Ingo Blechschmidt (c) 2002 ----------------------------------------------------------------------------- ------------------------- Farbverlauf mit Perl ------------------------- Mon Aug 27 13:32:52 MEST 2001 ------------------------- Verlauf Farbverlauf Perl HTML ----------------------------------------------------------------------------- Sie wollen einen Farbverlauf automatisch mittels Perl generieren. ----------------------------------------------------------------------------- Dabei lässt sich die Größe und Start- und End-Farbe natürlich ändern. Der Aufruf: --------CODE--------: Aufruf # ./verlauf.pl d s1 s2 s3 e1 e2 e3 maxx maxy --------/CODE-------- Die Parameter: # d # Kann r oder l sein, gibt die Stelle des Hotspots an. # s1, s2, s3 # Die Hexadezimalen Start-RGB-Werte des Farbverlaufs. # e1, e2, e3 # Die Hexadezimalen End-RGB-Werte des Farbverlaufs. # maxx, maxy # Maximale Breite und Höhe Die Ausgabe des Skripts ist eine HTML-Tabelle, die sofort in HTML-Dateien eingebunden werden kann. Das Skript, siehe <"down/verlauf.pl">Download: --------CODE--------: verlauf.pl #!/usr/bin/perl -w # # This program is free software; you can redistribute it # and/or modify it under the terms of the GNU General Public # License as published by the Free Software Foundation; # either version 2 of the License, or (at your option) any # later version. # # This program is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR # PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public # License along with this program; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA # 02139, USA. # # Ingo Blechschmidt # Arberstraße 5 # 86179 Augsburg # E-Mail: iblech@web.de, http://www.way.to/uselinux/ # Tel.: +49 / 821 882955 # # @start = (); @ende = (); @stepx = (); @stepy = (); $maxx = 10; $maxy = 20; $i = 0; $j = 0; $k = 0; @matrix = (); $spot = ''; $spot = $ARGV[0] ? $ARGV[0] : 'l'; @start = qw(nil ff 80 33); # Initialisierung @ende = qw(nil ff 89 44); @start = (0, "$ARGV[1]", "$ARGV[2]", "$ARGV[3]") if (defined $ARGV[1]); @ende = (0, "$ARGV[4]", "$ARGV[5]", "$ARGV[6]") if (defined $ARGV[4]); $maxx = $ARGV[7] if (defined $ARGV[7]); $maxy = $ARGV[8] if (defined $ARGV[8]); for ($i = 1; $i <= 3; $i++) { $start[$i] = hex($start[$i]); $ende[$i] = hex($ende[$i]); } for ($i = 1; $i <= 3; $i++) { $stepx[$i] = abs(($start[$i] - $ende[$i]) / $maxx); $stepy[$i] = abs(($start[$i] - $ende[$i]) / $maxy); } for($i = 1; $i <= $maxx; $i++) { # Berechnung for($j = 1; $j <= $maxy; $j++) { for($k = 1; $k <= 3; $k++) { $matrix[$maxx - $i + 1][$j][$k] = $ende[$k] + ($stepx[$k] * ($i - 1) + $stepy[$k] * ($j - 1)) / 4 if ($spot eq 'r'); $matrix[$maxx - $i + 1][$maxy - $j + 1][$k] = $ende[$k] + ($stepx[$k] * ($i - 1) + $stepy[$k] * ($j - 1)) / 4 if ($spot eq 'l'); } } } print "\n"; for ($i = 1; $i <= $maxx; $i++) { # Umrechnung in hex for ($j = 1; $j <= $maxy; $j++) { # und Ausgabe for ($k = 1; $k <= 3; $k++) { $matrix[$i][$j][$k] = 255 if ($matrix[$i][$j][$k] > 255); print ((0 .. 9, 'a' .. 'f')[int($matrix[$i][$j][$k] / 16)], (0 .. 9, 'a' .. 'f')[$matrix[$i][$j][$k] % 16]); # print " "; } } } 1; --------/CODE-------- ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- This document is distributed under the terms of the GNU Free Documentation License.