chiark / gitweb /
quacks-ingredients: Base vs Witches vs All, revised runes
[reprap-play.git] / quacks-ingredients.scad
1 // -*- C -*-
2
3 //
4 // git clean -xdff
5 // ./quacks-ingredients-update-levels
6 // make autoincs
7 //
8 // make -j8 quacks-stls 2>&1 | tee log
9 // OR EG
10 // make -j8 quacks-ingredients-L{1,2,3,4,5},Base_Yellow.auto.stl
11 //
12 // ./quacks-ingredients-make-copy-gcodes Base_Yellow   etc.
13
14 token_dia = 20;
15 spot_dia = 4.3;
16 spot_gap = spot_dia / 3.0;
17
18 thick = 3.0;
19
20 multicolour_gap = 0.075; // each side
21 initial_layer_thick = 0.400;
22 initial_layer_width = 0.750;
23 final_layer_thick = 0.500;
24 multicolour_post = 4;
25
26 $fs=0.1;
27 $fa=1;
28
29 // calculated
30
31 token_pitch = token_dia + 3;
32
33 // autoadjusted
34
35 $spots_absent = false;
36 $spots_plusgap = false;
37
38 module Spots_Extrude_Lower(){
39   d = $spots_plusgap ? 1 : 0;
40   translate([0,0,-d])
41     linear_extrude(height= initial_layer_thick + d)
42     children(0);
43 }
44
45 module Spots_Extrude_Upper(){
46   d = $spots_plusgap ? 1 : 0;
47   translate([0,0, thick + d])
48     mirror([0,0, 1])
49     linear_extrude(height= final_layer_thick + d)
50     children(0);
51 }
52
53 module SpotAt(condition, xy) {
54   if (condition == !$spots_absent) {
55     translate(xy * (spot_gap + spot_dia) * sqrt(0.5))
56       circle(r= spot_dia/2 +
57              ($spots_plusgap ? multicolour_gap : 0));
58   }
59 }
60
61 module Token_Spots(){
62   SpotAt(($nspots % 2) > 0,  [0,0]);
63   SpotAt($nspots >= 2, [ 1, 1]);
64   SpotAt($nspots >= 2, [-1,-1]);
65   SpotAt($nspots >= 4, [ 1,-1]);
66   SpotAt($nspots >= 4, [-1, 1]);
67 }
68
69 module Token_Spots_All(){
70   $nspots = 5;
71   Token_Spots();
72 }
73
74 module Token_L1(){
75   Spots_Extrude_Lower()
76     Token_Spots();
77 }
78
79 module Token_L2(){
80   $spots_absent = true;
81   Spots_Extrude_Lower()
82     Token_Spots();
83 }
84
85 module Token_L3(){
86   $spots_plusgap = true;
87   difference(){
88     linear_extrude(height=thick)
89       circle(r=token_dia/2);
90     Spots_Extrude_Lower() Token_Spots_All();
91     Spots_Extrude_Upper() Token_Spots_All();
92   }
93 }
94
95 module Token_L4(){
96   $spots_absent = true;
97   Spots_Extrude_Upper()
98     Token_Spots();
99 }
100
101 module Token_L5(){
102   Spots_Extrude_Upper()
103     Token_Spots();
104 }
105
106 module Frame(phase, base_sz) {
107   zs = [ initial_layer_thick,
108          initial_layer_thick,
109          thick,
110          thick,
111          thick ];
112
113   sz = base_sz + phase * initial_layer_width * 2 * [1,1];
114   linear_extrude(height= initial_layer_thick) {
115     difference(){
116       square(center=true, sz + initial_layer_width * 2 * [1,1]);
117       square(center=true, sz);
118     }
119   }
120   // Priming tower
121   translate([-base_sz[0]/2, (2.8-phase)*(multicolour_post*1.7)])
122     linear_extrude(height= zs[phase-1])
123     square(multicolour_post);
124 }
125
126 module Tests(){
127   for ($nspots = [1,2,3,4]) {
128     translate(($nspots - 2) * token_pitch * [1,0])
129       children();
130   }
131 }
132
133 module Tests_L() { ////toplevel
134   Frame($phase, token_dia * [ 6, 1.5 ]);
135   Tests() Token_L();
136 }
137
138 //// toplevels-from:
139 include <quacks-ingredients-counts.scad>
140
141 //Demo();