01_FHEMWEB.pm: implement different fill and stroke colors (Forum #120303)

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@24251 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2021-04-14 14:44:20 +00:00
parent 30f2b7cdb4
commit bba813a78b

View File

@ -2711,16 +2711,18 @@ FW_makeImage(@)
$data =~ s/[\r\n]/ /g; $data =~ s/[\r\n]/ /g;
$data =~ s/ *$//g; $data =~ s/ *$//g;
$data =~ s/<svg/<svg class="$class" data-txt="$txt"/; #52967 $data =~ s/<svg/<svg class="$class" data-txt="$txt"/; #52967
$name =~ m/(@.*)$/; if($name =~ m/@([^:]*)(:(.*))?$/) {
my $col; my ($fill, $stroke) = ($1, $3);
$col = $1 if($1); if($fill ne "") {
if($col) { $fill = "#$fill" if($fill =~ m/^([A-F0-9]{6})$/);
$col =~ s/@//; $data =~ s/fill="#000000"/fill="$fill"/g;
$col = "#$col" if($col =~ m/^([A-F0-9]{6})$/); $data =~ s/fill:#000000/fill:$fill/g;
$data =~ s/fill="#000000"/fill="$col"/g; }
$data =~ s/fill:#000000/fill:$col/g; if(defined($stroke)) {
$data =~ s/stroke="#000000"/stroke="$col"/g; # 120303 $stroke = "#$stroke" if($stroke =~ m/^([A-F0-9]{6})$/);
$data =~ s/stroke:#000000/stroke:$col/g; $data =~ s/stroke="#000000"/stroke="$stroke"/g;
$data =~ s/stroke:#000000/stroke:$stroke/g;
}
} else { } else {
$data =~ s/fill="#000000"//g; $data =~ s/fill="#000000"//g;
$data =~ s/fill:#000000//g; $data =~ s/fill:#000000//g;
@ -3789,7 +3791,9 @@ FW_log($$)
attr lamp devStateIcon .*:noIcon<br> attr lamp devStateIcon .*:noIcon<br>
</ul> </ul>
Note: if the image is referencing an SVG icon, then you can use the Note: if the image is referencing an SVG icon, then you can use the
@colorname suffix to color the image. E.g.:<br> @fill:stroke suffix to color the image, where fill replaces the fill
color in the SVG (if it is specified as #000000) and the optional
stroke the stroke color (if it is specified as #000000). E.g.:<br>
<ul> <ul>
attr Fax devStateIcon on:control_building_empty@red attr Fax devStateIcon on:control_building_empty@red
off:control_building_filled:278727 off:control_building_filled:278727
@ -4556,8 +4560,11 @@ FW_log($$)
attr lamp devStateIcon on::A0 off::AI<br> attr lamp devStateIcon on::A0 off::AI<br>
attr lamp devStateIcon .*:noIcon<br> attr lamp devStateIcon .*:noIcon<br>
</ul> </ul>
Anmerkung: Wenn das Icon ein SVG Bild ist, kann das @colorname Suffix Anmerkung: Wenn das Icon ein SVG Bild ist, kann das @fill:stroke
verwendet werden um das Icon einzuf&auml;rben. Z.B.:<br> Suffix verwendet werden um das Icon einzuf&auml;rben, dabei wird in
der SVG die F&uuml;llfarbe durch das spezifizierte fill ersetzt, und
die Stiftfarbe durch das optionale stroke.
Z.B.:<br>
<ul> <ul>
attr Fax devStateIcon on:control_building_empty@red attr Fax devStateIcon on:control_building_empty@red
off:control_building_filled:278727 off:control_building_filled:278727