Download the PHP package fyre/color without Composer
On this page you can find all versions of the php package fyre/color. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package color
FyreColor
FyreColor is a free, open-source immutable color manipulation library for PHP.
It is a modern library, and features full support for all CSS color-spaces.
Table Of Contents
- Installation
- Basic Usage
- Color Creation
- Colors
- A98 Rgb
- Display P3
- Display P3 Linear
- Hex
- Hsl
- Hwb
- Lab
- Lch
- OkLab
- OkLch
- ProPhoto Rgb
- Rec2020
- Rgb
- Srgb
- Srgb Linear
- Xyz D50
- Xyz D65
Installation
Using Composer
In PHP:
Basic Usage
$stringis a string representing the CSS color.
Color Creation
Create From A98 RGB
$redis a number between 0 and 1, and will default to 0.$greenis a number between 0 and 1, and will default to 0.$blueis a number between 0 and 1, and will default to 0.$alphais a number between 0 and 1, and will default to 1.
Create From Display P3
$redis a number between 0 and 1, and will default to 0.$greenis a number between 0 and 1, and will default to 0.$blueis a number between 0 and 1, and will default to 0.$alphais a number between 0 and 1, and will default to 1.
Create From Display P3 Linear
$redis a number between 0 and 1, and will default to 0.$greenis a number between 0 and 1, and will default to 0.$blueis a number between 0 and 1, and will default to 0.$alphais a number between 0 and 1, and will default to 1.
Create From HSL
$hueis a number between 0 and 360, and will default to 0.$saturationis a number between 0 and 100, and will default to 0.$lightnessis a number between 0 and 100, and will default to 0.$alphais a number between 0 and 1, and will default to 1.
Create From HWB
$hueis a number between 0 and 360, and will default to 0.$whitenessis a number between 0 and 100, and will default to 0.$blacknessis a number between 0 and 100, and will default to 0.$alphais a number between 0 and 1, and will default to 1.
Create From Lab
$lightnessis a number between 0 and 100, and will default to 0.$ais a number between -128 and 127, and will default to 0.$bis a number between -128 and 127, and will default to 0.$alphais a number between 0 and 1, and will default to 1.
Create From Lch
$lightnessis a number between 0 and 100, and will default to 0.$chromais a number between 0 and 230, and will default to 0.$hueis a number between 0 and 360, and will default to 0.$alphais a number between 0 and 1, and will default to 1.
Create From OkLab
$lightnessis a number between 0 and 1, and will default to 0.$ais a number between -0.4 and 0.4, and will default to 0.$bis a number between -0.4 and 0.4, and will default to 0.$alphais a number between 0 and 1, and will default to 1.
Create From OkLch
$lightnessis a number between 0 and 1, and will default to 0.$chromais a number between 0 and 0.4, and will default to 0.$hueis a number between 0 and 360, and will default to 0.$alphais a number between 0 and 1, and will default to 1.
Create From ProPhoto Rgb
$redis a number between 0 and 1, and will default to 0.$greenis a number between 0 and 1, and will default to 0.$blueis a number between 0 and 1, and will default to 0.$alphais a number between 0 and 1, and will default to 1.
Create From Rec 2020
$redis a number between 0 and 1, and will default to 0.$greenis a number between 0 and 1, and will default to 0.$blueis a number between 0 and 1, and will default to 0.$alphais a number between 0 and 1, and will default to 1.
Create From Rgb
$redis a number between 0 and 255, and will default to 0.$greenis a number between 0 and 255, and will default to 0.$blueis a number between 0 and 255, and will default to 0.$alphais a number between 0 and 1, and will default to 1.
Create From Srgb
$redis a number between 0 and 1, and will default to 0.$greenis a number between 0 and 1, and will default to 0.$blueis a number between 0 and 1, and will default to 0.$alphais a number between 0 and 1, and will default to 1.
Create From Srgb Linear
$redis a number between 0 and 1, and will default to 0.$greenis a number between 0 and 1, and will default to 0.$blueis a number between 0 and 1, and will default to 0.$alphais a number between 0 and 1, and will default to 1.
Create From Xyz D50
$xis a number between 0 and 1, and will default to 0.$yis a number between 0 and 1, and will default to 0.$zis a number between 0 and 1, and will default to 0.$alphais a number between 0 and 1, and will default to 1.
Create From Xyz D65
$xis a number between 0 and 1, and will default to 0.$yis a number between 0 and 1, and will default to 0.$zis a number between 0 and 1, and will default to 0.$alphais a number between 0 and 1, and will default to 1.
Colors
Contrast
Calculate the contrast between this and another Color.
$otheris a Color.
Get Alpha
Get the alpha value.
Label
Find the closest HTML color name for this color (in current color space).
Luma
Calculate the relative luminance value.
Space
Get the current color space.
To
Convert the Color to a named color space.
$spaceis a string representing the color space, and must be one of either "a98-rgb", "display-p3", "display-p3-linear", "hex", "hsl", "hwb", "lab", "lch", "oklab", "oklch", "prophoto-rgb", "rec2020", "rgb", "srgb", "srgb-linear", "xyz-d50" or "xyz-d65".
To A98 RGB
Convert the Color to A98Rgb.
To Array
Get the color components as an array.
To Display P3
Convert the Color to DisplayP3.
To Display P3 Linear
Convert the Color to DisplayP3Linear.
To Hex
Convert the Color to Hex.
To HSL
Convert the Color to Hsl.
To HWB
Convert the Color to Hwb.
To Lab
Convert the Color to Lab.
To Lch
Convert the Color to Lch.
To OkLab
Convert the Color to OkLab.
To OkLch
Convert the Color to OkLch.
To ProPhoto Rgb
Convert the Color to ProPhotoRgb.
To Rec 2020
Convert the Color to Rec2020.
To Rgb
Convert the Color to Rgb.
To Srgb
Convert the Color to Srgb.
To Srgb Linear
Convert the Color to SrgbLinear.
To String
Get the CSS color string.
$alphais a boolean indicating whether to include the alpha component in the string, and will default to null.$precisionis a number representing the decimal precision, and will default to 2.
To Xyz D50
Convert the Color to XyzD50.
To Xyz D65
Convert the Color to XyzD65.
With Alpha
Clone the Color with a new alpha value.
$alphais a number between 0 and 1.
A98 RGB
Get Blue
Get the blue value.
Get Green
Get the green value.
Get Red
Get the red value.
With Blue
Clone the Color with a new blue value.
$blueis a number between 0 and 1.
With Green
Clone the Color with a new green value.
$greenis a number between 0 and 1.
With Red
Clone the Color with a new red value.
$redis a number between 0 and 1.
Display P3
Get Blue
Get the blue value.
Get Green
Get the green value.
Get Red
Get the red value.
With Blue
Clone the Color with a new blue value.
$blueis a number between 0 and 1.
With Green
Clone the Color with a new green value.
$greenis a number between 0 and 1.
With Red
Clone the Color with a new red value.
$redis a number between 0 and 1.
Display P3 Linear
Get Blue
Get the blue value.
Get Green
Get the green value.
Get Red
Get the red value.
With Blue
Clone the Color with a new blue value.
$blueis a number between 0 and 1.
With Green
Clone the Color with a new green value.
$greenis a number between 0 and 1.
With Red
Clone the Color with a new red value.
$redis a number between 0 and 1.
Hex
Get Blue
Get the blue value.
Get Green
Get the green value.
Get Red
Get the red value.
To String
Get the CSS color string.
$alphais a boolean indicating whether to include the alpha component in the string, and will default to null.$precisionis a number representing the decimal precision, and will default to 2 (unused).$shortenHexis a boolean indicating whether shorten hex output, and will default to true.$nameis a boolean indicating whether to use CSS color names, and will default to false.
With Blue
Clone the Color with a new blue value.
$blueis a number between 0 and 255.
With Green
Clone the Color with a new green value.
$greenis a number between 0 and 255.
With Red
Clone the Color with a new red value.
$redis a number between 0 and 255.
Hsl
Get Hue
Get the hue value.
Get Lightness
Get the lightness value.
Get Saturation
Get the saturation value.
With Hue
Clone the Color with a new hue value.
$hueis a number between 0 and 360.
With Lightness
Clone the Color with a new lightness value.
$lightnessis a number between 0 and 100.
With Saturation
Clone the Color with a new saturation value.
$saturationis a number between 0 and 100.
Hwb
Get Blackness
Get the blackness value.
Get Hue
Get the hue value.
Get Whiteness
Get the whiteness value.
With Blackness
Clone the Color with a new blackness value.
$blacknessis a number between 0 and 100.
With Hue
Clone the Color with a new hue value.
$hueis a number between 0 and 360.
With Whiteness
Clone the Color with a new whiteness value.
$whitenessis a number between 0 and 100.
Lab
Get A
Get the a value.
Get B
Get the b value.
Get Lightness
Get the lightness value.
With A
Clone the Color with a new a value.
$ais a number between -128 and 127.
With B
$bis a number between -128 and 127.
With Lightness
Clone the Color with a new lightness value.
$lightnessis a number between 0 and 100.
Lch
Get Chroma
Get the chroma value.
Get Hue
Get the hue value.
Get Lightness
Get the lightness value.
With Chroma
Clone the Color with a new chroma value.
$chromais a number between 0 and 230.
With Hue
Clone the Color with a new hue value.
$hueis a number between 0 and 360.
With Lightness
Clone the Color with a new lightness value.
$lightnessis a number between 0 and 100.
OkLab
Get A
Get the a value.
Get B
Get the b value.
Get Lightness
Get the lightness value.
With A
Clone the Color with a new a value.
$ais a number between -0.4 and 0.4.
With B
$bis a number between -0.4 and 0.4.
With Lightness
Clone the Color with a new lightness value.
$lightnessis a number between 0 and 1.
OkLch
Get Chroma
Get the chroma value.
Get Hue
Get the hue value.
Get Lightness
Get the lightness value.
With Chroma
Clone the Color with a new chroma value.
$chromais a number between 0 and 0.4.
With Hue
Clone the Color with a new hue value.
$hueis a number between 0 and 360.
With Lightness
Clone the Color with a new lightness value.
$lightnessis a number between 0 and 1.
ProPhoto Rgb
Get Blue
Get the blue value.
Get Green
Get the green value.
Get Red
Get the red value.
With Blue
Clone the Color with a new blue value.
$blueis a number between 0 and 1.
With Green
Clone the Color with a new green value.
$greenis a number between 0 and 1.
With Red
Clone the Color with a new red value.
$redis a number between 0 and 1.
Rec2020
Get Blue
Get the blue value.
Get Green
Get the green value.
Get Red
Get the red value.
With Blue
Clone the Color with a new blue value.
$blueis a number between 0 and 1.
With Green
Clone the Color with a new green value.
$greenis a number between 0 and 1.
With Red
Clone the Color with a new red value.
$redis a number between 0 and 1.
Rgb
Get Blue
Get the blue value.
Get Green
Get the green value.
Get Red
Get the red value.
To String
Get the CSS color string.
$alphais a boolean indicating whether to include the alpha component in the string, and will default to null.$precisionis a number representing the decimal precision, and will default to 2.$nameis a boolean indicating whether to use CSS color names, and will default to false.
With Blue
Clone the Color with a new blue value.
$blueis a number between 0 and 255.
With Green
Clone the Color with a new green value.
$greenis a number between 0 and 255.
With Red
Clone the Color with a new red value.
$redis a number between 0 and 255.
Srgb
Get Blue
Get the blue value.
Get Green
Get the green value.
Get Red
Get the red value.
With Blue
Clone the Color with a new blue value.
$blueis a number between 0 and 1.
With Green
Clone the Color with a new green value.
$greenis a number between 0 and 1.
With Red
Clone the Color with a new red value.
$redis a number between 0 and 1.
Srgb Linear
Get Blue
Get the blue value.
Get Green
Get the green value.
Get Red
Get the red value.
With Blue
Clone the Color with a new blue value.
$blueis a number between 0 and 1.
With Green
Clone the Color with a new green value.
$greenis a number between 0 and 1.
With Red
Clone the Color with a new red value.
$redis a number between 0 and 1.
Xyz D50
Get X
Get the x value.
Get Y
Get the y value.
Get Z
Get the z value.
With X
Clone the Color with a new x value.
$xis a number between 0 and 1.
With Y
Clone the Color with a new y value.
$yis a number between 0 and 1.
With Z
Clone the Color with a new z value.
$zis a number between 0 and 1.
Xyz D65
Get X
Get the x value.
Get Y
Get the y value.
Get Z
Get the z value.
With X
Clone the Color with a new x value.
$xis a number between 0 and 1.
With Y
Clone the Color with a new y value.
$yis a number between 0 and 1.
With Z
Clone the Color with a new z value.
$zis a number between 0 and 1.