Index Documentation

ColourHsl extends Colour
in package

Represents a colour using Hue, Saturation and Lightness.

Table of Contents

Methods

__construct()  : mixed
__toString()  : string
Returns this colour in a format CSS understands.
convert()  : ColourHsl
Converts any other colour to a ColourHsl.
fromMisuzu()  : Colour
Creates a Colour object from raw Misuzu format.
getAlpha()  : float
Retrieves the alpha component.
getBlue()  : int
Retrieves the Blue RGB byte.
getGreen()  : int
Retrieves the Green RGB byte.
getHue()  : float
Retrieves the Hue component.
getLightness()  : float
Retrieves the lightness component.
getLuminance()  : float
Calculates the luminance value of this colour.
getRed()  : int
Retrieves the Red RGB byte.
getSaturation()  : float
Retrieves the Saturation component.
init()  : void
Initialises the Colour class.
isDark()  : bool
Checks whether this colour is on the darker side of things.
isLight()  : bool
Checks whether this colour is on the brighter side of things.
mix()  : Colour
Mixes two colours.
none()  : Colour
Gets an empty colour.
parse()  : Colour
Attempts to parse a CSS format colour.
shouldInherit()  : bool
Whether this colour should be ignored and another should be used instead.
toMisuzu()  : int
Converts a Colour object to raw Misuzu format.

Methods

__construct()

public __construct(float $hue, float $saturation, float $lightness[, float $alpha = 1.0 ]) : mixed
Parameters
$hue : float

Hue property.

$saturation : float

Saturation property.

$lightness : float

Lightness property.

$alpha : float = 1.0

Alpha property.

__toString()

Returns this colour in a format CSS understands.

public __toString() : string
Return values
string

CSS compatible colour.

convert()

Converts any other colour to a ColourHsl.

public static convert(Colour $colour) : ColourHsl
Parameters
$colour : Colour

Original colour.

Return values
ColourHsl

Converted colour.

fromMisuzu()

Creates a Colour object from raw Misuzu format.

public static fromMisuzu(int $raw) : Colour

If bit 31 is set the global instance of ColourNull will always be returned, otherwise an instance of ColourRgb will be created using the fromRawRgb method (top 8 bits ignored).

Parameters
$raw : int

Raw RGB colour in Misuzu format.

Return values
Colour

Colour instance representing the Misuzu colour.

getAlpha()

Retrieves the alpha component.

public getAlpha() : float
Return values
float

A number ranging from 0.0 to 1.0.

getBlue()

Retrieves the Blue RGB byte.

public getBlue() : int
Return values
int

A number ranging from 0 to 255.

getGreen()

Retrieves the Green RGB byte.

public getGreen() : int
Return values
int

A number ranging from 0 to 255.

getHue()

Retrieves the Hue component.

public getHue() : float
Return values
float

Hue rotation value.

getLightness()

Retrieves the lightness component.

public getLightness() : float
Return values
float

Lightness value.

getLuminance()

Calculates the luminance value of this colour.

public getLuminance() : float
Return values
float

Luminance value for this colour.

getRed()

Retrieves the Red RGB byte.

public getRed() : int
Return values
int

A number ranging from 0 to 255.

getSaturation()

Retrieves the Saturation component.

public getSaturation() : float
Return values
float

Saturation value.

init()

Initialises the Colour class.

public static init() : void

isDark()

Checks whether this colour is on the darker side of things.

public isDark() : bool
Return values
bool

true if this colour would not be very legible on a dark background.

isLight()

Checks whether this colour is on the brighter side of things.

public isLight() : bool
Return values
bool

true if this colour would not be very legible on a light background.

mix()

Mixes two colours.

public static mix(Colour $colour1, Colour $colour2, float $weight) : Colour

0.0 -> Entirely $colour1 0.5 -> Midpoint between $colour1 and $colour2 1.0 -> Entirely $colour2

Parameters
$colour1 : Colour

Starting colour.

$colour2 : Colour

Ending colour.

$weight : float

Weight of $colour2.

Return values
Colour

Mixed colour.

none()

Gets an empty colour.

public static none() : Colour
Return values
Colour

A global instance of ColourNull.

parse()

Attempts to parse a CSS format colour.

public static parse(string|null $value) : Colour
Parameters
$value : string|null

CSS format colour.

Return values
Colour

Parsed CSS colour.

shouldInherit()

Whether this colour should be ignored and another should be used instead.

public shouldInherit() : bool
Return values
bool

true if this colour should be ignored.

toMisuzu()

Converts a Colour object to raw Misuzu format.

public static toMisuzu(Colour $colour) : int

If shouldInherit is true, an integer with only bit 31 will be returned, otherwise a raw RGB value will be returned.

Parameters
$colour : Colour

Colour to be converted to raw Misuzu format.

Return values
int

Raw Misuzu format colour.


        
On this page

Search results