diff --git a/doc/pattern_tools/gen_pattern.py b/doc/pattern_tools/gen_pattern.py index 720ebc7f919d3b8bd260c81ede5c5abe74d58cff..1f90615736262643b4af854e1161b2a74aeae1f9 100755 --- a/doc/pattern_tools/gen_pattern.py +++ b/doc/pattern_tools/gen_pattern.py @@ -36,18 +36,27 @@ class PatternMaker: 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): @@ -84,9 +93,9 @@ def main(): 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()