Skip to content

Instantly share code, notes, and snippets.

@roktas
Last active September 6, 2023 09:41
Show Gist options
  • Save roktas/8ea8240e195d066d7d2745fc2ca11b4d to your computer and use it in GitHub Desktop.
Save roktas/8ea8240e195d066d7d2745fc2ca11b4d to your computer and use it in GitHub Desktop.
require 'victor'
svg = Victor::SVG.new width: 140, height: 100, style: { background: '#ddd' }
svg.build do
rect x: 10, y: 10, width: 120, height: 80, rx: 10, fill: '#666'
circle cx: 50, cy: 50, r: 30, fill: 'yellow'
circle cx: 58, cy: 32, r: 4, fill: 'black'
polygon points: %w[45,50 80,30 80,70], fill: '#666'
3.times do |i|
x = 80 + (i * 18)
circle cx: x, cy: 50, r: 4, fill: 'yellow'
end
end
svg.save '10_pacman'
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/env -S ruby -rsevgi/script
SVG width: 140, height: 100, style: { background: '#ddd' } do
rect x: 10, y: 10, width: 120, height: 80, rx: 10, fill: '#666'
circle cx: 50, cy: 50, r: 30, fill: 'yellow'
circle cx: 58, cy: 32, r: 4, fill: 'black'
polygon points: %w[45,50 80,30 80,70], fill: '#666'
Hrepeat(id: "dot", ny: 3, dy: 18) do
circle cx: 80, cy: 50, r: 4, fill: 'yellow'
end
end.Out
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment