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