Class: VectorSalad::StandardShapes::Custom
- Inherits:
-
BasicShape
- Object
- BasicShape
- VectorSalad::StandardShapes::Custom
- Defined in:
- lib/vector_salad/standard_shapes/custom.rb
Overview
Make your own custom shape.
Instance Attribute Summary (collapse)
-
- (Object) options
inherited
from BasicShape
Returns the value of attribute options.
Instance Method Summary (collapse)
-
- (Any) initialize(name, **options, &block)
constructor
You must name your custom shape to be able to use it later.
Constructor Details
- (Any) initialize(name, **options, &block)
You must name your custom shape to be able to use it later. The block passed to custom shape is what will create your shape. If you create just 1 shape (e.g. with MultiPath or one of the VectorSalad::StandardShapes::Clip operations which return a MultiPath) then that's what's added to the canvas, but if you create multiple shapes they will be wrapped in a Group.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/vector_salad/standard_shapes/custom.rb', line 31 def initialize(name, **, &block) const = name.to_s.capitalize.to_sym ::VectorSalad::StandardShapes.const_set(const, Class.new(Custom) do include VectorSalad::DSL include VectorSalad::StandardShapes define_method(:initialize, &block) def canvas @canvas ||= VectorSalad::Canvas.new end def to_path if canvas.length == 1 canvas[0] else Group.new.tap(&:canvas=.(@canvas)) end end end) end |
Instance Attribute Details
- (Object) options Originally defined in class BasicShape
Returns the value of attribute options