ColourRGB
extends Colour
in package
Represents an RGB colour.
Table of Contents
Methods
- __construct() : mixed
- __toString() : string
- Returns this colour in a format CSS understands.
- convert() : ColourRGB
- Converts any other colour to a ColourRGB.
- fromMisuzu() : Colour
- Creates a Colour object from raw Misuzu format.
- fromRawARGB() : ColourRGB
- Create a ColourRGB instance from a raw ARGB value.
- fromRawRGB() : ColourRGB
- Create a ColourRGB instance from a raw RGB value.
- fromRawRGBA() : ColourRGB
- Create a ColourRGB instance from a raw RGBA value.
- 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.
- 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(int $red, int $green, int $blue[, float $alpha = 1.0 ]) : mixed
Parameters
- $red : int
-
Red property.
- $green : int
-
Green property.
- $blue : int
-
Blue 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 ColourRGB.
public
static convert(Colour $colour) : ColourRGB
Parameters
- $colour : Colour
-
Original colour.
Return values
ColourRGB —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.
fromRawARGB()
Create a ColourRGB instance from a raw ARGB value.
public
static fromRawARGB(int $raw) : ColourRGB
Parameters
- $raw : int
-
A raw ARGB colour in 0xAARRGGBB format.
Return values
ColourRGB —An instance of ColourRGB.
fromRawRGB()
Create a ColourRGB instance from a raw RGB value.
public
static fromRawRGB(int $raw) : ColourRGB
Parameters
- $raw : int
-
A raw RGB colour in 0xRRGGBB format.
Return values
ColourRGB —An instance of ColourRGB.
fromRawRGBA()
Create a ColourRGB instance from a raw RGBA value.
public
static fromRawRGBA(int $raw) : ColourRGB
Parameters
- $raw : int
-
A raw RGBA colour in 0xRRGGBBAA format.
Return values
ColourRGB —An instance of ColourRGB.
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.
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.
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.