Brisko

Palette
in package

Table of Contents

generate()  : array<string|int, mixed>
Generate a Palette-style colors based on a base hex color.
adjust_color_component()  : int
Adjust an RGB color component based on a lightness factor.
hex_to_rgb()  : array<string|int, mixed>
Convert a hex color to an RGB array.
rgb_to_hex()  : string
Convert RGB values to a hex color string.
sanitize_hex()  : string
Sanitize and normalize a hex color code.

Methods

generate()

Generate a Palette-style colors based on a base hex color.

public static generate(string $base_hex, string $color_name) : array<string|int, mixed>
Parameters
$base_hex : string

The base hex color (e.g., #04e200).

$color_name : string

The name of the color.

Tags
throws
InvalidArgumentException

If an invalid hex color is provided.

Return values
array<string|int, mixed>

The generated color palette.

adjust_color_component()

Adjust an RGB color component based on a lightness factor.

private static adjust_color_component(int $component, float $factor) : int
Parameters
$component : int

The original color component (0-255).

$factor : float

The lightness factor (0.0 - 1.0).

Return values
int

The adjusted color component.

hex_to_rgb()

Convert a hex color to an RGB array.

private static hex_to_rgb(string $hex) : array<string|int, mixed>
Parameters
$hex : string

The hex color.

Return values
array<string|int, mixed>

An array containing RGB values.

rgb_to_hex()

Convert RGB values to a hex color string.

private static rgb_to_hex(int $r, int $g, int $b) : string
Parameters
$r : int

Red component (0-255).

$g : int

Green component (0-255).

$b : int

Blue component (0-255).

Return values
string

The hex color.

sanitize_hex()

Sanitize and normalize a hex color code.

private static sanitize_hex(string $hex) : string
Parameters
$hex : string

The input hex color.

Tags
throws
InvalidArgumentException

If the hex format is invalid.

Return values
string

The sanitized 6-character hex code.

Search results