Class: Laser::Cutter::Sloped::Layout
- Inherits:
-
Object
- Object
- Laser::Cutter::Sloped::Layout
- Defined in:
- lib/laser/cutter/sloped/layout.rb
Overview
Lays the panels of a sloped box on the sheet, unfolded: the panels that wrap around the box in one column, in the order they wrap, and a side wall either side of the back.
+---------+
| front |
+---------+
| tilted |
+---------+
| top |
+-------+ +---------+ +-------+
| left | | back | | right |
+-------+ X---------+ +-------+
+---------+
| bottom |
+---------+
0,0
Edges that face each other on the sheet meet on the box. The front strip is turned half way round, so the edge it shares with the tilted panel faces that panel, and the right wall is the mirror image of the left. The corner at the bottom left is kept free for the metadata.
Instance Method Summary collapse
-
#initialize(sizes:, thickness:, padding:, metadata:) ⇒ Layout
constructor
A new instance of Layout.
-
#placements ⇒ Hash{String => Placement}
Where each panel goes, by name.
Constructor Details
#initialize(sizes:, thickness:, padding:, metadata:) ⇒ Layout
Returns a new instance of Layout.
33 34 35 36 37 38 39 |
# File 'lib/laser/cutter/sloped/layout.rb', line 33 def initialize(sizes:, thickness:, padding:, metadata:) @sizes = sizes @thickness = thickness.to_f @padding = padding.to_f @metadata = freeze end |
Instance Method Details
#placements ⇒ Hash{String => Placement}
Returns where each panel goes, by name.
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/laser/cutter/sloped/layout.rb', line 42 def placements wall = 2 * @thickness x, y = origin depth = @sizes['left'][0] placed = { 'left' => place('left', x - depth - wall - @padding, y), 'right' => place('right', x + @sizes['back'][0] + wall + @padding, y, flip_x: true), 'bottom' => place('bottom', x, y - @sizes['bottom'][1] - wall - @padding), 'back' => place('back', x, y) } placed.merge(column(x, y + @sizes['back'][1])) end |