Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: UTF-8 -*-
- import math
- import sys
- from reportlab.lib.units import inch
- LIB_DIR = './lib'
- if not LIB_DIR in sys.path:
- sys.path.insert(0, LIB_DIR)
- import PDF
- pdf = PDF.PDF('graph_paper.pdf', page_orientation = PDF.PageOrientation.Portrait)
- margin = 0.25 * inch
- spacing = 0.25 * inch
- spacing2 = 0.5 * math.sqrt(3) * spacing
- hmargin = 0.5 * math.fmod(pdf.page_width, spacing2)
- vmargin = 0.5 * math.fmod(pdf.page_height, spacing)
- epsilon = 0.25
- for col in range(int(pdf.page_width / spacing2) + 1):
- x = hmargin + col * spacing2
- for row in range(int(pdf.page_height / spacing) + 1):
- if col & 1 == 1:
- y = pdf.page_height - vmargin - row * spacing
- else:
- y = pdf.page_height - vmargin - (row + 0.5) * spacing
- pdf.ellipse(x-epsilon, y-epsilon, x+epsilon, y+epsilon, fill = 1)
- pdf.save()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement