Module: Sunniesnow::Tools

Defined in:
lib/sscharter/tools.rb,
lib/sscharter/tools/svg_path.rb

Defined Under Namespace

Modules: SvgPath

Class Method Summary collapse

Class Method Details

.path(data, range, total = range.end, &block) ⇒ SvgPath::Path .path(data, range_end, total = range_end, &block) ⇒ SvgPath::Path

Turn any SVG path into uniformly sampled points.

Examples:

path 'M -6,-0 C -4,2 -0,-0.7 -0,2 -0,4.7 6,-1 5,1 4,3 1,2 -0,-0 -1,-2 10,-2 6,-3 2,-4 -6,-0 -4,2 c 2,2 3,-8 0,-5', 128 do |x, y, i|
  d x, y; b 1/32r
end

Overloads:

  • .path(data, range, total = range.end, &block) ⇒ SvgPath::Path

    Parameters:

    • range (Range)
    • total (Integer) (defaults to: range.end)
  • .path(data, range_end, total = range_end, &block) ⇒ SvgPath::Path

    Parameters:

    • range_end (Integer)
    • total (Integer) (defaults to: range_end)

Parameters:

  • data (String)

    The SVG path definition.

Yield Parameters:

  • x (Float)
  • y (Float)
  • i (Integer)

Returns:



544
545
546
547
548
# File 'lib/sscharter/tools/svg_path.rb', line 544

module_function def path data, *args, &block
	result = SvgPath::Path.new data
	result.samples *args, &block if block
	result
end