HSVColor
Renfordt\Colors\HSVColor
Represents a color as hue, saturation, and value. Uses
Renfordt\Colors\Traits\HueBasedTrait for its RGB conversion.
Properties
| Property | Type | Range | Notes |
|---|---|---|---|
hue | int | 0–360 | Clamped on assignment |
saturation | float | 0.0–1.0 | Clamped on assignment |
value | float | 0.0–1.0 | Clamped on assignment |
alpha | float | 0.0–1.0 | Opacity; 1.0 = opaque. Defaults to 1.0. Clamped on assignment |
Static methods
create(array $hsv): HSVColor
Creates an instance from [hue, saturation, value], with an optional 4th alpha
element. Alpha defaults to 1.0 (opaque) when omitted.
$hsv = HSVColor::create([240, 0.8, 0.6]);
$hsva = HSVColor::create([240, 0.8, 0.6, 0.5]); // 50% opaque
make(array $hsv): HSVColor
Alias of create().
Instance methods
getHSV(): array
Returns the components as [hue, saturation, value] (alpha excluded).
getHSVA(): array
Returns the components as [hue, saturation, value, alpha].
toRGB(): RGBColor
Converts to RGBColor using chroma derived from saturation and value. The
0.0–1.0 alpha is carried through as a 0–255 int.
toHex(): HexColor
Converts to HexColor via RGB. Alpha is preserved.
Converting to HSL
There is no direct toHSL() method. Convert through RGB:
$hsl = HSVColor::create([240, 0.8, 0.6])->toRGB()->toHSL();
Adjusting brightness
HSVColor has no brighten() / darken() helpers. Assign the value property,
which is clamped on assignment:
$hsv = HSVColor::create([240, 0.8, 0.6]);
$hsv->value = 0.9;