from __future__ import division import sys print ".P" print ".PS" # The coordinate system: (0, 0) is the center of the page. def absline((x1, y1), (x2, y2)): print "line from %f, %f to %f, %f" % (x1, y1, x2, y2) def line(p1, p2): absline(scale(p1), scale(p2)) def scale((x, y)): x /= 12 y /= 12 return (x, y) def spline(points): r = "spline from %f, %f" % scale(points[0]) for i in points[1:]: r += " to %f, %f" % scale(i) print r def draw(points): prev = points[0] for i in points[1:]: line(prev, i) prev = i # Draw the grid gridrecsize = 1 # number of boxes/inch on page pageheight = 8 pagewidth = 6 for i in range(pagewidth * gridrecsize + 1): x = i/gridrecsize - pagewidth/2 y = pageheight/2 absline((x, y), (x, -y)) for i in range(pageheight * gridrecsize + 1): y = i/gridrecsize - pageheight/2 x = pagewidth/2 absline((x, y), (-x, y)) extension = 48 # how far the counter extends down xr = 42/2 # x radius yr = 42/2 # y radius counterdepth = 27 + 1/8 xd = counterdepth/2 # how far the counter extends past the centerline def y2x(y): return xr*((1-(abs(y/yr)**exponent))**(1/exponent)) def x2y(x): return yr*((1-(abs(x/xr)**exponent))**(1/exponent)) exponent = 2.5 steps = 1000 xbend = (xd+xr)/2 # where the counter starts joining the main part ybend = -x2y(xbend) points = [] yincr = yr/steps y = yr while y>ybend: points.append((y2x(y), y)) y -= yincr # Curve in to the main counter i = len(points)-2 while points[i][1] < 0: x, y = points[i] points.append((xbend-(x-xbend), (ybend)-(y-(ybend)))) i -= 1 points.append((xd, -extension)) points = map(lambda(x, y): (-x, y), points[:1:-1]) + points draw(points) print ".PE"