background

@param mixed $color
@access protected
@return \Thapp\JitImage\Driver\ImagickDriver
763463
protected function background($color = null)
    {
        if (!is_null($color)) {
            $this->resource->setImageBackgroundColor(sprintf('#%s', $color));
        }
        return $this;
    }
689244
public function color($type = 'bg', $color = Style::COLOR_WHITE)
    {
        if ($type === 'bg') {
            $this->backgroundColor = $color;
        } else {
            $this->foregroundColor = $color;
        }

        return $this;
    }
145500
public function setTransparent($color) {
	    $color = call_user_func_array([$this, 'getColorWithRGB'], func_get_args());
	    return imagecolortransparent($this->image, $color);
    }
161402
public function setColor(string $color): self
    {
        if (!preg_match("/^#([A-Fa-f0-9]{6})$/", $color)) {
            throw new \InvalidArgumentException($color. " is not a valid hexadecimal color");
        }
        $this->color = $color;
        return $this;
    }
184515
private static function rgb($color) {

		return (object) [

			'r' => intval(hexdec(substr($color, 0, 2))),
			'g' => intval(hexdec(substr($color, 2, 2))),
			'b' => intval(hexdec(substr($color, 4, 2)))
		];
	}
137074
public function getRgbaString(Color $color)
    {
        return 'rgba('. $color->red . ', ' . $color->green . ', ' . $color->blue . ', ' . $color->alpha . ')';
    }
1328588
public static function background(string $executable): self
    {
        $self = new self($executable);
        $self->background = true;

        return $self;
    }
143503
public static function materialColors(string $color = null)
    {
        $colors = Collection::make([
            'red'           => '#F44336',
            'pink'          => '#E91E63',
            'purple'        => '#9C27B0',
            'deep_purple'   => '#673AB7',
            'indigo'        => '#3F51B5',
            'blue'          => '#2196F3',
            'light_blue'    => '#03A9F4',
            'cyan'          => '#00BCD4',
            'teal'          => '#009688',
            'green'         => '#4CAF50',
            'light_green'   => '#8BC34A',
            'lime'          => '#CDDC39',
            'yellow'        => '#FFEB3B',
            'amber'         => '#FFC107',
            'orange'        => '#FF9800',
            'deep_orange'   => '#FF5722',
            'brown'         => '#795548',
            'grey'          => '#9E9E9E',
            'blue_grey'     => '#607D8B'
        ]);

        if (!$color) {
            return $colors;
        }

        return $colors->has($color) ? $colors->get($color) : $color;
    }
20874
public function setFromRGBColor(RGBColor $color)
    {
        return $this->setRed($color->getRed())
                        ->setGreen($color->getGreen())
                        ->setBlue($color->getBlue())
                        ->setAlpha($color->getAlpha());
    }
806558
public function fill_color( $color, $alpha = 1 ) 
	{
		$alpha = $alpha * 127;

		// parse the color
		$color = CCColor::create( $color );
		$color = imagecolorallocatealpha( $this->image_context, $color->RGB[0], $color->RGB[1], $color->RGB[2], $alpha );

		// run image fill
		imagefill( $this->image_context, 0, 0, $color );

		return $this;
	}
712048
public function setColor($color)
	{
		if (is_array($color))
		{
			$this->color[0] = $color[0];
			$this->color[1] = $color[1];
			$this->color[2] = $color[2];
		}
		else
		{
			$color = ltrim($color, '#');

			$this->color[0] = hexdec(substr($color, 0, 2));
			$this->color[1] = hexdec(substr($color, 2, 2));
			$this->color[2] = hexdec(substr($color, 4, 2));
		}

		return $this;
	}
