MCPcopy Create free account
hub / github.com/JoshuaPostel/texaform / Shape

Class Shape

python/utils.py:85–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83
84
85class Shape():
86 def __init__(self, text: str):
87 self.points: Set[Point] = set()
88
89 lines = text.split("\n")
90 for y, line in enumerate(lines):
91 for x, char in enumerate(line):
92 if char != ".":
93 self.points.add(Point(x, y))
94
95 def outline(self) -> Self:
96 outline = set()
97 for point in self.points:
98 for x_adj in [-1, 0, 1]:
99 for y_adj in [-1, 0, 1]:
100 point_adj = point + Point(x_adj, y_adj)
101 if point_adj not in self.points:
102 if point_adj.x >= 0 and point_adj.y >= 0:
103 outline.add(point_adj)
104
105 outline_shape = Shape("")
106 outline_shape.points = outline
107 return outline_shape
108
109@dataclass
110class ShapeProperties():

Callers 3

lazer_cutter.pyFile · 0.90
outlineMethod · 0.70
utils.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected