Tsugi

HSLuv
in package

Port of HSLuv Color library to PHP by Carlos Cabo. V.2.0.0 Original by Alexei Boronine. https://github.com/hsluv

The math for most of this module was taken from:

http://www.easyrgb.com http://www.brucelindbloom.com Wikipedia

All numbers below taken from math/bounds.wxm wxMaxima file. We use 17 digits of decimal precision to export the numbers, effectively exporting them as double precision IEEE 754 floats.

"If an IEEE 754 double precision is converted to a decimal string with at least 17 significant digits and then converted back to double, then the final number must match the original"

Source: https://en.wikipedia.org/wiki/Double-precision_floating-point_format

Table of Contents

Constants

EPSILLON  : mixed = 0.008856451679035631
KAPPA  : mixed = 903.2962962962963
M  : mixed = ['R' => [3.2409699419045213, -1.537383177570093...
M_INV  : mixed = ['X' => [0.4123907992659595, 0.3575843393838779...
REF_U  : mixed = 0.19783000664283681
REF_V  : mixed = 0.468319994938791

Methods

fromHex()  : mixed
fromRgb()  : mixed
fromRgbInt()  : mixed
hexToRgb()  : mixed
hpluvToLch()  : mixed
hpluvToRgb()  : mixed
hsluvToLch()  : mixed
hsluvToRgb()  : mixed
lchToHpluv()  : mixed
lchToHsluv()  : mixed
lchToLuv()  : mixed
lchToRgb()  : mixed
luvToLch()  : mixed
luvToXyz()  : mixed
p_fromHex()  : mixed
p_fromRgb()  : mixed
p_toHex()  : mixed
p_toRgb()  : mixed
rgbToHex()  : mixed
rgbToHpluv()  : mixed
rgbToHsluv()  : mixed
rgbToLch()  : mixed
rgbToXyz()  : mixed
toHex()  : mixed
toRgb()  : mixed
toRgbInt()  : mixed
xyzToLuv()  : mixed
xyzToRgb()  : mixed
componentsToTuple()  : mixed
distanceFromPole()  : mixed
dotProduct()  : mixed
fromLinear()  : mixed
getBounds()  : array<string|int, mixed>
For a given lightness, return a list of 6 lines in slope-intercept form that represent the bounds in CIELUV, stepping over which will push a value out of the RGB gamut
intersectLineLine()  : mixed
L_to_Y()  : mixed
lengthOfRayUntilIntersect()  : float|int|null
theta -- angle of ray starting at (0, 0) m, b -- slope and intercept of line x1, y1 -- coordinates of intersection len -- length of ray until it intersects with line
maxChromaForLH()  : mixed
For a given lightness and hue, return the maximum chroma that fits in the RGB gamut.
maxSafeChromaForL()  : mixed
For given lightness, returns the maximum chroma. Keeping the chroma value below this number will ensure that for any hue, the color is within the RGB gamut.
toLinear()  : mixed
Y_to_L()  : mixed
http://en.wikipedia.org/wiki/CIELUV In these formulas, Yn refers to the reference white point. We are using illuminant D65, so Yn (see refY in Maxima file) equals 1. The formula is simplified accordingly.

Constants

EPSILLON

public mixed EPSILLON = 0.008856451679035631

KAPPA

public mixed KAPPA = 903.2962962962963

M

public mixed M = ['R' => [3.2409699419045213, -1.5373831775700935, -0.4986107602930033], 'G' => [-0.9692436362808798, 1.8759675015077206, 0.04155505740717561], 'B' => [0.05563007969699361, -0.20397695888897657, 1.0569715142428786]]

M_INV

public mixed M_INV = ['X' => [0.4123907992659595, 0.35758433938387796, 0.1804807884018343], 'Y' => [0.21263900587151036, 0.7151686787677559, 0.07219231536073371], 'Z' => [0.01933081871559185, 0.11919477979462599, 0.9505321522496606]]

REF_U

public mixed REF_U = 0.19783000664283681

REF_V

public mixed REF_V = 0.468319994938791

Methods

fromHex()

public static fromHex(mixed $hex) : mixed
Parameters
$hex : mixed

fromRgb()

public static fromRgb() : mixed

fromRgbInt()

public static fromRgbInt() : mixed

hexToRgb()

public static hexToRgb(mixed $hex) : mixed
Parameters
$hex : mixed

hpluvToLch()

public static hpluvToLch(mixed $tuple) : mixed
Parameters
$tuple : mixed

hpluvToRgb()

public static hpluvToRgb() : mixed

hsluvToLch()

public static hsluvToLch(mixed $tuple) : mixed
Parameters
$tuple : mixed

hsluvToRgb()

public static hsluvToRgb() : mixed

lchToHpluv()

public static lchToHpluv(mixed $tuple) : mixed
Parameters
$tuple : mixed

lchToHsluv()

public static lchToHsluv(mixed $tuple) : mixed
Parameters
$tuple : mixed

lchToLuv()

public static lchToLuv(mixed $tuple) : mixed
Parameters
$tuple : mixed

lchToRgb()

public static lchToRgb() : mixed

luvToLch()

public static luvToLch(mixed $tuple) : mixed
Parameters
$tuple : mixed

luvToXyz()

public static luvToXyz(mixed $tuple) : mixed
Parameters
$tuple : mixed

p_fromHex()

public static p_fromHex(mixed $hex) : mixed
Parameters
$hex : mixed

p_fromRgb()

public static p_fromRgb() : mixed

p_toHex()

public static p_toHex() : mixed

p_toRgb()

public static p_toRgb() : mixed

rgbToHex()

public static rgbToHex(mixed $rgb) : mixed
Parameters
$rgb : mixed

rgbToHpluv()

public static rgbToHpluv() : mixed

rgbToHsluv()

public static rgbToHsluv() : mixed

rgbToLch()

public static rgbToLch() : mixed

rgbToXyz()

public static rgbToXyz(mixed $tuple) : mixed
Parameters
$tuple : mixed

toHex()

public static toHex() : mixed

toRgb()

public static toRgb() : mixed

toRgbInt()

public static toRgbInt() : mixed

xyzToLuv()

public static xyzToLuv(mixed $tuple) : mixed
Parameters
$tuple : mixed

xyzToRgb()

public static xyzToRgb(mixed $tuple) : mixed
Parameters
$tuple : mixed

componentsToTuple()

private static componentsToTuple(mixed $components) : mixed
Parameters
$components : mixed

distanceFromPole()

private static distanceFromPole(mixed $point) : mixed
Parameters
$point : mixed

dotProduct()

private static dotProduct(mixed $a, mixed $b) : mixed
Parameters
$a : mixed
$b : mixed

fromLinear()

private static fromLinear(mixed $c) : mixed
Parameters
$c : mixed

getBounds()

For a given lightness, return a list of 6 lines in slope-intercept form that represent the bounds in CIELUV, stepping over which will push a value out of the RGB gamut

private static getBounds(mixed $L) : array<string|int, mixed>
Parameters
$L : mixed
Return values
array<string|int, mixed>

intersectLineLine()

private static intersectLineLine(mixed $line1, mixed $line2) : mixed
Parameters
$line1 : mixed
$line2 : mixed

L_to_Y()

private static L_to_Y(mixed $L) : mixed
Parameters
$L : mixed

lengthOfRayUntilIntersect()

theta -- angle of ray starting at (0, 0) m, b -- slope and intercept of line x1, y1 -- coordinates of intersection len -- length of ray until it intersects with line

private static lengthOfRayUntilIntersect(mixed $theta, mixed $line) : float|int|null

b + m * x1 = y1 len >= 0 len * cos(theta) = x1 len * sin(theta) = y1

b + m * (len * cos(theta)) = len * sin(theta) b = len * sin(hrad) - m * len * cos(theta) b = len * (sin(hrad) - m * cos(hrad)) len = b / (sin(hrad) - m * cos(hrad))

Parameters
$theta : mixed
$line : mixed
Return values
float|int|null

maxChromaForLH()

For a given lightness and hue, return the maximum chroma that fits in the RGB gamut.

private static maxChromaForLH(mixed $L, mixed $H) : mixed
Parameters
$L : mixed
$H : mixed

maxSafeChromaForL()

For given lightness, returns the maximum chroma. Keeping the chroma value below this number will ensure that for any hue, the color is within the RGB gamut.

private static maxSafeChromaForL(mixed $L) : mixed
Parameters
$L : mixed

toLinear()

private static toLinear(mixed $c) : mixed
Parameters
$c : mixed

Y_to_L()

http://en.wikipedia.org/wiki/CIELUV In these formulas, Yn refers to the reference white point. We are using illuminant D65, so Yn (see refY in Maxima file) equals 1. The formula is simplified accordingly.

private static Y_to_L(mixed $Y) : mixed
Parameters
$Y : mixed

        
On this page

Search results