ColorUtilitiesTrait::backgroundDark

@param bool $gradient

@return static
15457
public function backgroundDark($gradient = false)
    {
        $this->textLight();
        $this->attributes->addAttributeClass('bg-' . ($gradient === true ? 'gradient-' : '') . 'dark');

        return $this;
    }
1006695
protected function setBackground()
    {
        // set background color of image by drawing a rectangle since imagecreatetruecolor doesn't set a bg color
        imagefilledrectangle($this->im, 0, 0,
                             $this->image_width, $this->image_height,
                             $this->gdbgcolor);

        if ($this->perturbation > 0) {
            imagefilledrectangle($this->tmpimg, 0, 0,
                                 $this->image_width * $this->iscale, $this->image_height * $this->iscale,
                                 $this->gdbgcolor);
        }

        if ($this->bgimg == '') {
            if ($this->background_directory != null &&
                is_dir($this->background_directory) &&
                is_readable($this->background_directory))
            {
                $img = $this->getBackgroundFromDirectory();
                if ($img != false) {
                    $this->bgimg = $img;
                }
            }
        }

        if ($this->bgimg == '') {
            return;
        }

        $dat = @getimagesize($this->bgimg);
        if($dat == false) {
            return;
        }

        switch($dat[2]) {
            case 1:  $newim = @imagecreatefromgif($this->bgimg); break;
            case 2:  $newim = @imagecreatefromjpeg($this->bgimg); break;
            case 3:  $newim = @imagecreatefrompng($this->bgimg); break;
            default: return;
        }

        if(!$newim) return;

        imagecopyresized($this->im, $newim, 0, 0, 0, 0,
                         $this->image_width, $this->image_height,
                         imagesx($newim), imagesy($newim));
    }
1202856
public function setIconColor($color = null)
    {
        $color === null || Checkers::checkColor($color, null);
        $this->iconColor = $color;
        return $this;
    }
670445
public final function negate( bool $internal = false ) : GdImage
   {

      if ( ! $internal )
      {
         $clon = clone $this;
         return $clon->negate( true );
      }

      $w = $this->getWidth();
      $h = $this->getHeight();

      $im = \imagecreatetruecolor( $w, $h );
      for ( $y = 0; $y < $h; ++$y )
      {
         for ( $x = 0; $x < $w; $x++ )
         {
            $colors = \imagecolorsforindex(
               $this->r,
               \imagecolorat( $this->r, $x, $y )
            );
            $r = 255 - $colors[ 'red' ];
            $g = 255 - $colors[ 'green' ];
            $b = 255 - $colors[ 'blue' ];
            $newColor = \imagecolorallocate( $im, $r, $g, $b );
            \imagesetpixel( $im, $x, $y, $newColor );
         }
      }
      
      \imagedestroy( $this->r );
      $this->r = null;
      
      $this->r = $im;
      
      return $this;
      
   }
1253579
public TextCharacter withBackgroundColor(TextColor backgroundColor) {
        if(this.backgroundColor == backgroundColor || this.backgroundColor.equals(backgroundColor)) {
            return this;
        }
        return new TextCharacter(character, foregroundColor, backgroundColor, modifiers);
    }
187354
public function visit(string $url): Dusk
    {
        $url = $this->applyBaseUrl($url);

        $this->getBrowser()->visit($url);

        return $this;
    }
1007109
public function setFontColor($fontColor)
    {
        $this->fontColor = $fontColor;
        $this->hasSetFontColor = true;
        $this->shouldApplyFont = true;
        return $this;
    }
1332893
public function highlight($type = 'bg', $isHighlight = true)
    {
        if ($type === 'bg') {
            $this->hasHighlightedBackground = $isHighlight;
        } else {
            $this->hasHighlightedForeground = $isHighlight;
        }

        return $this;
    }
216958
public function shade($percent = 50)
    {
        $clone = clone $this;
        $black = $clone->toRgb()->red(0)->green(0)->blue(0);
        return $this->mix($black, $percent);
    }
782970
def background=(background)
      if !background.is_a?(TrueClass) && !background.is_a?(FalseClass)
        fail(ArgumentError, "Background should be boolean")
      end

      manager.allowsBackgroundLocationUpdates = background
      @background = background
    end
184407
public static function fromGD($image, $backgroundColor = null)
    {
        if (!is_resource($image) || get_resource_type($image) != 'gd') {
            throw new \InvalidArgumentException('Image must be a gd resource');
        }
        if ($backgroundColor !== null && (!is_numeric($backgroundColor) || $backgroundColor < 0 || $backgroundColor > 16777215)) {
            throw new \InvalidArgumentException(sprintf('"%s" does not represent a valid color', $backgroundColor));
        }

        $palette = new self();

        $areColorsIndexed = !imageistruecolor($image);
        $imageWidth = imagesx($image);
        $imageHeight = imagesy($image);
        $palette->colors = [];

        $backgroundColorRed = ($backgroundColor >> 16) & 0xFF;
        $backgroundColorGreen = ($backgroundColor >> 8) & 0xFF;
        $backgroundColorBlue = $backgroundColor & 0xFF;

        for ($x = 0; $x < $imageWidth; ++$x) {
            for ($y = 0; $y < $imageHeight; ++$y) {
                $color = imagecolorat($image, $x, $y);
                if ($areColorsIndexed) {
                    $colorComponents = imagecolorsforindex($image, $color);
                    $color = ($colorComponents['alpha'] * 16777216) +
                             ($colorComponents['red'] * 65536) +
                             ($colorComponents['green'] * 256) +
                             ($colorComponents['blue']);
                }

                if ($alpha = $color >> 24) {
                    if ($backgroundColor === null) {
                        continue;
                    }

                    $alpha /= 127;
                    $color = (int) (($color >> 16 & 0xFF) * (1 - $alpha) + $backgroundColorRed * $alpha) * 65536 +
                             (int) (($color >> 8 & 0xFF) * (1 - $alpha) + $backgroundColorGreen * $alpha) * 256 +
                             (int) (($color & 0xFF) * (1 - $alpha) + $backgroundColorBlue * $alpha);
                }

                isset($palette->colors[$color]) ?
                    $palette->colors[$color] += 1 :
                    $palette->colors[$color] = 1;
            }
        }

        arsort($palette->colors);

        return $palette;
    }
1148731
public function bg($color)
    {
        Assert::nullOrOneOf($color, self::$colors, 'The color must be null or one of the Style::* color constants. Got: "%s"');

        $this->bgColor = $color;

        return $this;
    }
1174556
protected function gdImageBackground($image, $bgcolor){

		if( $bgcolor == 'transparent' ){
			imagesavealpha($image,true);
			$bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127);

		}else{
			list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
			$bgcolor1 = imagecolorallocate($image, $r, $g, $b);
		}

		imagefill($image, 0, 0, $bgcolor1);
	}
84264
public function color($color)
    {
        if ($color !== null) {
            Checkers::checkColor($color, null);
        }
        $this->color = $color;
        return $this;
    }
18812
public function alphaBlending(Bool $blendMode = NULL) : GD
    {
        imagealphablending($this->canvas, (bool) $blendMode);

        return $this;
    }
464943
private static GradientDrawable getKitkatBackground(int color) {
        final GradientDrawable gradientDrawable = new GradientDrawable();
        gradientDrawable.setCornerRadius(BackgroundUtils.convertToDIP(24));
        gradientDrawable.setColor(color);
        return gradientDrawable;
    }
333226
public function color(string $color): Bootstrap3ProgressBar
    {
        if (in_array($color, $this->supported_styles) === true) {
            $this->color = $color;
        }

        return $this;
    }