struct Novika::Color

Included Modules

Defined in:

novika/forms/color.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from module Novika::Form

a(type : T.class) : T forall T a, desc(io : IO)
desc : String
desc
, die(details : String) die, effect(io)
effect
effect
, on_open(engine : Engine) : self on_open, on_parent_open(engine : Engine) : self on_parent_open, onto(block : Block) : self onto, sel(a, b) sel, to_quote : Quote to_quote

Instance methods inherited from module Novika::Schedulable

schedule(engine : Engine, stack : Block) schedule, schedule!(engine : Engine, stack : Block) schedule!

Constructor Detail

def self.hsl(h : Decimal, s : Decimal, l : Decimal) : Color #

Creates a Color from hue (0 <= h <= 360, degrees), saturation (0 <= s <= 100, percents), and lightness (0 <= l <= 100, percents).


[View source]
def self.hsv(h, s, v) : Color #

Creates a Color from hue (0 <= h <= 360, degrees), saturation (0 <= s <= 100, percents), and value (0 <= v <= 100, percents).


[View source]
def self.lch(l : Decimal, c : Decimal, h : Decimal) : Color #

Creates a Color from lightness (0-100), chroma (0-132), hue (0-360).


[View source]
def self.rgb(r : Decimal, g : Decimal, b : Decimal) : Color #

Creates a Color from red (0 <= h <= 255), green (0 <= g <= 255), blue (0 <= b <= 255) channel values.


[View source]

Class Method Detail

def self.rgb(r, g, b) #

Creates a Color from red (0 <= h <= 255), green (0 <= g <= 255), blue (0 <= b <= 255) channel values.


[View source]
def self.typedesc #

[View source]

Instance Method Detail

def a : Decimal #

Holds alpha channel value decimal (0-255).

You can mutate this to set alpha, but do remember that Color is a struct.


[View source]
def a=(a : Decimal) #

Holds alpha channel value decimal (0-255).

You can mutate this to set alpha, but do remember that Color is a struct.


[View source]
def b : Decimal #

Returns blue channel value decimal (0-255).


[View source]
def closest(palette : Array(Color)) #

Returns the color closest to this color from palette.

How close one color is to another is determined by their distance in an HSV-backed coordinate system.


[View source]
def desc(io) #

[View source]
def g : Decimal #

Returns green channel value decimal (0-255).


[View source]
def hsl : Tuple(Decimal, Decimal, Decimal) #

Returns a tuple with H, S, L of this color.


[View source]
def hsv : Tuple(Decimal, Decimal, Decimal) #

Returns a tuple with H, S, V of this color.


[View source]
def lch : Tuple(Decimal, Decimal, Decimal) #

Returns a tuple with L, C, H of this color.


[View source]
def r : Decimal #

Returns red channel value decimal (0-255).


[View source]
def rgb : Tuple(Decimal, Decimal, Decimal) #

Returns a tuple of R, G, B channel values.


[View source]
def to_s(io) #

[View source]