Class: VectorSalad::StandardShapes::Rotate

Inherits:
Transform
  • Object
show all
Defined in:
lib/vector_salad/standard_shapes/rotate.rb

Overview

Rotates the contained shapes by the specified angle about the origin.

Instance Method Summary (collapse)

Constructor Details

- (Any) initialize(angle, canvas:, **_options, &block)

Examples:

rotate(45) do
  triangle(30, at: [50, -50])
  pentagon(40, at: [50, -100])
end

Parameters:

  • angle (Num)
  • canvas ([])
  • _options ([])
  • block (Proc)


14
15
16
17
18
19
20
# File 'lib/vector_salad/standard_shapes/rotate.rb', line 14

def initialize(angle, canvas:, **_options, &block)
  instance_eval(&block) # inner_canvas is populated

  @canvas.each do |shape|
    canvas << shape.rotate(angle)
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class VectorSalad::DSL