Class: Spreadsheet::Excel::Rgb
- Inherits:
-
Object
- Object
- Spreadsheet::Excel::Rgb
- Defined in:
- lib/spreadsheet/excel/rgb.rb
Constant Summary collapse
- @@RGB_MAP =
{ :xls_color_0 => 0x000000, :xls_color_1 => 0xffffff, :xls_color_2 => 0xff0000, :xls_color_3 => 0x00ff00, :xls_color_4 => 0x0000ff, :xls_color_5 => 0xffff00, :xls_color_6 => 0xff00ff, :xls_color_7 => 0x00ffff, :xls_color_8 => 0x800000, :xls_color_9 => 0x008000, :xls_color_10 => 0x008000, :xls_color_11 => 0x000080, :xls_color_12 => 0x808080, :xls_color_13 => 0x008080, :xls_color_14 => 0xc0c0c0, :xls_color_15 => 0x808080, :xls_color_16 => 0x9999ff, :xls_color_17 => 0x993366, :xls_color_18 => 0xffffcc, :xls_color_19 => 0xccffff, :xls_color_20 => 0x660066, :xls_color_21 => 0xff8080, :xls_color_22 => 0x0066cc, :xls_color_23 => 0xccccff, :xls_color_24 => 0x000080, :xls_color_25 => 0xff00ff, :xls_color_26 => 0xffff00, :xls_color_27 => 0x00ffff, :xls_color_28 => 0x800080, :xls_color_29 => 0x800000, :xls_color_30 => 0x008080, :xls_color_31 => 0x0000ff, :xls_color_32 => 0x00ccff, :xls_color_33 => 0xccffff, :xls_color_34 => 0xccffcc, :xls_color_35 => 0xffff99, :xls_color_36 => 0x99ccff, :xls_color_37 => 0xff99cc, :xls_color_38 => 0xcc99ff, :xls_color_39 => 0xffcc99, :xls_color_40 => 0x3366ff, :xls_color_41 => 0x33cccc, :xls_color_42 => 0x99cc00, :xls_color_43 => 0xffcc00, :xls_color_44 => 0xff9900, :xls_color_45 => 0xff6600, :xls_color_46 => 0x666699, :xls_color_47 => 0x969696, :xls_color_48 => 0x003366, :xls_color_49 => 0x339966, :xls_color_50 => 0x003300, :xls_color_51 => 0x333300, :xls_color_52 => 0x993300, :xls_color_53 => 0x993366, :xls_color_54 => 0x333399, :xls_color_55 => 0x333333, :builtin_black => 0x000000, :builtin_white => 0xffffff, :builtin_red => 0xff0000, :builtin_green => 0x00ff00, :builtin_blue => 0x0000ff, :builtin_yellow => 0xffff00, :builtin_magenta => 0xff00ff, :builtin_cyan => 0x00ffff, :aqua => 0x00ffff, :black => 0x000000, :blue => 0x0000ff, :cyan => 0x00ffff, :brown => 0x800000, :fuchsia => 0xff00ff, :gray => 0x808080, :grey => 0x808080, :green => 0x008000, :lime => 0x00ff00, :magenta => 0xff00ff, :navy => 0x000080, :orange => 0xff9900, :purple => 0x800080, :red => 0xff0000, :silver => 0xc0c0c0, :white => 0xffffff, :yellow => 0xffff00 }
Instance Attribute Summary collapse
-
#b ⇒ Object
Returns the value of attribute b.
-
#g ⇒ Object
Returns the value of attribute g.
-
#r ⇒ Object
Returns the value of attribute r.
Class Method Summary collapse
Instance Method Summary collapse
- #as_hex ⇒ Object
-
#initialize(r, g, b) ⇒ Rgb
constructor
A new instance of Rgb.
- #to_i ⇒ Object
Constructor Details
#initialize(r, g, b) ⇒ Rgb
Returns a new instance of Rgb.
107 108 109 110 111 |
# File 'lib/spreadsheet/excel/rgb.rb', line 107 def initialize(r,g,b) @r = r & 0xff @g = g & 0xff @b = b & 0xff end |
Instance Attribute Details
#b ⇒ Object
Returns the value of attribute b.
14 15 16 |
# File 'lib/spreadsheet/excel/rgb.rb', line 14 def b @b end |
#g ⇒ Object
Returns the value of attribute g.
14 15 16 |
# File 'lib/spreadsheet/excel/rgb.rb', line 14 def g @g end |
#r ⇒ Object
Returns the value of attribute r.
14 15 16 |
# File 'lib/spreadsheet/excel/rgb.rb', line 14 def r @r end |
Class Method Details
Instance Method Details
#as_hex ⇒ Object
117 118 119 |
# File 'lib/spreadsheet/excel/rgb.rb', line 117 def as_hex to_i.to_s(16) end |
#to_i ⇒ Object
113 114 115 |
# File 'lib/spreadsheet/excel/rgb.rb', line 113 def to_i (r * (256 * 256)) + (g * 256) + b end |