def make_circles_pattern(self):
spacing = self.square_size
r = spacing / self.radius_rate
- for x in range(1, self.cols + 1):
- for y in range(1, self.rows + 1):
- dot = SVG("circle", cx=x * spacing, cy=y * spacing, r=r, fill="black", stroke="none")
+ pattern_width = ((self.cols - 1.0) * spacing) + (2.0 * r)
+ pattern_height = ((self.rows - 1.0) * spacing) + (2.0 * r)
+ x_spacing = (self.width - pattern_width) / 2.0
+ y_spacing = (self.height - pattern_height) / 2.0
+ for x in range(0, self.cols):
+ for y in range(0, self.rows):
+ dot = SVG("circle", cx=(x * spacing) + x_spacing + r,
+ cy=(y * spacing) + y_spacing + r, r=r, fill="black", stroke="none")
self.g.append(dot)
def make_acircles_pattern(self):
spacing = self.square_size
r = spacing / self.radius_rate
- for i in range(0, self.rows):
- for j in range(0, self.cols):
- dot = SVG("circle", cx=((j * 2 + i % 2) * spacing) + spacing, cy=self.height - (i * spacing + spacing),
- r=r, fill="black", stroke="none")
+ pattern_width = ((self.cols-1.0) * 2 * spacing) + spacing + (2.0 * r)
+ pattern_height = ((self.rows-1.0) * spacing) + (2.0 * r)
+ x_spacing = (self.width - pattern_width) / 2.0
+ y_spacing = (self.height - pattern_height) / 2.0
+ for x in range(0, self.cols):
+ for y in range(0, self.rows):
+ dot = SVG("circle", cx=(2 * x * spacing) + (y % 2)*spacing + x_spacing + r,
+ cy=(y * spacing) + y_spacing + r, r=r, fill="black", stroke="none")
self.g.append(dot)
def make_checkerboard_pattern(self):
parser.add_argument("-R", "--radius_rate", help="circles_radius = square_size/radius_rate", default="5.0",
action="store", dest="radius_rate", type=float)
parser.add_argument("-w", "--page_width", help="page width in units", default="216", action="store",
- dest="page_width", type=int)
+ dest="page_width", type=float)
parser.add_argument("-h", "--page_height", help="page height in units", default="279", action="store",
- dest="page_width", type=int)
+ dest="page_width", type=float)
parser.add_argument("-a", "--page_size", help="page size, supersedes -h -w arguments", default="A4", action="store",
dest="page_size", choices=["A0", "A1", "A2", "A3", "A4", "A5"])
args = parser.parse_args()