public function contrastColors($backgroundColor)
 {
     $background = Color::stringToRgb24($backgroundColor);
     $this->string = preg_replace_callback('/(?<!\\$)((?:\\$[\\$])*)(\\$[0-9a-f][^\\$]{0,2})/iu', function ($matches) use($background) {
         $color = Color::stringToRgb24($matches[2]);
         $color = Color::contrast($color, $background);
         $color = Color::rgb24ToRgb12($color);
         $color = Color::rgb12ToString($color);
         return $matches[1] . '$' . $color;
     }, $this->string);
     return $this;
 }
Beispiel #2
0
 /**
  * @dataProvider rgb24ToStringProvider
  */
 public function testStringToRgb12String($input, $expected)
 {
     $rgb24 = Color::stringToRgb24($input);
     $rgb12 = Color::rgb24ToRgb12($rgb24);
     $this->assertEquals($expected, Color::rgb12ToString($rgb12));
 }