New primitive: Boxes.step()
Outset a line by a given margin - negative values for insetting
This commit is contained in:
parent
a0338a559f
commit
7c004e2d2c
|
@ -717,6 +717,20 @@ class Boxes:
|
||||||
self.ctx.line_to(length, 0)
|
self.ctx.line_to(length, 0)
|
||||||
self.ctx.translate(*self.ctx.get_current_point())
|
self.ctx.translate(*self.ctx.get_current_point())
|
||||||
|
|
||||||
|
def step(self, out):
|
||||||
|
"""
|
||||||
|
Create a parallel step prependicular to the current direction
|
||||||
|
Positive values move to the outside of the part
|
||||||
|
"""
|
||||||
|
if out > 1E-5:
|
||||||
|
self.corner(-90)
|
||||||
|
self.edge(out)
|
||||||
|
self.corner(90)
|
||||||
|
elif out < -1E-5:
|
||||||
|
self.corner(90)
|
||||||
|
self.edge(-out)
|
||||||
|
self.corner(-90)
|
||||||
|
|
||||||
def curveTo(self, x1, y1, x2, y2, x3, y3):
|
def curveTo(self, x1, y1, x2, y2, x3, y3):
|
||||||
"""control point 1, control point 2, end point
|
"""control point 1, control point 2, end point
|
||||||
|
|
||||||
|
|
|
@ -450,17 +450,7 @@ class CompoundEdge(BaseEdge):
|
||||||
lastwidth = self.types[0].startwidth()
|
lastwidth = self.types[0].startwidth()
|
||||||
|
|
||||||
for e, l in zip(self.types, self.lengths):
|
for e, l in zip(self.types, self.lengths):
|
||||||
diff = e.startwidth() - lastwidth
|
self.step(e.startwidth() - lastwidth)
|
||||||
|
|
||||||
if diff > 1E-5:
|
|
||||||
self.boxes.corner(-90)
|
|
||||||
self.boxes.edge(diff)
|
|
||||||
self.boxes.corner(90)
|
|
||||||
elif diff < -1E-5:
|
|
||||||
self.boxes.corner(90)
|
|
||||||
self.boxes.edge(-diff)
|
|
||||||
self.boxes.corner(-90)
|
|
||||||
|
|
||||||
e(l)
|
e(l)
|
||||||
lastwidth = e.endwidth()
|
lastwidth = e.endwidth()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue