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, #page_manager, #subject
Instance Method Summary collapse
- #enclosure ⇒ Object
- #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
#enclosure ⇒ Object
19 20 21 |
# File 'lib/laser-cutter/renderer/box_renderer.rb', line 19 def enclosure box.enclosure end |
#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
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/laser-cutter/renderer/box_renderer.rb', line 23 def render pdf = nil renderer = self pdf.instance_eval do self.line_width = renderer.config.stroke.send(renderer.config.units.to_sym) stroke_color renderer.config[:color] || BLACK renderer.box.generate_notches.each do |notch| LineRenderer.new(renderer.config, notch).render(self) end end end |