Use special latch for the lexboxes instead of generic finger joint
This commit is contained in:
parent
012442de6c
commit
bd24170bcf
49
boxes.py
49
boxes.py
|
@ -226,6 +226,55 @@ class Boxes:
|
|||
self.ctx.line_to(x, 0)
|
||||
self.ctx.translate(*self.ctx.get_current_point())
|
||||
|
||||
def grip(self, length, depth):
|
||||
"""corrugated edge useful as an gipping area"""
|
||||
grooves = int(length // (depth*2.0)) + 1
|
||||
depth = length / grooves / 4.0
|
||||
for groove in xrange(grooves):
|
||||
self.corner(90, depth)
|
||||
self.corner(-180, depth)
|
||||
self.corner(90, depth)
|
||||
|
||||
def _latchHole(self, length):
|
||||
self.edge(self.thickness)
|
||||
self.corner(-90)
|
||||
self.edge(length/2.0-2*self.burn)
|
||||
self.corner(-90)
|
||||
self.edge(self.thickness)
|
||||
|
||||
def _latchGrip(self, length):
|
||||
self.corner(90, self.thickness/4.0)
|
||||
self.grip(length/2.0-self.thickness/2.0-2.0*self.burn, self.thickness/2.0)
|
||||
self.corner(90, self.thickness/4.0)
|
||||
|
||||
def latch(self, length, positive=True, reverse=False):
|
||||
"""Fix a flex box door at the box
|
||||
positive: False: Door side; True: Box side
|
||||
reverse: True when running away from the latch
|
||||
"""
|
||||
if positive:
|
||||
if reverse:
|
||||
self.edge(length/2.0-self.burn)
|
||||
self.corner(-90)
|
||||
self.edge(self.thickness)
|
||||
self.corner(90)
|
||||
self.edge(length/2.0)
|
||||
self.corner(90)
|
||||
self.edge(self.thickness)
|
||||
self.corner(-90)
|
||||
if not reverse:
|
||||
self.edge(length/2.0-self.burn)
|
||||
else:
|
||||
if reverse:
|
||||
self._latchGrip(length)
|
||||
else:
|
||||
self.corner(90)
|
||||
self._latchHole(length)
|
||||
if not reverse:
|
||||
self._latchGrip(length)
|
||||
else:
|
||||
self.corner(90)
|
||||
|
||||
def handle(self, x, h, hl, r=20):
|
||||
"""Creates and Edge with a handle"""
|
||||
d = (x-hl-2*r)/2.0
|
||||
|
|
18
flexbox.py
18
flexbox.py
|
@ -10,6 +10,8 @@ class FlexBox(boxes.Boxes):
|
|||
self.y = y
|
||||
self.z = z
|
||||
self.r = r or min(x, y)/2.0
|
||||
self.latchsize = 8*thickness
|
||||
|
||||
width = 2*x + 2*y - 8*r + 4*c4 + 4*thickness
|
||||
height = y + z + 40
|
||||
boxes.Boxes.__init__(self, width, height, thickness=thickness)
|
||||
|
@ -17,7 +19,6 @@ class FlexBox(boxes.Boxes):
|
|||
@boxes.restore
|
||||
def flexBoxSide(self, x, y, r, callback=None):
|
||||
space, finger = self.fingerJointSettings
|
||||
lock = 2.1*space + finger
|
||||
|
||||
self.moveTo(r, 0)
|
||||
for i, l in zip(range(2), (x, y)):
|
||||
|
@ -28,9 +29,9 @@ class FlexBox(boxes.Boxes):
|
|||
self.edge(x-2*r)
|
||||
self.corner(90, r)
|
||||
self.cc(callback, 3)
|
||||
self.fingerJoint(lock)
|
||||
self.latch(self.latchsize)
|
||||
self.cc(callback, 4)
|
||||
self.fingerJoint(y-2*r-lock)
|
||||
self.fingerJoint(y-2*r-self.latchsize)
|
||||
self.corner(90, r)
|
||||
|
||||
def surroundingWall(self):
|
||||
|
@ -39,9 +40,8 @@ class FlexBox(boxes.Boxes):
|
|||
c4 = math.pi * r * 0.5
|
||||
|
||||
space, finger = self.fingerJointSettings
|
||||
lock = 2.1*space + finger
|
||||
|
||||
self.fingerJoint(y-2*r-lock, False)
|
||||
self.fingerJoint(y-2*r-self.latchsize, False)
|
||||
self.flex(c4, z+2*self.thickness)
|
||||
self.fingerJoint(x-2*r, False)
|
||||
self.flex(c4, z+2*self.thickness)
|
||||
|
@ -49,11 +49,9 @@ class FlexBox(boxes.Boxes):
|
|||
self.flex(c4, z+2*self.thickness)
|
||||
self.edge(x-2*r)
|
||||
self.flex(c4, z+2*self.thickness)
|
||||
self.fingerJoint(lock, False)
|
||||
self.corner(90)
|
||||
self.latch(self.latchsize, False)
|
||||
self.edge(z+2*self.thickness)
|
||||
self.corner(90)
|
||||
self.fingerJoint(lock, False)
|
||||
self.latch(self.latchsize, False, True)
|
||||
self.edge(c4)
|
||||
self.edge(x-2*r)
|
||||
self.edge(c4)
|
||||
|
@ -61,7 +59,7 @@ class FlexBox(boxes.Boxes):
|
|||
self.edge(c4)
|
||||
self.fingerJoint(x-2*r, False)
|
||||
self.edge(c4)
|
||||
self.fingerJoint(y-2*r-lock, False)
|
||||
self.fingerJoint(y-2*r-self.latchsize, False)
|
||||
self.corner(90)
|
||||
self.edge(z+2*self.thickness)
|
||||
self.corner(90)
|
||||
|
|
34
flexbox2.py
34
flexbox2.py
|
@ -9,14 +9,13 @@ class FlexBox(boxes.Boxes):
|
|||
self.y = y
|
||||
self.z = z
|
||||
self.r = r or min(x, y)/2.0
|
||||
c4 = math.pi * r * 0.5
|
||||
self.c4 = c4 = math.pi * r * 0.5
|
||||
self.latchsize = 8*thickness
|
||||
|
||||
width = 2*x + y - 3*r + 2*c4 + 18*thickness # lock
|
||||
width = 2*x + y - 3*r + 2*c4 + 6*thickness + self.latchsize # lock
|
||||
height = y + z + 8*thickness
|
||||
|
||||
boxes.Boxes.__init__(self, width, height, thickness=thickness)
|
||||
space, finger = self.fingerJointSettings
|
||||
self.lock = 2.1*space + finger
|
||||
|
||||
@boxes.restore
|
||||
def flexBoxSide(self, x, y, r, callback=None):
|
||||
|
@ -31,30 +30,24 @@ class FlexBox(boxes.Boxes):
|
|||
self.edge(x-2*r)
|
||||
self.corner(90, r)
|
||||
self.cc(callback, 3)
|
||||
self.fingerJoint(self.lock)
|
||||
self.latch(self.latchsize)
|
||||
self.cc(callback, 4)
|
||||
self.fingerJoint(y-r-self.lock)
|
||||
self.fingerJoint(y-r-self.latchsize)
|
||||
self.corner(90)
|
||||
|
||||
def surroundingWall(self):
|
||||
x, y, z, r = self.x, self.y, self.z, self.r
|
||||
|
||||
c4 = math.pi * r * 0.5
|
||||
|
||||
lock = self.lock
|
||||
|
||||
self.fingerJoint(y-r, False)
|
||||
self.flex(c4, z+2*self.thickness)
|
||||
self.flex(self.c4, z+2*self.thickness)
|
||||
self.edge(x-2*r)
|
||||
self.flex(c4, z+2*self.thickness)
|
||||
self.fingerJoint(lock, False)
|
||||
self.corner(90)
|
||||
self.flex(self.c4, z+2*self.thickness)
|
||||
self.latch(self.latchsize, False)
|
||||
self.edge(z+2*self.thickness)
|
||||
self.corner(90)
|
||||
self.fingerJoint(lock, False)
|
||||
self.edge(c4)
|
||||
self.latch(self.latchsize, False, True)
|
||||
self.edge(self.c4)
|
||||
self.edge(x-2*r)
|
||||
self.edge(c4)
|
||||
self.edge(self.c4)
|
||||
self.fingerJoint(y-r, False)
|
||||
self.corner(90)
|
||||
self.edge(self.thickness)
|
||||
|
@ -63,11 +56,10 @@ class FlexBox(boxes.Boxes):
|
|||
self.corner(90)
|
||||
|
||||
def render(self):
|
||||
c4 = math.pi * self.r * 0.5
|
||||
self.moveTo(2*self.thickness, self.thickness)
|
||||
self.ctx.save()
|
||||
self.surroundingWall()
|
||||
self.moveTo(self.x+self.y-3*self.r+2*c4+self.lock+1*self.thickness, 0)
|
||||
self.moveTo(self.x+self.y-3*self.r+2*self.c4+self.latchsize+1*self.thickness, 0)
|
||||
self.rectangularWall(self.x, self.z, edges="FFFF")
|
||||
self.ctx.restore()
|
||||
self.moveTo(0, self.z+4*self.thickness)
|
||||
|
@ -77,7 +69,7 @@ class FlexBox(boxes.Boxes):
|
|||
self.flexBoxSide(self.x, self.y, self.r)
|
||||
self.ctx.scale(-1, 1)
|
||||
self.moveTo(2*self.thickness, 0)
|
||||
self.rectangularWall(self.z, self.y-self.r-self.lock, edges="fFeF")
|
||||
self.rectangularWall(self.z, self.y-self.r-self.latchsize, edges="fFeF")
|
||||
self.ctx.stroke()
|
||||
self.surface.flush()
|
||||
|
||||
|
|
Loading…
Reference in New Issue