@@ -512,8 +512,15 @@ private function parseColorValue() {
512512 $ sValue = $ this ->parseIdentifier (false );
513513 if ($ this ->strlen ($ sValue ) === 3 ) {
514514 $ 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 ));
515523 }
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 ));
517524 } else {
518525 $ sColorMode = $ this ->parseIdentifier (false );
519526 $ this ->consumeWhiteSpace ();
@@ -800,4 +807,13 @@ private function strpos($sString, $sNeedle, $iOffset) {
800807 }
801808 }
802809
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+
803819}
0 commit comments