From 1a6380fd67efa2d10472f0fc7fc764ea89631c85 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Fri, 7 Jun 2013 12:51:04 +0200 Subject: [PATCH] Make side able to hole the lamp --- lamp.py | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/lamp.py b/lamp.py index fc50ab0..5a19e93 100755 --- a/lamp.py +++ b/lamp.py @@ -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)