Class: Quartz::Color
- Inherits:
-
Object
- Object
- Quartz::Color
- Defined in:
- lib/rubyquartz/color.rb
Constant Summary collapse
- @@Gray =
nil
- @@RGB =
nil
- @@CMYK =
nil
Instance Attribute Summary collapse
-
#colorspace ⇒ Object
readonly
Returns the value of attribute colorspace.
Class Method Summary collapse
- .cmyk(c, m, y, k, a = 1.0) ⇒ Object
- .gray(g, a = 1.0) ⇒ Object
- .hsv(h, s, v, a = 1.0) ⇒ Object
- .rgb(r, g, b, a = 1.0) ⇒ Object
Instance Method Summary collapse
-
#initialize(colorspace, *components) ⇒ Color
constructor
A new instance of Color.
- #to_s ⇒ Object
Constructor Details
#initialize(colorspace, *components) ⇒ Color
Returns a new instance of Color.
35 36 37 38 39 |
# File 'lib/rubyquartz/color.rb', line 35 def initialize(colorspace, *components) @colorspace = colorspace @components = components _initialize_with_components(colorspace, components) end |
Instance Attribute Details
#colorspace ⇒ Object (readonly)
Returns the value of attribute colorspace.
33 34 35 |
# File 'lib/rubyquartz/color.rb', line 33 def colorspace @colorspace end |
Class Method Details
.cmyk(c, m, y, k, a = 1.0) ⇒ Object
53 54 55 56 |
# File 'lib/rubyquartz/color.rb', line 53 def self.cmyk(c, m, y, k, a = 1.0) @@CMYK = ColorSpace.new(:name => ColorSpace::GENERIC_CMYK) if @@CMYK.nil? new(@@CMYK, c, m, y, k, a) end |
.gray(g, a = 1.0) ⇒ Object
43 44 45 46 |
# File 'lib/rubyquartz/color.rb', line 43 def self.gray(g, a = 1.0) @@Gray = ColorSpace.new(:name => ColorSpace::GENERIC_GRAY) if @@Gray.nil? new(@@Gray, g, a) end |
.hsv(h, s, v, a = 1.0) ⇒ Object
58 59 60 61 62 |
# File 'lib/rubyquartz/color.rb', line 58 def self.hsv(h, s, v, a = 1.0) components = [h, s, v] convert_hsv_to_rgb(components) rgb(components[0], components[1], components[2], a) end |
.rgb(r, g, b, a = 1.0) ⇒ Object
48 49 50 51 |
# File 'lib/rubyquartz/color.rb', line 48 def self.rgb(r, g, b, a = 1.0) @@RGB = ColorSpace.new(:name => ColorSpace::GENERIC_RGB) if @@RGB.nil? new(@@RGB, r, g, b, a) end |
Instance Method Details
#to_s ⇒ Object
64 65 66 |
# File 'lib/rubyquartz/color.rb', line 64 def to_s "<Color: #{@colorspace.name} #{@components.join(" ")}" end |