Class: Rays::ColorSpace

Inherits:
Object
  • Object
show all
Defined in:
lib/rays/color_space.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type = :RGBA, premultiplied = true) ⇒ ColorSpace

Returns a new instance of ColorSpace.



12
13
14
# File 'lib/rays/color_space.rb', line 12

def initialize (type = :RGBA, premultiplied = true)
  setup self.class.get_type(type), premultiplied
end

Class Method Details

.get_color_space(obj) ⇒ Object



26
27
28
# File 'lib/rays/color_space.rb', line 26

def self.get_color_space (obj)
  (ColorSpace === obj) ? obj : (ColorSpace.new get_type(obj))
end

.get_type(obj) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/rays/color_space.rb', line 16

def self.get_type (obj)
  case obj
  when Integer        then obj
  when String, Symbol then const_get obj
  else raise ArgumentError, "can not convert '#{obj}' to ColorSpace type."
  end
rescue NameError
  raise "ColoeSpace::#{obj} is not found."
end