# DSL

Requiring victor/script provides a streamlined way to create SVG images by automatically setting up an #svg object.

# Target Image

In the example below, we are creating this image.

# Usage Pattern

  1. Require victor/script.
  2. Use the #setup method to configure your SVG, like setting the viewBox.
  3. Use the #build method to start defining your SVG content.
  4. Save the SVG output to a file using the #save method.

# Code

require 'victor/script'

setup viewBox: '-10 -10 120 120'

build do
  mask id: 'heart' do
    rect x: 0, y: 0, width: 100, height: 100, fill: 'white'
    path d: 'M10,35 A20,20,0,0,1,50,35 A20,20,0,0,1,90,35 Q90,65,50,95 Q10,65,10,35 Z',
      fill: 'black'
  end

  polygon points: '-10,120 120,120 120,-10', fill: :orange
  circle cx: 50, cy: 50, r: 50, mask: 'url(#heart)', fill: :red
end

save 'heart'

See this example on GitHub

# See Also