Skip to content

Color RGB CMYK and Grayscale

shairontoledo edited this page Sep 13, 2010 · 4 revisions

The method create is a color factory depending on the parameter used. The parameter varies between 0 and 1, if value is greater that 1, it will be divided by 100.0 . The class Color Options :color is normally used in passing parameters in the construction of objects via facade method.

Creating RGB color

String HTML color converter


 Color.create '#FFAA33'

Using Symbol class, the create method will be found in RGhost::Constants::Color::RGB

 Color.create :red

Using Array with 3 elements
 
 Color.create [0.5, 0.3, 0.5]

Hash with 3 pairs of key/value. Valid keys :red, :green and :blue

 Color.create :red => 0.5, :green => 0.3, :blue => 0.5

Hash with 3 pairs of key/value. Valid keys :r, :g and :b

 Color.create :r => 0.5, :g => 0.3, :b => 0.5

h2. Creating CMYK color

Hash with 4 pair of key/value. Valids keys :cyan, :magenta, :yellow and :black


 Color.create :cyan=> 1 ,:magenta => 0.3, :yellow => 0, :black => 0

Hash with 4 pair of key/value. Valids keys :c, :m, :y and :b

 Color.create :c=> 1 ,:m => 0.3, :y => 0, :b => 0

Creating Gray color

A single Numeric


 Color.create 0.5

50 percent of black will be divided by 100.0

 Color.create 50