struct TCal::Color
- TCal::Color
- Struct
- Value
- Object
Overview
An RGB color value.
Defined in:
t_cal/color.crConstructors
- .new(red : UInt8, green : UInt8, blue : UInt8)
-
.new(rgb : String)
Initialize from a case-insensitive "RRGGBB" hex string.
-
.new(value : JSON::PullParser)
Deserialize from JSON, assuming an RGB hex string as used in the V3 API.
Instance Method Summary
- #blue : UInt8
-
#distance_from(other : self) : Float
Returns the perceptual distance between this color and another.
- #green : UInt8
- #red : UInt8
-
#to_css : String
Convert to a CSS color value.
-
#to_ical : String
Convert to an iCal
COLOR
value.
Constructor Detail
def self.new(value : JSON::PullParser)
#
Deserialize from JSON, assuming an RGB hex string as used in the V3 API.
Instance Method Detail
def distance_from(other : self) : Float
#
Returns the perceptual distance between this color and another. Uses the "redmean" algorithm: https://www.compuphase.com/cmetric.htm
def to_ical : String
#
Convert to an iCal COLOR
value.
The standard only allows expressing colors as CSS3 color names, so the
conversion is not exact. The "closest" color by #distance_from
is used.