Thread Darstellung von Farben (8 answers)
Opened by Yvonne at 2006-04-03 18:18

Crian
 2006-04-04 16:06
#64356 #64356
User since
2003-08-04
5873 Artikel
ModeratorIn
[Homepage]
user image
[quote=Taulmarill,03.04.2006, 16:40]hm, weiss zwar noch nicht 100%ig wie das aussehen soll, hört sich aber so an, als ob man das mit ganz normalem html + css hinbekommt. du musst halt nur den entsprechenden farbwert zwischen #FF0000 und #00FF00 ausrechnen. für die balken würde ich entweder tabellenzellen oder div-blöcke benutzen. je nach dem wie das layout aussehen soll.[/quote]
Denk ich auch. Zum Ausrechnen der Farbwerte könnte dir das hier nützlich sein:

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/perl
use strict;
use warnings;

die "syntax: farbverlauf.pl anzahl startfarbe endfarbe\n" unless 3 == @ARGV;
my @color = farbverlauf(@ARGV);

print '[color=', $_, ']', $_, '[/color]', "\n" for @color;
exit;


sub farbverlauf {
my ($n, $von, $bis) = @_;


my ($f1, $f2, $f3) = $von =~ /^#?([0-9abcdef]{2})([0-9abcdef]{2})([0-9abcdef]{2})$/i;
my ($f4, $f5, $f6) = $bis =~ /^#?([0-9abcdef]{2})([0-9abcdef]{2})([0-9abcdef]{2})$/i;

my $ar = hex $f1; # Anfangsfarbwerte
my $ag = hex $f2;
my $ab = hex $f3;

my $zr = hex $f4; # Endfarbwerte
my $zg = hex $f5;
my $zb = hex $f6;

my $dr = ($zr-$ar) / ($n-1); # Deltawerte
my $dg = ($zg-$ag) / ($n-1);
my $db = ($zb-$ab) / ($n-1);

#print "ar=$ar\tag=$ag\tab=$ab\n",
# "zr=$zr\tzg=$zg\tzb=$zb\n",
# "dr=$dr\tdg=$dg\tdb=$db\n";

my $r = $ar;
my $g = $ag;
my $b = $ab;

my @ergebnis;
for my $i (1 .. $n) {
my $rr = int $r+.5;
my $gg = int $g+.5;
my $bb = int $b+.5;

push @ergebnis, sprintf "#%02X%02X%02X", $rr, $gg, $bb;

$r += $dr;
$g += $dg;
$b += $db;
}

return @ergebnis;
} # sub farbverlauf


Ein Aufruf farbverlauf.pl 10 #FF0000 #00FF00 liefert

Code: (dl )
1
2
3
4
5
6
7
8
9
10
[color=#FF0000]#FF0000[/color]
[color=#E31C00]#E31C00[/color]
[color=#C63900]#C63900[/color]
[color=#AA5500]#AA5500[/color]
[color=#8E7100]#8E7100[/color]
[color=#718E00]#718E00[/color]
[color=#55AA00]#55AA00[/color]
[color=#39C600]#39C600[/color]
[color=#1CE300]#1CE300[/color]
[color=#00FF00]#00FF00[/color]


... das sieht dann ohne CODE-Tags so aus:

#FF0000
#E31C00
#C63900
#AA5500
#8E7100
#718E00
#55AA00
#39C600
#1CE300
#00FF00\n\n

<!--EDIT|Crian|1144153025-->
s--Pevna-;s.([a-z]).chr((ord($1)-84)%26+97).gee; s^([A-Z])^chr((ord($1)-52)%26+65)^gee;print;

use strict; use warnings; Link zu meiner Perlseite

View full thread Darstellung von Farben