Method: Scruffy::Layers::Stacked#render

Defined in:
lib/scruffy/layers/stacked.rb

#render(svg, options = {}) ⇒ Object

Overrides Base#render to fiddle with layers’ points to achieve a stacked effect.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/scruffy/layers/stacked.rb', line 32

def render(svg, options = {})
  #TODO ensure this works with new points
  current_points = points.dup
  
  layers.each do |layer|
    real_points = layer.points
    layer.points = current_points
    layer_options = options.dup
    layer_options[:color] = layer.preferred_color || layer.color || options[:theme].next_color          
    layer.render(svg, layer_options)
    options.merge(layer_options)
    layer.points = real_points
    
    layer.points.each_with_index { |val, idx| current_points[idx] -= val }
  end
end