Created
April 4, 2012 04:43
-
-
Save simonster/2297848 to your computer and use it in GitHub Desktop.
Arcs in PostScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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