Index Documentation

Colour
in package
implements Stringable

AbstractYes

Abstract class for representing colours.

Table of Contents

Interfaces

Stringable

Methods

__toString()  : string
Returns this colour in a format CSS understands.
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.
getLuminance()  : float
Calculates the luminance value of this colour.
getRed()  : int
Retrieves the Red RGB byte.
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

__toString()

Returns this colour in a format CSS understands.

public abstract __toString() : string
Return values
string

CSS compatible 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 abstract getAlpha() : float
Return values
float

A number ranging from 0.0 to 1.0.

getBlue()

Retrieves the Blue RGB byte.

public abstract getBlue() : int
Return values
int

A number ranging from 0 to 255.

getGreen()

Retrieves the Green RGB byte.

public abstract getGreen() : int
Return values
int

A number ranging from 0 to 255.

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 abstract getRed() : int
Return values
int

A number ranging from 0 to 255.

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 abstract 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