Lines Matching defs:color

21     const COLOR = "color";
23 const BORDER_COLOR = "border-color";
49 * https://drafts.csswg.org/css-color/#color-keywords
213 public const BACKGROUND_COLOR = "background-color";
253 * The color name
278 * @return ColorRgb - the default primary color in case of any errors
349 public static function createFromHex(string $color): ColorRgb
353 ->setHex($color);
367 throw new ExceptionCompile("This color ($this) does not have any channel known, we can't transform it to hsl");
416 * @param array|string|ColorRgb $color
422 * https://sass-lang.com/documentation/modules/color#mix
430 function mix($color, ?int $weight = 50): ColorRgb
436 $color2 = ColorRgb::createFromString($color);
447 function unmix($color, ?int $weight = 50): ColorRgb
453 $color2 = ColorRgb::createFromString($color);
456 throw new ExceptionCompile("This is not possible, the red value ({$color2->getBlue()}) with the percentage $weight could not be unmixed. They were not calculated with color mixing.");
460 throw new ExceptionCompile("This is not possible, the green value ({$color2->getGreen()}) with the percentage $weight could not be unmixed. They were not calculated with color mixing.");
464 throw new ExceptionCompile("This is not possible, the blue value ({$color2->getBlue()}) with the percentage $weight could not be unmixed. They were not calculated with color mixing.");
471 * Takes an hexadecimal color and returns the rgb channels
480 throw new ExceptionBadArgument("The color value ($hex) does not start with a #, this is not valid CSS hexadecimal color value");
497 throw new ExceptionBadArgument("The digit color value ($hex) is not 3 or 6 in length, this is not a valid CSS hexadecimal color value");
501 throw new ExceptionBadArgument("The digit color value ($hex) is not a hexadecimal value, this is not a valid CSS hexadecimal color value");
548 static function createFromString(string $color): ColorRgb
550 if ($color[0] === "#") {
551 return self::createFromHex($color);
553 return self::createFromName($color);
561 static function createFromName(string $color): ColorRgb
564 ->setName($color);
592 // unknown color name
732 function toMinimumContrastRatio(string $color, float $minimum = self::MINIMUM_CONTRAST_RATIO, $darknessIncrement = 5): ColorRgb
734 $targetColor = ColorRgb::createFromString($color);
750 * Returns the complimentary color
761 LogUtility::msg("Error while getting the complementary color of ($this). Error: {$e->getMessage()}");
790 function setHex(string $color): ColorRgb
793 if ($color[0] !== "#") {
794 throw new ExceptionBadArgument("The value is not an hexadecimal color value ($color)");
796 [$this->red, $this->green, $this->blue, $this->transparency] = $this->hex2rgb($color);
798 $this->name = $color;
809 throw new ExceptionCompile("A rgb color array should be of length 3");
811 foreach ($colorValue as $color) {
813 $channel = DataType::toInteger($color);
815 throw new ExceptionCompile("The rgb color $color is not an integer. Error: {$e->getMessage()}");
818 throw new ExceptionCompile("The rgb color $color is not between 0 and 255");
853 LogUtility::msg("The primary color cannot be set with the value primary. Default to bootstrap color.", self::BRANDING_COLOR_CANONICAL);
862 LogUtility::msg("The secondary color cannot be set with the value secondary. Default to bootstrap color.", self::BRANDING_COLOR_CANONICAL);
878 LogUtility::msg("The color name ($name) is unknown");