struct
Celestine::Color
- Celestine::Color
- Struct
- Value
- Object
Overview
Represents an RGBA/HSLA color with parsing, conversions, and manipulation utilities.
Defined in:
color/color.crConstructors
-
.hex(str : String) : Color
Parses hex color strings: "#RGB", "#RGBA", "#RRGGBB", or "#RRGGBBAA"
-
.hsl(h : Number, s : Number, l : Number, a : Number = 1.0) : Color
Creates a color from HSL (h: 0-360, s: 0.0-1.0 or 0-100, l: 0.0-1.0 or 0-100)
- .new(r : Number, g : Number, b : Number, a : Number = 1.0)
-
.rgb(r : Number, g : Number, b : Number, a : Number = 1.0) : Color
Creates a color from RGB integers (0-255) and alpha (0.0-1.0)
Instance Method Summary
- #a : Float64
- #b : UInt8
-
#complementary : Color
Returns the complementary color (180 degree hue shift)
-
#darken(amount : Number) : Color
Darkens color by a fraction (0.0 - 1.0)
-
#desaturate(amount : Number) : Color
Decreases saturation by a fraction (0.0 - 1.0)
- #g : UInt8
-
#lighten(amount : Number) : Color
Lightens color by a fraction (0.0 - 1.0)
-
#mix(other : Color, weight : Number = 0.5) : Color
Mixes this color with another color by weight (0.0 = self, 1.0 = other)
- #r : UInt8
-
#saturate(amount : Number) : Color
Increases saturation by a fraction (0.0 - 1.0)
-
#to_hex(include_alpha : Bool = false) : String
Formats as CSS hex string
-
#to_hsl : Tuple(Float64, Float64, Float64)
Converts this color to HSL representation: {hue, saturation, lightness}
-
#to_rgb : String
Formats as CSS rgb(...) string
-
#to_rgba : String
Formats as CSS rgba(...) string
-
#to_s(io : IO) : Nil
Default string conversion: hex when fully opaque, rgba when translucent
-
#to_s : String
Returns a nicely readable and concise string representation of this object, typically intended for users.
-
#with_alpha(new_alpha : Number) : Color
Returns a copy of this color with adjusted alpha
Constructor Detail
Parses hex color strings: "#RGB", "#RGBA", "#RRGGBB", or "#RRGGBBAA"
Creates a color from HSL (h: 0-360, s: 0.0-1.0 or 0-100, l: 0.0-1.0 or 0-100)
Creates a color from RGB integers (0-255) and alpha (0.0-1.0)
Instance Method Detail
Decreases saturation by a fraction (0.0 - 1.0)
Mixes this color with another color by weight (0.0 = self, 1.0 = other)
Increases saturation by a fraction (0.0 - 1.0)
Converts this color to HSL representation: {hue, saturation, lightness}
Returns a nicely readable and concise string representation of this object, typically intended for users.
This method should usually not be overridden. It delegates to
#to_s(IO) which can be overridden for custom implementations.
Also see #inspect.
Returns a copy of this color with adjusted alpha