Download or view birdhouse.frink in plain text format
// This makes a birdhouse from a Little Golden Book like The Poky Little Puppy.
// The only major variable is the angle of the roof theta.
maxw = 15.5 cm
maxh = 20.15 cm
theta = 30 deg
wf = maxw
we = wf/2
hr = we tan[theta]
h0 = maxh - hr
hpeak = maxh
l = hr / sin[theta]
println["l is " + format[l, "cm", 2]]
g = new graphics
g.stroke[.5 mm]
// Draw front/back of house
p = new polygon
p.addPoint[-wf/2, 0 cm]
p.addPoint[wf/2, 0 cm]
p.addPoint[wf/2, -h0]
p.addPoint[0 cm, -hpeak]
p.addPoint[-wf/2, -h0]
println["Side height is " + format[h0, "cm", 2]]
g.add[p]
g.drawEllipseCenter[0 cm, -6.8 cm, 1.5 in, 1.5 in]
// Draw book cover
lroof = maxw
wr = lroof cos[theta]
hr = hpeak - lroof sin[theta]
// Draw wood roof
lwoodroof = maxw - 1 cm
wr1 = lwoodroof cos[theta]
hr1 = hpeak - lwoodroof sin[theta]
g.color[0,0,0,.5]
thickness = 6 mm
g.stroke[thickness]
voffset = thickness cos[theta]
//g.line[0 cm, -hpeak - 1/2 voffset, wr1, -hr1 - 1/2 voffset ]
//g.line[0 cm, -hpeak - 1/2 voffset, -wr1, -hr1 - 1/2 voffset]
g.stroke[1 mm]
g.color[0,0,0]
//g.line[0 cm, -hpeak - voffset, wr, -hr - voffset]
//g.line[0 cm, -hpeak - voffset , -wr, -hr - voffset]
g.show[]
// Draw side
depth = maxw
g2 = new graphics
g2.stroke[.5 mm]
g2.drawRectSides[-depth/2 + thickness, -h0, depth/2 - thickness, 0 cm]
g2.font["SansSerif", 1 cm]
g2.text["side", 0 cm, -h0/2]
g2.show[]
// Draw roof
dwoodroof = maxh - 2 cm
g3 = new graphics
g3.stroke[.5 mm]
g3.drawRectSides[-dwoodroof / 2, lwoodroof, dwoodroof / 2, 0 cm]
g3.font["SansSerif", 1 cm]
g3.text["roof", 0 cm, lwoodroof / 2]
g3.show[]
// Draw floor
g4 = new graphics
g4.stroke[.5 mm]
wfloor = maxw + 4 cm
g4.drawRectCenter[0 cm, 0 cm, wfloor, wfloor]
g4.font["SansSerif", 1 cm]
g4.text["floor", 0 cm, 0 cm]
g4.show[]
// Draw felt under floor
wfelt = wfloor - 1 cm
g6 = new graphics
g6.drawRectCenter[0 cm, 0 cm, wfelt, wfelt]
g6.stroke[.5 mm]
g6.font["SansSerif", 1 cm]
g6.text["felt", 0 cm, 0 cm]
g6.show[]
// Draw supports
g5 = new graphics
g5.stroke[.5 mm]
ps = new polygon
// Width of support
ws = 13 mm
wout = we - thickness
dout = wout tan[theta]
hout = hpeak - dout
win = wout - ws
din = win tan[theta]
hin = hpeak - din
ps.addPoint[0 cm, 0 cm]
ps.addPoint[ws, 0 cm]
ps.addPoint[ws, -hout]
ps.addPoint[0 cm, -hin]
g5.add[ps]
g5.show[]
Download or view birdhouse.frink in plain text format
This is a program written in the programming language Frink.
For more information, view the Frink
Documentation or see More Sample Frink Programs.
Alan Eliasen was born 20217 days, 23 hours, 27 minutes ago.