Class: VectorSalad::StandardShapes::Custom

Inherits:
BasicShape
  • Object
show all
Defined in:
lib/vector_salad/standard_shapes/custom.rb

Overview

Make your own custom shape.

Instance Attribute Summary

Attributes inherited from BasicShape

#options

Instance Method Summary collapse

Methods inherited from BasicShape

#flip, #flip_x, #flip_y, #jitter, #move, #rotate, #scale, #to_a, #to_bezier_path, #to_cubic_path, #to_multi_path, #to_path, #to_simple_path, #to_svg

Constructor Details

#initialize(name, **options, &block) ⇒ Custom

Returns a new instance of Custom.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/vector_salad/standard_shapes/custom.rb', line 28

def initialize(name, **options, &block)
  ::VectorSalad::StandardShapes.const_set(name.to_s.capitalize.to_sym, Class.new(BasicShape) do
    include VectorSalad::DSL
    include VectorSalad::StandardShapes

    define_method(:initialize, &block)

    def canvas
      @canvas ||= VectorSalad::Canvas.new
    end

    def to_path
      canvas[0]
    end
  end)
end