Skip to content

Instantly share code, notes, and snippets.

@dagezi
Created February 7, 2023 14:48
Show Gist options
  • Save dagezi/108d2b5ead64e1190c19bb4f314dbd32 to your computer and use it in GitHub Desktop.
Save dagezi/108d2b5ead64e1190c19bb4f314dbd32 to your computer and use it in GitHub Desktop.
def drawCube(x, y, scale = 1)
print <<-EOS
<g stroke="black" fill="none" transform="matrix(#{scale},0,0,#{scale},#{x},#{y})">
<rect x="50" y="100" width="90" height="90" />
<rect x="50" y="130" width="90" height="30" />
<rect x="80" y="100" width="30" height="90" />
<line x1="50" y1="100" x2="95" y2="55"/>
<line x1="80" y1="100" x2="125" y2="55"/>
<line x1="110" y1="100" x2="155" y2="55"/>
<line x1="140" y1="100" x2="185" y2="55"/>
<line x1="140" y1="130" x2="185" y2="85"/>
<line x1="140" y1="160" x2="185" y2="115"/>
<line x1="140" y1="190" x2="185" y2="145"/>
<path d="M65,85 h90 v90" />
<path d="M80,70 h90 v90" />
<path d="M95,55 h90 v90" />
</g>
EOS
end
print <<-EOS
<svg version="1.1"
baseProfile="full"
width="1000" height="1400"
xmlns="http://www.w3.org/2000/svg">
EOS
for x in 0..4
for y in 0..1
drawCube(x * 200, y * 200);
end
end
for x in 0..6
for y in 0..4
drawCube(x * 140, 400 + y * 140, 0.7);
end
end
print '</svg>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment