Skip to content

Instantly share code, notes, and snippets.

@simonster
Created April 4, 2012 04:43
Show Gist options
  • Save simonster/2297848 to your computer and use it in GitHub Desktop.
Save simonster/2297848 to your computer and use it in GitHub Desktop.
Arcs in PostScript
#!/usr/bin/python
LINE_WIDTH = 2;
CIRCLE_RADIUS = 6
IMG_SIZE = 16;
NUM_ARCS = 20;
import subprocess;
p = subprocess.Popen(["gs", "-dSAFER", "-dNOPAUSE", "-r72", "-sDEVICE=pngalpha",
"-sOutputFile=arcs.png", "-"], stdin=subprocess.PIPE);
p.stdin.write("%!PS\n"+
"<< /PageSize ["+repr(IMG_SIZE*NUM_ARCS)+" "+repr(IMG_SIZE)+"] >> setpagedevice\n"+
repr(LINE_WIDTH)+" setlinewidth\n")
for i in range(1, NUM_ARCS+1):
p.stdin.write(repr(IMG_SIZE/2+(i-1)*IMG_SIZE)+" "+repr(IMG_SIZE/2)+" "+repr(CIRCLE_RADIUS) \
+" 90 "+repr(90-i*360/NUM_ARCS)+" arcn\nstroke\n")
p.stdin.write("showpage")
p.stdin.close()
p.wait()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment