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