class Scruffy::Components::Viewport

Component used to limit other visual components to a certain area on the graph.

Public Class Methods

new(*args, &block) click to toggle source
# File lib/scruffy/components/viewport.rb, line 6
def initialize(*args, &block)
  super(*args)
  
  self.components = []
  block.call(self.components) if block
end

Public Instance Methods

draw(svg, bounds, options={}) click to toggle source
# File lib/scruffy/components/viewport.rb, line 13
def draw(svg, bounds, options={})
  svg.g(options_for) {
    self.components.each do |component|
      component.render(svg, 
        bounds_for([bounds[:width], bounds[:height]], 
          component.position, 
          component.size), 
        options)
    end
  }
end