Module: Color

Module | Color
In: | lib/color.rb lib/color/grayscale.rb

# Colour Management with Ruby

### Methods

near_one? near_one_or_more? near_zero? near_zero_or_less? new normalize normalize_byte normalize_to_range normalize_word

### Classes and Modules

Module Color::CSS
Module Color::Palette
Class Color::CMYK
Class Color::GrayScale
Class Color::HSL
Class Color::RGB
Class Color::YIQ

### Constants

COLOR_VERSION | = | '1.4.0'
COLOR_EPSILON | = | 1e-5 |  | The maximum "resolution" for colour math; if any value is less than or equal to this value, it is treated as zero.
COLOR_TOLERANCE | = | 1e-4 |  | The tolerance for comparing the components of two colours. In general, colours are considered equal if all of their components are within this tolerance value of each other.
GreyScale | = | GrayScale |  | A synonym for Color::GrayScale.

### External Aliases

normalize | -> | normalize_fractional
normalize_byte | -> | normalize_8bit
normalize_word | -> | normalize_16bit

### Public Class methods

near_one?(value)

Returns `true` if the value is within COLOR_EPSILON of one.

near_one_or_more?(value)

Returns `true` if the value is within COLOR_EPSILON of one or more than one.

near_zero?(value)

Returns `true` if the value is less than COLOR_EPSILON.

near_zero_or_less?(value)

Returns `true` if the value is within COLOR_EPSILON of zero or less than zero.

new(values, mode = :rgb)

Provides a thin veneer over the Color module to make it seem like this is Color 0.1.0 (a class) and not Color 1.4.0 (a module). This "constructor" will be removed in the future.

mode = :hsl: | `values` must be an array of [ hue deg, sat %, lum % ]. A Color::HSL object will be created.
mode = :rgb: | `values` will either be an HTML-style colour string or an array of [ red, green, blue ] (range 0 .. 255). A Color::RGB object will be created.
mode = :cmyk: | `values` must be an array of [ cyan %, magenta %, yellow %, black % ]. A Color::CMYK object will be created.

normalize(value)

Normalizes the value to the range (0.0) .. (1.0).

normalize_byte(value)

Normalize the value to the range (0) .. (255).

normalize_to_range(value, range)
normalize_word(value)

Normalize the value to the range (0) .. (65535).

[Validate]