@@ -512,8 +512,15 @@ private function parseColorValue() {
512
512
$ sValue = $ this ->parseIdentifier (false );
513
513
if ($ this ->strlen ($ sValue ) === 3 ) {
514
514
$ sValue = $ sValue [0 ] . $ sValue [0 ] . $ sValue [1 ] . $ sValue [1 ] . $ sValue [2 ] . $ sValue [2 ];
515
+ } else if ($ this ->strlen ($ sValue ) === 4 ) {
516
+ $ sValue = $ sValue [0 ] . $ sValue [0 ] . $ sValue [1 ] . $ sValue [1 ] . $ sValue [2 ] . $ sValue [2 ] . $ sValue [3 ] . $ sValue [3 ];
517
+ }
518
+
519
+ if ($ this ->strlen ($ sValue ) === 8 ) {
520
+ $ aColor = array ('r ' => new Size (intval ($ sValue [0 ] . $ sValue [1 ], 16 ), null , true , $ this ->iLineNo ), 'g ' => new Size (intval ($ sValue [2 ] . $ sValue [3 ], 16 ), null , true , $ this ->iLineNo ), 'b ' => new Size (intval ($ sValue [4 ] . $ sValue [5 ], 16 ), null , true , $ this ->iLineNo ), 'a ' => new Size (round ($ this ->mapRange (intval ($ sValue [6 ] . $ sValue [7 ], 16 ), 0 , 255 , 0 , 1 ), 2 ), null , true , $ this ->iLineNo ));
521
+ } else {
522
+ $ aColor = array ('r ' => new Size (intval ($ sValue [0 ] . $ sValue [1 ], 16 ), null , true , $ this ->iLineNo ), 'g ' => new Size (intval ($ sValue [2 ] . $ sValue [3 ], 16 ), null , true , $ this ->iLineNo ), 'b ' => new Size (intval ($ sValue [4 ] . $ sValue [5 ], 16 ), null , true , $ this ->iLineNo ));
515
523
}
516
- $ aColor = array ('r ' => new Size (intval ($ sValue [0 ] . $ sValue [1 ], 16 ), null , true , $ this ->iLineNo ), 'g ' => new Size (intval ($ sValue [2 ] . $ sValue [3 ], 16 ), null , true , $ this ->iLineNo ), 'b ' => new Size (intval ($ sValue [4 ] . $ sValue [5 ], 16 ), null , true , $ this ->iLineNo ));
517
524
} else {
518
525
$ sColorMode = $ this ->parseIdentifier (false );
519
526
$ this ->consumeWhiteSpace ();
@@ -800,4 +807,13 @@ private function strpos($sString, $sNeedle, $iOffset) {
800
807
}
801
808
}
802
809
810
+ private function mapRange ($ fVal , $ fFromMin , $ fFromMax , $ fToMin , $ fToMax ) {
811
+ $ fFromRange = $ fFromMax - $ fFromMin ;
812
+ $ fToRange = $ fToMax - $ fToMin ;
813
+ $ fMultiplier = $ fToRange / $ fFromRange ;
814
+ $ fNewVal = $ fVal - $ fFromMin ;
815
+ $ fNewVal *= $ fMultiplier ;
816
+ return $ fNewVal + $ fToMin ;
817
+ }
818
+
803
819
}
0 commit comments