-
Notifications
You must be signed in to change notification settings - Fork 1
RGBAColor
Mistralys edited this page Feb 4, 2022
·
14 revisions
This utility class is used to hold information on an RGB based color, with optional opacity / alpha channel.
- 8-Bit integer:
0
-255
(Standard color values) - 7-Bit integer:
0
-127
(PHP GD style alpha channel) - Float:
0.00
-1.00
(CSS opacity) - Percent:
0
-100
(General purpose)
- Red
- Green
- Blue
- Opacity
- Transparency (inverted opacity)
use AppUtils;
$color = new RGBColor
The match()
method compares two colors, ignoring the opacity.
use AppUtils;
$colorA = ColorFactory::createFromHEX('CCC');
$colorB = ColorFactory::createFromHEX('CCC');
if($colorA->matches($colorB))
{
echo 'Colors match.';
}
else
{
echo 'Colors do not match.';
}
Output:
Colors match.
The matchAlpha()
method compares two colors, including their opacity.
use AppUtils;
$colorA = ColorFactory::createFromHEX('CCCCCCDD');
$colorB = ColorFactory::createFromHEX('CCCCCCEE');
if($colorA->matchesAlpha($colorB))
{
echo 'Colors match.';
}
else
{
echo 'Colors do not match.';
}
Output:
Colors do not match.
New here?
Have a look at the overview for a list of all helper classes available in the package.
Table of contents
Find the current page in the collapsible "Pages" list above, and expand the page, to view a table of contents.