Make side able to hole the lamp

This commit is contained in:
Florian Festi 2013-06-07 12:51:04 +02:00
parent 35347edeb4
commit 1a6380fd67
1 changed files with 24 additions and 8 deletions

32
lamp.py
View File

@ -1,6 +1,7 @@
#!/usr/bin/python
from boxes import Boxes
import math
class Lamp(Boxes):
def __init__(self):
@ -16,10 +17,24 @@ class Lamp(Boxes):
self.corner(360, r)
self.ctx.restore()
def holder(self, l):
self.ctx.line_to(l/2.0,-l/2.0)
self.ctx.line_to(l, 0)
self.moveTo(l, 0)
def roundedTriangle(self, length, angle, r=0.0):
x = 0.5*(length-2*r)*math.tan(math.radians(angle))
y = 0.5*(length)
self.hole(x, y, 2)
l = 0.5 * (length-2*r) / math.cos(math.radians(angle))
self.corner(90-angle, r)
self.edge(l)
self.corner(2*angle, r)
self.edge(l)
self.corner(90-angle, r)
def side(self, y, h):
self.fingerJoint(y)
self.corner(90)
self.fingerJoint(h)
self.roundedTriangle(y, 70, 25)
self.fingerJoint(h)
self.corner(90)
def render(self, r, w, x, y, h):
"""
@ -42,12 +57,13 @@ class Lamp(Boxes):
self.moveTo(x+20, 0)
self.rectangularWall(x, y, edges="fFfF", holesMargin=5)
self.moveTo(x+20, 0)
self.rectangularWall(y, h, edges="ffff", holesMargin=5)
self.side(y, h)
self.moveTo(y+20, 0)
self.side(y, h)
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-y-40, 0)
self.rectangularWall(x, h, edges='hFFF', holesMargin=5)
self.moveTo(-x-20, 0)
self.rectangularWall(x, h, edges='hFFF', holesMargin=5)