45 $this->
a = ($value >> 24) & 0xFF;
46 $this->r = ($value >> 16) & 0xFF;
47 $this->g = ($value >> 8) & 0xFF;
48 $this->
b = $value & 0xFF;
59 $array = array_values($array);
61 if (count($array) == 4) {
65 $this->
a = $this->alpha2gd(
$a);
67 } elseif (count($array) == 3) {
92 $this->
a = $this->alpha2gd($color[3]);
106 $this->r = intval(
$r);
107 $this->g = intval(
$g);
108 $this->
b = intval(
$b);
123 $this->r = intval(
$r);
124 $this->g = intval(
$g);
125 $this->
b = intval(
$b);
126 $this->
a = $this->alpha2gd(
$a);
137 throw new \Intervention\Image\Exception\NotSupportedException(
138 "GD colors cannot init from ImagickPixel objects."
149 return ($this->
a << 24) + ($this->r << 16) + ($this->g << 8) +
$this->b;
160 return sprintf(
'%s%02x%02x%02x', $prefix, $this->r, $this->g, $this->
b);
170 return array($this->r, $this->g, $this->
b, round(1 - $this->
a / 127, 2));
180 return sprintf(
'rgba(%d, %d, %d, %.2f)', $this->r, $this->g, $this->
b, round(1 - $this->
a / 127, 2));
192 $color_tolerance = round($tolerance * 2.55);
193 $alpha_tolerance = round($tolerance * 1.27);
196 'r' => abs($color->r - $this->r),
197 'g' => abs($color->g - $this->g),
198 'b' => abs($color->b - $this->b),
199 'a' => abs($color->a - $this->a)
203 $delta[
'r'] > $color_tolerance
or
204 $delta[
'g'] > $color_tolerance
or
205 $delta[
'b'] > $color_tolerance
or
206 $delta[
'a'] > $alpha_tolerance
216 private function alpha2gd($input)
224 return ceil(((($input- $oldMin) * ($newMax - $newMin)) / ($oldMax - $oldMin)) + $newMin);