2013-04-16 04:25:37 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
from boxes import Boxes
|
|
|
|
|
|
|
|
class Lamp(Boxes):
|
|
|
|
def __init__(self):
|
2013-05-14 17:54:47 +02:00
|
|
|
Boxes.__init__(self, width=1000, height=1000)
|
2013-04-16 04:25:37 +02:00
|
|
|
self.fingerJointSettings = (5, 5)
|
|
|
|
|
|
|
|
def ring(self, r, w):
|
|
|
|
self.ctx.save()
|
|
|
|
d = 2*(r+w)
|
|
|
|
self.roundedPlate(d, d, r)
|
|
|
|
|
|
|
|
self.moveTo(r+w, w)
|
|
|
|
self.corner(360, r)
|
|
|
|
self.ctx.restore()
|
|
|
|
|
2013-05-14 17:54:47 +02:00
|
|
|
def holder(self, l):
|
|
|
|
self.ctx.line_to(l/2.0,-l/2.0)
|
|
|
|
self.ctx.line_to(l, 0)
|
|
|
|
self.moveTo(l, 0)
|
2013-04-16 04:25:37 +02:00
|
|
|
|
2013-04-18 04:44:33 +02:00
|
|
|
def render(self, r, w, x, y, h):
|
2013-04-16 04:25:37 +02:00
|
|
|
"""
|
|
|
|
r : radius of lamp
|
|
|
|
w : width of surrounding ring
|
|
|
|
"""
|
|
|
|
d = 2*(r+w)
|
|
|
|
self.ctx.save()
|
|
|
|
self.moveTo(20, 20)
|
|
|
|
self.ring(r, w)
|
|
|
|
self.moveTo(2*(r+w)+20, 0)
|
2013-05-14 17:54:47 +02:00
|
|
|
self.roundedPlate(d, d, r, holesMargin=w/2.0)
|
2013-04-16 04:25:37 +02:00
|
|
|
|
|
|
|
self.ctx.restore()
|
|
|
|
self.moveTo(10, 2*(r+w)+40)
|
2013-04-16 17:02:43 +02:00
|
|
|
self.surroundingWall(d, d, r, 150, top='h', bottom='h')
|
2013-04-18 04:44:33 +02:00
|
|
|
self.moveTo(0, 150+20)
|
2013-04-16 04:25:37 +02:00
|
|
|
|
2013-05-14 17:54:47 +02:00
|
|
|
self.rectangularWall(x, y, edges="fFfF", holesMargin=5)
|
2013-04-18 04:44:33 +02:00
|
|
|
self.moveTo(x+20, 0)
|
2013-05-14 17:54:47 +02:00
|
|
|
self.rectangularWall(x, y, edges="fFfF", holesMargin=5)
|
|
|
|
self.moveTo(x+20, 0)
|
|
|
|
self.rectangularWall(y, h, edges="ffff", holesMargin=5)
|
|
|
|
|
|
|
|
self.moveTo(0, y+20)
|
|
|
|
self.rectangularWall(y, h, edges="ffff", holesMargin=5)
|
|
|
|
self.moveTo(-x-20, 0)
|
|
|
|
self.rectangularWall(x, h, edges=['h', 'F', (self.holder, 20), 'F'], holesMargin=5)
|
|
|
|
self.moveTo(-x-20, 0)
|
|
|
|
self.rectangularWall(x, h, edges='hFFF', holesMargin=5)
|
2013-04-16 04:25:37 +02:00
|
|
|
|
|
|
|
self.ctx.stroke()
|
|
|
|
self.surface.flush()
|
|
|
|
|
|
|
|
|
|
|
|
l = Lamp()
|
2013-04-18 04:44:33 +02:00
|
|
|
l.render(100, 20, 250, 140, 120)
|