Merge pull request #18083 from IanMaquignaz:fix_gen_pattern_centering
* Fixed centering issue with make_cicle_pattern and make_acircle_pattern() * Fixed issue where asymmetric circles were not at 45 degree angles. Also fixed support for inch measurement by converting parsing to usage of floating points for page size * Fixed copy-paste error from experimental workspace
This commit is contained in:
parent
f53ff0d01c
commit
8c1af09989
@ -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()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user