Class: Laser::Cutter::Renderer::BoxRenderer
- Defined in:
- lib/laser-cutter/renderer/box_renderer.rb
Constant Summary
Constants inherited from Base
Laser::Cutter::Renderer::Base::BLACK, Laser::Cutter::Renderer::Base::BLUE
Instance Attribute Summary
Attributes inherited from Base
#config, #enclosure, #page_manager, #subject
Instance Method Summary collapse
- #ensure_space_for(rect) ⇒ Object
-
#initialize(config) ⇒ BoxRenderer
constructor
A new instance of BoxRenderer.
- #render(pdf = nil) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(config) ⇒ BoxRenderer
Returns a new instance of BoxRenderer.
9 10 11 12 |
# File 'lib/laser-cutter/renderer/box_renderer.rb', line 9 def initialize(config) super(config) self.subject = Laser::Cutter::Box.new(config) end |
Instance Method Details
#ensure_space_for(rect) ⇒ Object
14 15 16 17 |
# File 'lib/laser-cutter/renderer/box_renderer.rb', line 14 def ensure_space_for(rect) coords = [ rect.p2.x, rect.p2.y ].map{|a| page_manager.value_from_units(a)} box. = Geometry::Point.new(coords) end |
#render(pdf = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/laser-cutter/renderer/box_renderer.rb', line 20 def render pdf = nil renderer = self pdf.instance_eval do self.line_width = renderer.config.stroke.send(renderer.config.units.to_sym) stroke_color BLACK renderer.box.notches.each do |notch| LineRenderer.new(renderer.config, notch).render(self) end end end |