Make side able to hole the lamp
This commit is contained in:
parent
35347edeb4
commit
1a6380fd67
32
lamp.py
32
lamp.py
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
from boxes import Boxes
|
from boxes import Boxes
|
||||||
|
import math
|
||||||
|
|
||||||
class Lamp(Boxes):
|
class Lamp(Boxes):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -16,10 +17,24 @@ class Lamp(Boxes):
|
||||||
self.corner(360, r)
|
self.corner(360, r)
|
||||||
self.ctx.restore()
|
self.ctx.restore()
|
||||||
|
|
||||||
def holder(self, l):
|
def roundedTriangle(self, length, angle, r=0.0):
|
||||||
self.ctx.line_to(l/2.0,-l/2.0)
|
x = 0.5*(length-2*r)*math.tan(math.radians(angle))
|
||||||
self.ctx.line_to(l, 0)
|
y = 0.5*(length)
|
||||||
self.moveTo(l, 0)
|
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):
|
def render(self, r, w, x, y, h):
|
||||||
"""
|
"""
|
||||||
|
@ -42,12 +57,13 @@ class Lamp(Boxes):
|
||||||
self.moveTo(x+20, 0)
|
self.moveTo(x+20, 0)
|
||||||
self.rectangularWall(x, y, edges="fFfF", holesMargin=5)
|
self.rectangularWall(x, y, edges="fFfF", holesMargin=5)
|
||||||
self.moveTo(x+20, 0)
|
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.moveTo(0, y+20)
|
||||||
self.rectangularWall(y, h, edges="ffff", holesMargin=5)
|
self.moveTo(-x-y-40, 0)
|
||||||
self.moveTo(-x-20, 0)
|
self.rectangularWall(x, h, edges='hFFF', holesMargin=5)
|
||||||
self.rectangularWall(x, h, edges=['h', 'F', (self.holder, 20), 'F'], holesMargin=5)
|
|
||||||
self.moveTo(-x-20, 0)
|
self.moveTo(-x-20, 0)
|
||||||
self.rectangularWall(x, h, edges='hFFF', holesMargin=5)
|
self.rectangularWall(x, h, edges='hFFF', holesMargin=5)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue