setasign\SetaPDF2\Core\DataStructure\Color

AbstractColor Abstract class for color structures

File: /SetaPDF v2/Core/DataStructure/Color/AbstractColor.php
Old class name (alias): \SetaPDF_Core_DataStructure_Color

Class hierarchy

Summary

Properties

$_components

The array of color components


Static Methods

createByComponents()

public static AbstractColor::createByComponents (
int|float|string|array|\setasign\SetaPDF2\Core\Type\PdfArray $components
): AbstractColor

Create an instance by a PDF array object, PHP array or a hexadecimal string of an RGB value.

Parameters
$components : int|float|string|array|\setasign\SetaPDF2\Core\Type\PdfArray
 
Exceptions

Throws \InvalidArgumentException

hexToRgb()

WARNING: This method is marked as deprecated!

Use Rgb::hexToRgb() instead.

public static AbstractColor::hexToRgb (
string $hex
): array

Converts a hex encoded string (3 or 6 characters) into a component array of red, green and blue values.

Parameters
$hex : string
 

writePdfString()

public static AbstractColor::writePdfString (
\setasign\SetaPDF2\Core\Writer\WriteInterface $writer,
array $components,
?bool $stroking = true
): void

Writes the colors components to a writer.

Parameters
$writer : \setasign\SetaPDF2\Core\Writer\WriteInterface
 
$components : array
 
$stroking : ?bool
 

writePdfStringByComponents()

public static AbstractColor::writePdfStringByComponents (
\setasign\SetaPDF2\Core\Writer\WriteInterface $writer,
array|int|float|string $components,
bool $stroking = true
): void

Writes a color definition directly to a writer.

Parameters
$writer : \setasign\SetaPDF2\Core\Writer\WriteInterface
 
$components : array|int|float|string
 
$stroking : bool
 
Exceptions

Throws \InvalidArgumentException


Methods

__construct()

The constructor.

Parameters
$components : \setasign\SetaPDF2\Core\Type\PdfArray|array|float
 

__clone()

public AbstractColor::__clone (
void
): void

Implementation of __clone().

adjustAllComponents()

public AbstractColor::adjustAllComponents (
int|float $by
): void

Adjust all color components by a specific value.

Parameters
$by : int|float
 

draw()

public AbstractColor::draw (
\setasign\SetaPDF2\Core\Writer\WriteInterface $writer,
bool $stroking = true
): void

Write the color as a PDF string to a writer.

Parameters
$writer : \setasign\SetaPDF2\Core\Writer\WriteInterface
 
$stroking : bool
 

getValue()

Get the components of the color.

toPhp()

public AbstractColor::toPhp (
void
): array

Get the data as a PHP value.