4 |
4 |
5 # pfad zu den TTF files (arial.ttf) |
5 # pfad zu den TTF files (arial.ttf) |
6 FONTBASE = "/usr/share/fonts/truetype/msttcorefonts/" |
6 FONTBASE = "/usr/share/fonts/truetype/msttcorefonts/" |
7 |
7 |
8 SPACE_MIN = 10 # minimum offset between bottles |
8 SPACE_MIN = 10 # minimum offset between bottles |
|
9 |
|
10 SCADSCRIPT = "include <cylindertransport.scad>\n" |
9 |
11 |
10 # Durchmesser, Laenge, Volumen und Gewicht der verfuegbaren Tauchflaschen |
12 # Durchmesser, Laenge, Volumen und Gewicht der verfuegbaren Tauchflaschen |
11 CYLINDER = { |
13 CYLINDER = { |
12 "03" : [100, 515, 3, 4.7], |
14 "03" : [100, 515, 3, 4.7], |
13 "05" : [140, 466, 5, 5.7], |
15 "05" : [140, 466, 5, 5.7], |
76 r1 = CYLINDER[bottles[0]][0] / 2 |
77 r1 = CYLINDER[bottles[0]][0] / 2 |
77 r2 = CYLINDER[bottles[1]][0] / 2 |
78 r2 = CYLINDER[bottles[1]][0] / 2 |
78 x = 20 + r1 # start offset x |
79 x = 20 + r1 # start offset x |
79 r1, r2, r3, dn = calc_min(r1, r2) |
80 r1, r2, r3, dn = calc_min(r1, r2) |
80 circ(draw, x, r2, dn, 0.5) |
81 circ(draw, x, r2, dn, 0.5) |
|
82 SCADSCRIPT = SCADSCRIPT + "spacer(%i, %i, %i, %i);\n" % ( |
|
83 x, r2, r3, CYLINDER[bottles[0]][1]) |
81 x = x + offset(r2, r3) |
84 x = x + offset(r2, r3) |
82 |
85 |
83 for i in range(0, len(bottles)-1): |
86 for i in range(0, len(bottles)-1): |
84 r1 = CYLINDER[bottles[i]][0] / 2 |
87 r1 = CYLINDER[bottles[i]][0] / 2 |
85 r2 = CYLINDER[bottles[i+1]][0] / 2 |
88 r2 = CYLINDER[bottles[i+1]][0] / 2 |
86 r1, r2, r3, dn = calc_min(r1, r2) |
89 r1, r2, r3, dn = calc_min(r1, r2) |
87 # draw bottle |
90 # draw bottle |
88 circ(draw, x, r1, "Tank "+bottles[i]) |
91 circ(draw, x, r1, "Tank "+bottles[i]) |
|
92 SCADSCRIPT = SCADSCRIPT + "tank(%i, %i, %i);\n" % ( |
|
93 x, r1, CYLINDER[bottles[i]][1]) |
89 sx1 = x+r1 |
94 sx1 = x+r1 |
90 x = x + offset(r1, r2) |
95 x = x + offset(r1, r2) |
91 # draw right spacer |
96 # draw right spacer |
92 circ(draw, x, r2, dn, 0.5) |
97 circ(draw, x, r2, dn, 0.5) |
|
98 SCADSCRIPT = SCADSCRIPT + "spacer(%i, %i, %i, %i);\n" % ( |
|
99 x, r2, r1, CYLINDER[bottles[i]][1]) |
93 x = x + offset(r2, r3) |
100 x = x + offset(r2, r3) |
94 sx2 = x-r3 |
101 sx2 = x-r3 |
95 if i == (len(bottles)-2): |
102 if i == (len(bottles)-2): |
96 # draw last bottle |
103 # draw last bottle |
97 circ(draw, x, r3, "Tank "+bottles[i+1]) |
104 circ(draw, x, r3, "Tank "+bottles[i+1]) |
|
105 SCADSCRIPT = SCADSCRIPT + "tank(%i, %i, %i);\n" % ( |
|
106 x, r3, CYLINDER[bottles[i+1]][1]) |
98 x = x + offset(r2, r3) |
107 x = x + offset(r2, r3) |
99 # draw the space between bottles |
108 # draw the space between bottles |
100 draw.line((sx1, spacerY1, sx1, spacerY2), fill='#ffffff') |
109 draw.line((sx1, spacerY1, sx1, spacerY2), fill='#ffffff') |
101 draw.line((sx2, spacerY1, sx2, spacerY2), fill='#ffffff') |
110 draw.line((sx2, spacerY1, sx2, spacerY2), fill='#ffffff') |
102 txt = "%imm" % (sx2-sx1) |
111 txt = "%imm" % (sx2-sx1) |
104 tox, toy = draw.textsize(txt, font=font) |
113 tox, toy = draw.textsize(txt, font=font) |
105 draw.text((sx1+(sx2-sx1)/2-(tox/2), spacerY2+toy/2), txt, font=font, fill='#ffffff') |
114 draw.text((sx1+(sx2-sx1)/2-(tox/2), spacerY2+toy/2), txt, font=font, fill='#ffffff') |
106 |
115 |
107 # last bottle spacer |
116 # last bottle spacer |
108 circ(draw, x, r2, dn, 0.5) |
117 circ(draw, x, r2, dn, 0.5) |
|
118 SCADSCRIPT = SCADSCRIPT + "spacer(%i, %i, %i, %i);\n" % ( |
|
119 x, r2, r3, CYLINDER[bottles[i+1]][1]) |
109 |
120 |
110 def getimage(args): |
121 def getimage(args): |
111 image = Image.new('1', (1000, 250)) #create new image, 1000x500 pixels, 1 bit per pixel |
122 image = Image.new('1', (1000, 250)) #create new image, 1000x500 pixels, 1 bit per pixel |
112 draw = ImageDraw.Draw(image) |
123 draw = ImageDraw.Draw(image) |
113 draw_bottles(draw, args) |
124 draw_bottles(draw, args) |