Class: Quartz::Shading

Inherits:
Object
  • Object
show all
Defined in:
lib/rubyquartz/shading.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(function, options = {}) ⇒ Shading

Returns a new instance of Shading.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rubyquartz/shading.rb', line 30

def initialize(function, options={})
  type = options[:type] || :axial
  case type
  when :axial
    @function = function # Hold onto this so it doesn't get GC'd
    
    colorspace = options[:colorspace] || ColorSpace.new(:name => ColorSpace::GENERIC_RGB)
    start_point = options[:start] || Point.new(0, 0)
    end_point = options[:end] || Point.new(1, 0)
    extend_start = options[:extend_start] || false
    extend_end = options[:extend_end] || false
    _initialize_axial(colorspace, start_point.x, start_point.y, end_point.x, end_point.y,
                      function, extend_start, extend_end)
  else
    raise "Unknown shading type '#{type}'"
  end
end

Instance Attribute Details

#functionObject (readonly)

Returns the value of attribute function.



28
29
30
# File 'lib/rubyquartz/shading.rb', line 28

def function
  @function
end