Add and fix burn compensation
This commit is contained in:
parent
3757df27a7
commit
f57fcc3284
22
boxes.py
22
boxes.py
|
@ -129,22 +129,27 @@ class Boxes:
|
||||||
sections = int((length) // (width*2))
|
sections = int((length) // (width*2))
|
||||||
leftover = length - sections*width*2
|
leftover = length - sections*width*2
|
||||||
|
|
||||||
|
p = 1 if positive else -1
|
||||||
|
|
||||||
self.edge((width+leftover)/2.0+diffx-l1)
|
self.edge((width+leftover)/2.0+diffx-l1)
|
||||||
for i in xrange(sections):
|
for i in xrange(sections):
|
||||||
self._turn(radius+self.burn, angle, right=positive)
|
self._turn(radius-p*self.burn, angle, right=positive)
|
||||||
self.edge(2*(l2-l1))
|
self.edge(2*(l2-l1))
|
||||||
self._turn(radius-self.burn, angle, right=not positive)
|
self._turn(radius+p*self.burn, angle, right=not positive)
|
||||||
self.edge(2*(diffx-l1)+width)
|
self.edge(2*(diffx-l1)+width)
|
||||||
self._turn(radius-self.burn, angle, right=not positive)
|
self._turn(radius+p*self.burn, angle, right=not positive)
|
||||||
self.edge(2*(l2-l1))
|
self.edge(2*(l2-l1))
|
||||||
self._turn(radius+self.burn, angle, right=positive)
|
self._turn(radius-p*self.burn, angle, right=positive)
|
||||||
if i<sections-1: # all but the last
|
if i<sections-1: # all but the last
|
||||||
self.edge(2*(diffx-l1)+width)
|
self.edge(2*(diffx-l1)+width)
|
||||||
self.edge((width+leftover)/2.0+diffx-l1)
|
self.edge((width+leftover)/2.0+diffx-l1)
|
||||||
self.ctx.translate(*self.ctx.get_current_point())
|
self.ctx.translate(*self.ctx.get_current_point())
|
||||||
|
|
||||||
def flex(self, x, h, settings=None):
|
def flex(self, x, h, settings=None, burn=None):
|
||||||
dist, connection, width = settings or self.flexSettings
|
dist, connection, width = settings or self.flexSettings
|
||||||
|
if burn is None:
|
||||||
|
burn = self.burn
|
||||||
|
h += 2*burn
|
||||||
lines = int(x // dist)
|
lines = int(x // dist)
|
||||||
leftover = x - lines * dist
|
leftover = x - lines * dist
|
||||||
sections = int((h-connection) // width)
|
sections = int((h-connection) // width)
|
||||||
|
@ -192,10 +197,11 @@ class Boxes:
|
||||||
self.ctx.translate(*self.ctx.get_current_point())
|
self.ctx.translate(*self.ctx.get_current_point())
|
||||||
self.ctx.rotate(angle)
|
self.ctx.rotate(angle)
|
||||||
|
|
||||||
def fingerHolesAt(self, x, y, length, angle=90):
|
def fingerHolesAt(self, x, y, length, angle=90, burn=None):
|
||||||
# XXX burn
|
if burn is None:
|
||||||
|
burn = self.burn
|
||||||
self.ctx.save()
|
self.ctx.save()
|
||||||
self.moveTo(x, y, angle)
|
self.moveTo(x, y+burn, angle)
|
||||||
self.fingerHoles(length)
|
self.fingerHoles(length)
|
||||||
self.ctx.restore()
|
self.ctx.restore()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue