Class: VectorSalad::StandardShapes::Jitter

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

Overview

Jitter the position of nodes in the contained shapes randomly.

Instance Method Summary (collapse)

Constructor Details

- (Any) initialize(max, min: 0, fn: nil, canvas:, **_options, &block)

Examples:

Jitter.new(5) do
  canvas << Triangle.new(30, at: [50, -50])
  canvas << Pentagon.new(40, at: [50, -100])
end

Using DSL:

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

Parameters:

  • max (Num)

    The maximum offset

  • min ([])

    The minimum offset (default 0)

  • fn ([])

    The quantization number of sides

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


27
28
29
30
31
32
33
# File 'lib/vector_salad/standard_shapes/jitter.rb', line 27

def initialize(max, min: 0, fn: nil, canvas:, **_options, &block)
  instance_eval(&block) # inner_canvas is populated

  @canvas.each do |shape|
    canvas << shape.jitter(max, min: min, fn: fn)
  end
end

Dynamic Method Handling

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