112306
public function cut_color($color) {
		$replace_colors = & $this->parser->data['csstidy']['replace_colors'];

		// if it's a string, don't touch !
		if (strncmp($color, "'", 1) == 0 || strncmp($color, '"', 1) == 0)
			return $color;

		/* expressions complexes de type gradient */
		if (strpos($color, '(') !== false && strncmp($color, 'rgb(' ,4) != 0) {
			// on ne touche pas aux couleurs dans les expression ms, c'est trop sensible
			if (stripos($color, 'progid:') !== false)
				return $color;
			preg_match_all(",rgb\([^)]+\),i", $color, $matches, PREG_SET_ORDER);
			if (count($matches)) {
				foreach ($matches as $m) {
					$color = str_replace($m[0], $this->cut_color($m[0]), $color);
				}
			}
			preg_match_all(",#[0-9a-f]{6}(?=[^0-9a-f]),i", $color, $matches, PREG_SET_ORDER);
			if (count($matches)) {
				foreach ($matches as $m) {
					$color = str_replace($m[0],$this->cut_color($m[0]), $color);
				}
			}
			return $color;
		}

		// rgb(0,0,0) -> #000000 (or #000 in this case later)
		if (strncasecmp($color, 'rgb(', 4)==0) {
			$color_tmp = substr($color, 4, strlen($color) - 5);
			$color_tmp = explode(',', $color_tmp);
			for ($i = 0; $i < count($color_tmp); $i++) {
				$color_tmp[$i] = trim($color_tmp[$i]);
				if (substr($color_tmp[$i], -1) === '%') {
					$color_tmp[$i] = round((255 * $color_tmp[$i]) / 100);
				}
				if ($color_tmp[$i] > 255)
					$color_tmp[$i] = 255;
			}
			$color = '#';
			for ($i = 0; $i < 3; $i++) {
				if ($color_tmp[$i] < 16) {
					$color .= '0' . dechex($color_tmp[$i]);
				} else {
					$color .= dechex($color_tmp[$i]);
				}
			}
		}

		// Fix bad color names
		if (isset($replace_colors[strtolower($color)])) {
			$color = $replace_colors[strtolower($color)];
		}

		// #aabbcc -> #abc
		if (strlen($color) == 7) {
			$color_temp = strtolower($color);
			if ($color_temp{0} === '#' && $color_temp{1} == $color_temp{2} && $color_temp{3} == $color_temp{4} && $color_temp{5} == $color_temp{6}) {
				$color = '#' . $color{1} . $color{3} . $color{5};
			}
		}

		switch (strtolower($color)) {
			/* color name -> hex code */
			case 'black': return '#000';
			case 'fuchsia': return '#f0f';
			case 'white': return '#fff';
			case 'yellow': return '#ff0';

			/* hex code -> color name */
			case '#800000': return 'maroon';
			case '#ffa500': return 'orange';
			case '#808000': return 'olive';
			case '#800080': return 'purple';
			case '#008000': return 'green';
			case '#000080': return 'navy';
			case '#008080': return 'teal';
			case '#c0c0c0': return 'silver';
			case '#808080': return 'gray';
			case '#f00': return 'red';
		}

		return $color;
	}
65537
protected static function getMixedColorAsRgb($color)
	{
		if (is_array($color)) {
			if (!static::validateRgbColor($color)) return false;
			return $color;
		} else {
			return static::hexToRgb($color);
		}
	}
1096180
public function backgroundCell($color, $cell=null, $row=null){
        $color = str_replace("#", "", $color);
        if(!is_null($cell)){
            $this->x = $this->getColumnName($cell);
            $this->y = $row;
        }

        $style = array('fill' => array(
            'type' => PHPExcel_Style_Fill::FILL_SOLID,
            'color' => array('rgb' => "$color")
        )
        );
        $this->engine->getActiveSheet()->getStyle("{$this->x}{$this->y}")->applyFromArray($style);
    }
29341
public function setForegroundColor($foregroundColor)
    {
        if ( is_null($this->frontColor) ) {
            $this->frontColor = new Color;
        }

        $this->frontColor->setFromArray($foregroundColor);

        return $this;
    }
811383
public function setBackground(int $r = 255, int $g = 255, int $b = 255)
    {
        $this->check();

        $c = imagecolorallocate($this->image_resource, $r, $g, $b);

        imagefilledrectangle($this->image_resource, 0, 0, $this->image_width, $this->image_height, $c);

        return $this;
    }
573998
public function getRgbByColor($color) {
		$result = imagecolorsforindex($this->image, $color);
		return array(
			$result['red'],
			$result['green'],
			$result['blue']
		);
	}