Class: Hexflex::TapePlacer
- Inherits:
-
Object
- Object
- Hexflex::TapePlacer
- Defined in:
- lib/hexflex/tape_placer.rb
Instance Attribute Summary collapse
-
#canvas ⇒ Object
readonly
Returns the value of attribute canvas.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#triangle_vector ⇒ Object
readonly
Returns the value of attribute triangle_vector.
Instance Method Summary collapse
-
#initialize(canvas, triangle_vector, index) ⇒ TapePlacer
constructor
A new instance of TapePlacer.
- #place! ⇒ Object
Constructor Details
#initialize(canvas, triangle_vector, index) ⇒ TapePlacer
Returns a new instance of TapePlacer.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/hexflex/tape_placer.rb', line 5 def initialize(canvas, triangle_vector, index) @canvas = canvas @triangle_vector = triangle_vector @index = index.to_i @triangle_base = @canvas.width / 5.0 @triangle_half_base = @triangle_base / 2.0 @triangle_height = @canvas.height / 2.0 @triangle_height_after_radius = @triangle_height / 3.0 end |
Instance Attribute Details
#canvas ⇒ Object (readonly)
Returns the value of attribute canvas.
3 4 5 |
# File 'lib/hexflex/tape_placer.rb', line 3 def canvas @canvas end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
3 4 5 |
# File 'lib/hexflex/tape_placer.rb', line 3 def index @index end |
#triangle_vector ⇒ Object (readonly)
Returns the value of attribute triangle_vector.
3 4 5 |
# File 'lib/hexflex/tape_placer.rb', line 3 def triangle_vector @triangle_vector end |
Instance Method Details
#place! ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/hexflex/tape_placer.rb', line 16 def place! @canvas.use(triangle_vector) .translate(*lateral_placement) .translate(*vertical_placement) .rotate(*rotation) .scale(*normalize_triangle_scale) end |