struct TCal::Color

Overview

An RGB color value.

Defined in:

t_cal/color.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(red : UInt8, green : UInt8, blue : UInt8) #

[View source]
def self.new(rgb : String) #

Initialize from a case-insensitive "RRGGBB" hex string.


[View source]
def self.new(value : JSON::PullParser) #

Deserialize from JSON, assuming an RGB hex string as used in the V3 API.


[View source]

Instance Method Detail

def blue : UInt8 #

[View source]
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


[View source]
def green : UInt8 #

[View source]
def red : UInt8 #

[View source]
def to_css : String #

Convert to a CSS color value.


[View source]
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.


[View source]