Class: Pikl::Color
- Inherits:
-
Object
- Object
- Pikl::Color
- Defined in:
- lib/pikl/color.rb
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
- #getcolor(colormodel) ⇒ Object
-
#initialize(a, b, c, d) ⇒ Color
constructor
A new instance of Color.
-
#rawdata ⇒ Object
attr_accessor :color.
- #validate_color(v) ⇒ Object
Constructor Details
Class Method Details
.cmyk(c, m, y, k) ⇒ Object
21 22 23 |
# File 'lib/pikl/color.rb', line 21 def Color.cmyk(c,m,y,k) new(c,m,y,k) end |
.gray(g) ⇒ Object
13 14 15 |
# File 'lib/pikl/color.rb', line 13 def Color.gray(g) new(g,0,0,0) end |
.rgb(r, g, b) ⇒ Object
17 18 19 |
# File 'lib/pikl/color.rb', line 17 def Color.rgb(r, g, b) new(r,g,b,0) end |
Instance Method Details
#close ⇒ Object
35 36 37 38 |
# File 'lib/pikl/color.rb', line 35 def close Ext.pkl_color_close(@color) @color=nil end |
#getcolor(colormodel) ⇒ Object
30 31 32 33 |
# File 'lib/pikl/color.rb', line 30 def getcolor(colormodel) error("invalid colormodel parameter. # => #{colormodel}") unless COLORMODEL.include?(colormodel) Ext.pkl_color(@color, COLORMODEL[colormodel]) end |
#rawdata ⇒ Object
attr_accessor :color
26 27 28 |
# File 'lib/pikl/color.rb', line 26 def rawdata @color end |
#validate_color(v) ⇒ Object
40 41 42 43 |
# File 'lib/pikl/color.rb', line 40 def validate_color(v) error("invalid color parameter. # => #{v}") unless /^\d+$/ =~ v.to_s error("invalid color parameter. # => #{v}") unless v.to_i >= 0 && v.to_i <= 255 end |