public function blendColors(\OttawaDeveloper\Tools\ColorAnalyzer\ColorContext $context) { $convertedBackgroundAlpha = $context->background()->alpha() * (1 - $context->foreground()->alpha()); $resultAlpha = $context->foreground()->alpha() + $convertedBackgroundAlpha; // Tiny result alphas means that the color is transparent, so we just // return a transparent color. if ($resultAlpha < 0.001) { return new \OttawaDeveloper\Tools\ColorAnalyzer\BlendedColor($context->foreground(), $context->background(), 0, 0, 0, 0); } return new \OttawaDeveloper\Tools\ColorAnalyzer\BlendedColor($context->foreground(), $context->background(), $this->blendColorComponent($context->foreground()->red(), $context->background()->red(), $context->foreground()->alpha(), $context->background()->alpha(), $resultAlpha), $this->blendColorComponent($context->foreground()->green(), $context->background()->green(), $context->foreground()->alpha(), $context->background()->alpha(), $resultAlpha), $this->blendColorComponent($context->foreground()->blue(), $context->background()->blue(), $context->foreground()->alpha(), $context->background()->alpha(), $resultAlpha), $resultAlpha); }
public function columnValue(ColorContext $color) { switch ($this->layer) { case self::BACKGROUND: return $this->formatClass->formatColor($this->resolveColor($color->background())); case self::FOREGROUND: return $this->formatClass->formatColor($this->resolveColor($color->foreground())); } return NULL; }