Skip to content

Instantly share code, notes, and snippets.

@moutend
Created November 29, 2017 06:09
Show Gist options
  • Save moutend/183f11f317dfd0b4ac6a69a111145cc3 to your computer and use it in GitHub Desktop.
Save moutend/183f11f317dfd0b4ac6a69a111145cc3 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
puts <<EOL
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg"
width="1200" height="240">
<!-- body -->
<rect x="0" y="0" width="1152" height="60" style="fill: #000; stroke-width: 4; stroke: #555" />
<rect x="0" y="60" width="96" height="180" style="fill: #222; stroke-width: 4; stroke: #AAA" />
<text x="30" y="36" font-family="arial" font-weight="bold" font-size="32" fill="#888">iRig KEYS 37</text>
<!-- white keys -->
EOL
width = 48
height = 180
x = width * 2
y = 60
22.times do
puts " <rect x=\"#{x}\" y=\"#{y}\" width=\"#{width}\" height=\"#{height}\" style=\"fill: #FFF; stroke-width: 4; stroke: #777\" />"
x += width
end
bk_width = 20
bk_height = 110
x = width * 2 + width / 2 + bk_width / 2 + 4
count = 0
21.times do
count += 1
if count == 3 || count == 7
# skip render rect
else
puts " <rect x=\"#{x}\" y=\"#{y}\" width=\"#{bk_width}\" height=\"#{bk_height}\" style=\"fill: #111; stroke-width: 4; stroke: #555\" />"
end
x += width
count = 0 if count == 7
end
x = width * 2 + 6
y = 230
notes = %w{C D E F G A B}
22.times do |i|
note = notes[i % 7]
text = "#{note}#{i / 7 + 2}"
puts " <text x=\"#{x}\" y=\"#{y}\" font-family=\"arial\" font-weight=\"bold\" font-size=\"24\" fill=\"#111\">#{text}</text>"
x += width
end
x = width * 2.5 + 5
y = 50
notes = %w{C# D# E# F# G# A# B#}
count = 0
21.times do |i|
count += 1
if count == 3 || count == 7
# skip
else
note = notes[i % 7]
text = "#{note}#{i / 7 + 2}"
puts " <text x=\"#{x}\" y=\"#{y}\" font-family=\"arial\" font-weight=\"bold\" font-size=\"20\" fill=\"#FFF\">#{text}</text>"
end
count = 0 if count == 7
x += width
end
puts "</svg>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment