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).


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).


def self.lch(l : Decimal, c : Decimal, h : Decimal) : Color #

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


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.


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.


def self.typedesc #

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.


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.


def b : Decimal #

Returns blue channel value decimal (0-255).


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.


def desc(io) #

def g : Decimal #

Returns green channel value decimal (0-255).


def hsl : Tuple(Decimal, Decimal, Decimal) #

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


def hsv : Tuple(Decimal, Decimal, Decimal) #

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


def lch : Tuple(Decimal, Decimal, Decimal) #

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


def r : Decimal #

Returns red channel value decimal (0-255).


def rgb : Tuple(Decimal, Decimal, Decimal) #

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


def to_s(io) #