Class: Scruffy::Components::Viewport
- Includes:
- Helpers::Canvas
- Defined in:
- lib/scruffy/components/viewport.rb
Overview
Component used to limit other visual components to a certain area on the graph.
Instance Attribute Summary
Attributes included from Helpers::Canvas
Attributes inherited from Base
#id, #options, #position, #size, #visible
Instance Method Summary collapse
- #draw(svg, bounds, options = {}) ⇒ Object
-
#initialize(*args, &block) ⇒ Viewport
constructor
A new instance of Viewport.
Methods included from Helpers::Canvas
#component, #remove, #reset_settings!
Methods inherited from Base
Constructor Details
#initialize(*args, &block) ⇒ Viewport
Returns a new instance of Viewport.
6 7 8 9 10 11 |
# File 'lib/scruffy/components/viewport.rb', line 6 def initialize(*args, &block) super(*args) self.components = [] block.call(self.components) if block end |
Instance Method Details
#draw(svg, bounds, options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/scruffy/components/viewport.rb', line 13 def draw(svg, bounds, ={}) svg.g() { self.components.each do |component| component.render(svg, bounds_for([bounds[:width], bounds[:height]], component.position, component.size), ) end } end |