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