2013-04-16 05:07:26 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
from boxes import Boxes
|
|
|
|
|
|
|
|
class Silverware(Boxes):
|
|
|
|
####################################################################
|
|
|
|
### Parts
|
|
|
|
####################################################################
|
|
|
|
|
2013-04-16 05:22:20 +02:00
|
|
|
def basePlate(self, x, y, r):
|
|
|
|
self.roundedPlate(x, y, r, callback=[
|
|
|
|
lambda: self.fingerHolesAt(x/3.0-r, 0, 0.5*y-self.thickness),
|
|
|
|
lambda: self.fingerHolesAt(x/6.0, 0, 0.5*y-self.thickness),
|
|
|
|
lambda: self.fingerHolesAt(y/2.0-r, 0, x),
|
|
|
|
lambda: self.fingerHolesAt(x/2.0-r, 0, 0.5*y-self.thickness)
|
|
|
|
])
|
2013-04-16 05:07:26 +02:00
|
|
|
|
|
|
|
def wall(self, x=100, y=100, h=100, r=0):
|
2013-04-16 11:32:13 +02:00
|
|
|
self.surroundingWall(x,y,r,h, bottom='h', callback={
|
2013-06-29 13:57:56 +02:00
|
|
|
0 : lambda: self.fingerHolesAt(x/6.0, 0, h-10),
|
|
|
|
4 : lambda: self.fingerHolesAt(x/3.0-r, 0, h-10),
|
|
|
|
1 : lambda: self.fingerHolesAt(y/2.0-r, 0, h-10),
|
|
|
|
3 : lambda: self.fingerHolesAt(y/2.0-r, 0, h-10),
|
|
|
|
2 : lambda: self.fingerHolesAt(x/2.0-r, 0, h-10),
|
2013-07-20 10:49:45 +02:00
|
|
|
},
|
|
|
|
move="up")
|
2013-04-16 05:07:26 +02:00
|
|
|
|
|
|
|
def centerWall(self, x, h):
|
|
|
|
self.ctx.save()
|
|
|
|
|
2013-07-20 10:49:45 +02:00
|
|
|
self.moveTo(self.fingerJointEdge.spacing(), self.fingerJointEdge.spacing())
|
2013-04-16 05:07:26 +02:00
|
|
|
for i in range(2, 5):
|
2013-06-29 13:57:56 +02:00
|
|
|
self.fingerHolesAt(i*x/6.0, 0, h-10)
|
2013-04-16 05:07:26 +02:00
|
|
|
|
2013-07-20 10:49:45 +02:00
|
|
|
self.fingerJointEdge(x)
|
2013-04-16 05:07:26 +02:00
|
|
|
self.corner(90)
|
2013-07-20 10:49:45 +02:00
|
|
|
self.fingerJointEdge(h-10)
|
2013-04-16 05:07:26 +02:00
|
|
|
self.corner(90)
|
|
|
|
|
|
|
|
self.handle(x, 150, 120)
|
2013-06-29 13:57:56 +02:00
|
|
|
#self.handle(x, 40, 30, r=2)
|
2013-04-16 05:07:26 +02:00
|
|
|
|
|
|
|
self.corner(90)
|
2013-07-20 10:49:45 +02:00
|
|
|
self.fingerJointEdge(h-10)
|
2013-04-16 05:07:26 +02:00
|
|
|
self.corner(90)
|
|
|
|
self.ctx.restore()
|
|
|
|
|
2013-07-20 10:49:45 +02:00
|
|
|
self.moveTo(x+2*self.fingerJointEdge.spacing())
|
|
|
|
|
2013-04-16 05:07:26 +02:00
|
|
|
##################################################
|
|
|
|
### main
|
|
|
|
##################################################
|
|
|
|
|
|
|
|
def render(self, x, y, h, r):
|
2013-06-29 13:57:56 +02:00
|
|
|
t = self.thickness
|
|
|
|
b = self.burn
|
2013-04-16 05:07:26 +02:00
|
|
|
self.ctx.save()
|
|
|
|
|
2013-06-29 13:57:56 +02:00
|
|
|
self.wall(x, y, h, r)
|
2013-07-20 10:49:45 +02:00
|
|
|
self.centerWall(x,h)
|
2013-04-16 05:07:26 +02:00
|
|
|
|
2013-06-29 13:57:56 +02:00
|
|
|
l = (y-t)/2.0
|
2013-04-16 05:07:26 +02:00
|
|
|
for i in range(3):
|
2013-07-20 10:49:45 +02:00
|
|
|
self.rectangularWall(l, h-10, edges="ffef", move="right")
|
2013-04-16 05:07:26 +02:00
|
|
|
|
2013-07-20 10:49:45 +02:00
|
|
|
self.moveTo(-3.0*(l+2*t+8*b), h-10+2*t+8*b)
|
2013-04-16 05:07:26 +02:00
|
|
|
self.basePlate(x, y, r)
|
|
|
|
|
|
|
|
self.ctx.restore()
|
|
|
|
|
|
|
|
self.ctx.stroke()
|
2013-07-20 10:49:45 +02:00
|
|
|
self.surface.finish()
|
2013-04-16 05:07:26 +02:00
|
|
|
|
2013-06-29 13:57:56 +02:00
|
|
|
b = Silverware(900, 700, thickness=5.0, burn=0.05)
|
2013-04-16 05:07:26 +02:00
|
|
|
b.render(250, 250/1.618, 120, 30)
|
2013-06-29 13:57:56 +02:00
|
|
|
#b = Silverware(300, 300, thickness=3.0, burn=0.05)
|
|
|
|
#b.fingerJointSettings = (b.thickness, b.thickness)
|
|
|
|
#b.render(60, 60/1.618, 40, 10)
|