class Tioga::Colormaps

These are the methods for creating and using colormaps and color spaces in PDF graphics.

Public Instance Methods

convert_to_colormap(reds, greens, blues) click to toggle source

Returns a colormap corresponding to the given vectors of intensities. The intensities must be numbers between 0 and 1, and the vectors must be of equal lengths.

# File lib/Tioga/Colormaps.rb, line 83
def convert_to_colormap(reds, greens, blues)
end
create_colormap(dict) click to toggle source

Returns a color map as specified by the dictionary argument dict. The 'length' parameter determines the number of entries in the map and must be an integer between 2 and 256. The 'points' vector gives positions between 0.0 and 1.0 where the colors are explicitly specified for the map. The first color map entry corresponds to position 0.0, the last map entry is for position 1.0, and intermediate map entries are spaced evenly in between. The color specifications are given either as RGB triples (in the vectors 'Rs', 'Gs', and 'Bs') or as HLS triples (in the vectors 'Hs', 'Ls', and 'Ss'). In either case, there must be the same number of triples as there are positions in the 'points' vector. The color position points is assigned the color from the corresponding Rs, Gs, and Bs for the RGB case. In the HLS case, the triple Hs, Ls, and Ss is converted to a triple of RGB intensities, and that is assigned to the color position given by points. Color map entries for other positions are determined by linear interpolation from the neighboring assigned colors.

See also the prebuilt colormaps: #intense_colormap, #mellow_colormap, and rainbow_colormap.

Dictionary Entries

'length'   => an_integer      # integer between 2 and 256.  default is 256.
'points'   => a_dvector       # increasing locations starting at 0.0 and ending at 1.0
'Rs'       => a_dvector       # red intensities (between 0.0 and 1.0)
'Gs'       => a_dvector       # green intensities (between 0.0 and 1.0)
'Bs'       => a_dvector       # blue intensities (between 0.0 and 1.0)
'Hs'       => a_dvector       # hue angles in degrees (between 0 and 360)
'Ls'       => a_dvector       # lightness (between 0.0 and 1.0)
'Ss'       => a_dvector       # saturation (between 0.0 and 1.0)
# File lib/Tioga/Colormaps.rb, line 34
def create_colormap(dict)
end
create_gradient_colormap(dict) click to toggle source

Returns a color map for a gradient of HLS colors as specified by the dictionary argument dict. The hue is either fixed ('hue') or varies linearly (from 'starting_H' to 'ending_H'). The lightness is either fixed ('lightness') or varies linearly (from 'starting_L' to 'ending_L'). The saturation is either fixed ('saturation') or varies linearly (from 'starting_S' to 'ending_S').

Dictionary Entries

'hue'             => a_float   # hue angle in degrees (default 0)
'starting_H'      => a_float   # the starting hue angle
'ending_H'        => a_float   # the ending hue angle
'lightness'       => a_float   # lightness (default 0.5)
'starting_L'      => a_float   # the starting lightness
'ending_L'        => a_float   # the ending lightness
'saturation'      => a_float   # saturation (default 0.5)
'starting_S'      => a_float   # the starting saturation
'ending_S'        => a_float   # the ending saturation
# File lib/Tioga/Colormaps.rb, line 77
def create_gradient_colormap(dict)
end
get_color_from_colormap(colormap, color_position) click to toggle source

Returns the triple [ red, green, blue ] for the intensities of the color at the given color_position in colormap. Recall that a color position is a number between 0 and 1. See create_colormap.

# File lib/Tioga/Colormaps.rb, line 89
def get_color_from_colormap(colormap, color_position)
end
hls_to_rgb(hls_vec) click to toggle source

Returns a vector of [ red, green, blue ] intensities corresponding to the hls_vec color given as [ hue, lightness, saturation ]. See also rgb_to_hls.

# File lib/Tioga/Colormaps.rb, line 94
def hls_to_rgb(hls_vec)
end
intense_colormap click to toggle source

Returns a colormap with fully saturated reds and blues.

# File lib/Tioga/Colormaps.rb, line 41
def intense_colormap
end
mellow_colormap click to toggle source

Returns a colormap with reds and blues in which the saturation drops for high and low color positions,

# File lib/Tioga/Colormaps.rb, line 48
def mellow_colormap 
end
rainbow_colormap click to toggle source

Returns a colormap covering the spectrum from red, orange, yellow, green, blue, indigo, to violet (special thanks to Roy G. Biv for providing this).

# File lib/Tioga/Colormaps.rb, line 56
def rainbow_colormap
end
rgb_to_hls(rgb_vec) click to toggle source

Returns a vector of [ hue, lightness, saturation ] corresponding to the rgb_vec color given as [ red, green, blue ] intensities. See also hls_to_rgb.

# File lib/Tioga/Colormaps.rb, line 99
def rgb_to_hls(rgb_vec)
end
string_hls_to_rgb(str) click to toggle source

Returns a new string of [ red, green, blue ] byte triples corresponding to the colors given in str as triples of [ hue, lightness, saturation ]. For representation as a byte, intensities in range 0.0 to 1.0 are multiplied by 255 and rounded; hue angles in the range 0.0 to 360.0 are divided by 360, multiplied by 255, and rounded. See also #string_hls_to_rgb!.

# File lib/Tioga/Colormaps.rb, line 108
def string_hls_to_rgb(str)
end
string_hls_to_rgb!(str) click to toggle source

Modifies in-place the string of [ red, green, blue ] byte triples to give the corresponding colors as triples of [ hue, lightness, saturation ].

See also string_hls_to_rgb.

# File lib/Tioga/Colormaps.rb, line 114
def string_hls_to_rgb!(str)
end
string_rgb_to_hls(str) click to toggle source

Returns a new string of [ hue, lightness, saturation ] byte triples corresponding to the colors given in str as triples of [ red, green, blue ].

For representation as a byte, intensities in range 0.0 to 1.0 are multiplied by 255 and rounded; hue angles in the range 0.0 to 360.0 are divided by 360, multiplied by 255, and rounded. See also #string_rgb_to_hls!.

# File lib/Tioga/Colormaps.rb, line 122
def string_rgb_to_hls(str)
end
string_rgb_to_hls!(str) click to toggle source

Modifies in-place the string of [ hue, lightness, saturation ] byte triples to give the corresponding colors as triples of [ red, green, blue ].

See also string_rgb_to_hls.

# File lib/Tioga/Colormaps.rb, line 128
def string_rgb_to_hls!(str)
end