Documentation

RgbTint
in package

Class to handle tint applied to color.

Code borrows heavily from some Python projects.

Tags
see
https://docs.python.org/3/library/colorsys.html
see
https://gist.github.com/Mike-Honey/b36e651e9a7f1d2e1d60ce1c63b9b633

Table of Contents

Constants

HLSMAX  = 240.0
MS excel's tint function expects that HLS is base 240.
ONE_SIXTH  = 1.0 / 6.0
ONE_THIRD  = 1.0 / 3.0
RGBMAX  = 255.0
TWO_THIRD  = 2.0 / 3.0

Methods

rgbAndTintToRgb()  : string
Return result of tinting supplied rgb as 6 hex digits.
hlsToRgb()  : array<string|int, float>
Convert hue/luminance/saturation to red/green/blue.
msHlsToRgb()  : array<string|int, float>
Converts HLSMAX based HLS values to rgb values in the range (0,1).
positiveDecimalPart()  : float
rgbToHls()  : array<string|int, float>
Convert red/green/blue to hue/luminance/saturation.
rgbToMsHls()  : array<string|int, int>
Convert red/green/blue to HLSMAX-based hue/luminance/saturation.
tintLuminance()  : int
Tints HLSMAX based luminance.
vFunction()  : float

Constants

ONE_SIXTH

private mixed ONE_SIXTH = 1.0 / 6.0

ONE_THIRD

private mixed ONE_THIRD = 1.0 / 3.0

TWO_THIRD

private mixed TWO_THIRD = 2.0 / 3.0

Methods

rgbAndTintToRgb()

Return result of tinting supplied rgb as 6 hex digits.

public static rgbAndTintToRgb(int $red, int $green, int $blue, float $tint) : string
Parameters
$red : int
$green : int
$blue : int
$tint : float
Return values
string

hlsToRgb()

Convert hue/luminance/saturation to red/green/blue.

private static hlsToRgb(float $hue, float $luminance, float $saturation) : array<string|int, float>
Parameters
$hue : float

0.0 through 1.0

$luminance : float

0.0 through 1.0

$saturation : float

0.0 through 1.0

Return values
array<string|int, float>

msHlsToRgb()

Converts HLSMAX based HLS values to rgb values in the range (0,1).

private static msHlsToRgb(int $hue, int $lightness, int $saturation) : array<string|int, float>
Parameters
$hue : int
$lightness : int
$saturation : int
Return values
array<string|int, float>

positiveDecimalPart()

private static positiveDecimalPart(float $hue) : float
Parameters
$hue : float
Return values
float

rgbToHls()

Convert red/green/blue to hue/luminance/saturation.

private static rgbToHls(float $red, float $green, float $blue) : array<string|int, float>
Parameters
$red : float

0.0 through 1.0

$green : float

0.0 through 1.0

$blue : float

0.0 through 1.0

Return values
array<string|int, float>

rgbToMsHls()

Convert red/green/blue to HLSMAX-based hue/luminance/saturation.

private static rgbToMsHls(int $red, int $green, int $blue) : array<string|int, int>
Parameters
$red : int
$green : int
$blue : int
Return values
array<string|int, int>

vFunction()

private static vFunction(float $m1, float $m2, float $hue) : float
Parameters
$m1 : float
$m2 : float
$hue : float
Return values
float

        
On this page

Search results