SO FREAKING CLOSE

This commit is contained in:
XANTRONIX Development 2023-12-29 21:37:10 -05:00
parent 12606cbdd7
commit 64c9ee3dc5

View file

@ -30,6 +30,8 @@ class Path():
return cr.line_to(x, y + y2) return cr.line_to(x, y + y2)
def draw(self, cr: cairo.Context): def draw(self, cr: cairo.Context):
last = None
for item in self.commands: for item in self.commands:
command, args = item command, args = item
@ -38,6 +40,9 @@ class Path():
cr.move_to(*arg) cr.move_to(*arg)
elif command == 'm': elif command == 'm':
for arg in args: for arg in args:
if last == 'Z' or last == 'z':
cr.move_to(*arg)
else:
cr.rel_move_to(*arg) cr.rel_move_to(*arg)
elif command == 'L': elif command == 'L':
for arg in args: for arg in args:
@ -66,28 +71,31 @@ class Path():
elif command == 'Z' or command == 'z': elif command == 'Z' or command == 'z':
cr.close_path() cr.close_path()
last = command
class HexagonPattern(Path): class HexagonPattern(Path):
COMMANDS = ( COMMANDS = [
['M', [[23.246093, 0], [0, 13.382812]]], ['M', [[23.246093, 0],
['V', [44.689453,]], [0, 13.382812]]],
['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', []],
@ -98,14 +106,14 @@ class HexagonPattern(Path):
[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', []]
) ]
def __init__(self): def __init__(self):
super().__init__(self.COMMANDS) super().__init__(self.COMMANDS)
@ -230,5 +238,7 @@ class Cluster():
cr.rectangle(0, 0, self.WIDTH, self.HEIGHT) cr.rectangle(0, 0, self.WIDTH, self.HEIGHT)
cr.fill() cr.fill()
for gauge in self.gauges: for gauge in self.gauges:
gauge.draw_bg(cr) gauge.draw_bg(cr)