Flatten paths execution a bit

This commit is contained in:
XANTRONIX Development 2024-01-02 01:14:22 -05:00
parent e9a62e90d2
commit 6a7fb1f9c6
2 changed files with 40 additions and 40 deletions

View file

@ -156,23 +156,23 @@ class Path():
command, args = item command, args = item
if command == 'M': if command == 'M':
for i in range(0, len(args)): for i in range(0, len(args), 2):
if i == 0: if i == 0:
cr.move_to(*args[i]) cr.move_to(args[i], args[i+1])
else: else:
cr.line_to(*args[i]) cr.line_to(args[i], args[i+1])
elif command == 'm': elif command == 'm':
for i in range(0, len(args)): for i in range(0, len(args), 2):
if i == 0: if i == 0:
cr.rel_move_to(*args[i]) cr.rel_move_to(args[i], args[i+1])
else: else:
cr.rel_line_to(*args[i]) cr.rel_line_to(args[i], args[i+1])
elif command == 'L': elif command == 'L':
for arg in args: for i in range(0, len(args), 2):
cr.line_to(*arg) cr.line_to(args[i], args[i+1])
elif command == 'l': elif command == 'l':
for arg in args: for i in range(0, len(args), 2):
cr.rel_line_to(*arg) cr.rel_line_to(args[i], args[i+1])
elif command == 'H': elif command == 'H':
for arg in args: for arg in args:
self.horiz_to(cr, arg) self.horiz_to(cr, arg)

View file

@ -15,43 +15,43 @@ class HexagonPattern(Pattern):
MATRIX_SCALE = (3, 3) MATRIX_SCALE = (3, 3)
COMMANDS = [ COMMANDS = [
['M', [[23.246093, 0], ['M', [23.246093, 0,
[ 0, 13.382812]]], 0, 13.382812]],
['V', [44.689453]], ['V', [44.689453]],
['L', [[0.0839844, 44.640625], ['L', [0.0839844, 44.640625,
[24.033203, 58.505859], 24.033203, 58.505859,
[24.001953, 86.332031], 24.001953, 86.332031,
[22.841796, 87]]], 22.841796, 87]],
['h', [4.478516]], ['h', [4.478516]],
['L', [[26.068359, 86.275391], ['L', [26.068359, 86.275391,
[26.099609, 58.449219], 26.099609, 58.449219,
[50.083984, 44.640625], 50.083984, 44.640625,
[74.033203, 58.505859], 74.033203, 58.505859,
[74.001953, 86.332031], 74.001953, 86.332031,
[72.841796, 87]]], 72.841796, 87]],
['h', [4.478516]], ['h', [4.478516]],
['L', [[ 76.068359, 86.275391], ['L', [ 76.068359, 86.275391,
[ 76.099609, 58.449219], 76.099609, 58.449219,
[100, 44.689453]]], 100, 44.689453]],
['V', [13.365234]], ['V', [13.365234]],
['L', [[76.919921, 0]]], ['L', [76.919921, 0]],
['H', [73.246093]], ['H', [73.246093]],
['L', [[50.015625, 13.373047], ['L', [50.015625, 13.373047,
[26.919921, 0]]], 26.919921, 0]],
['Z', []], ['Z', []],
['M', [[25.083984, 1.25], ['M', [25.083984, 1.25,
[49.033203, 15.115234], 49.033203, 15.115234,
[49.001953, 42.941406], 49.001953, 42.941406,
[25.017578, 56.75], 25.017578, 56.75,
[ 1.0019531, 42.845703]]], 1.0019531, 42.845703]],
['l', [[ 0.033203, -27.75]]], ['l', [ 0.033203, -27.75]],
['z', []], ['z', []],
['m', [[50, 0], ['m', [50, 0,
[24.017576, 13.904297], 24.017576, 13.904297,
[-0.0352, 27.75]]], -0.0352, 27.75]],
['L', [[75.017578, 56.75], ['L', [75.017578, 56.75,
[51.068359, 42.884766], 51.068359, 42.884766,
[51.099609, 15.058594]]], 51.099609, 15.058594]],
['Z', []] ['Z', []]
] ]