chiark / gitweb /
71a3bd60359b20b86aa9115e0be1a1c8bc11cf43
[reprap-play.git] / quacks-ingredients.scad
1 // -*- C -*-
2
3 token_dia = 18;
4 spot_dia = 4;
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
14 $nspots = 3;
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     echo(condition, $spots_absent, "Y");
39     translate(xy * (spot_gap + spot_dia) * sqrt(0.5))
40       circle(r= spot_dia/2);
41   } else {
42     echo(condition, $spots_absent, "N");
43   }
44 }
45
46 module Token_Spots(){
47   SpotAt(($nspots % 2) > 0,  [0,0]);
48   SpotAt($nspots >= 2, [ 1, 1]);
49   SpotAt($nspots >= 2, [-1,-1]);
50   SpotAt($nspots >= 4, [ 1,-1]);
51   SpotAt($nspots >= 4, [-1, 1]);
52 }
53
54 module Token_Spots_All(){
55   $nspots = 5;
56   Token_Spots();
57 }
58
59 module Token_L1(){
60   Spots_Extrude_Lower()
61     Token_Spots();
62 }
63
64 module Token_L2(){
65   $spots_absent = true;
66   Spots_Extrude_Lower()
67     Token_Spots();
68 }
69
70 module Token_L3(){
71   $spots_plusgap = true;
72   difference(){
73     linear_extrude(height=thick)
74       circle(r=token_dia/2);
75     Spots_Extrude_Lower() Token_Spots_All();
76     Spots_Extrude_Upper() Token_Spots_All();
77   }
78 }
79
80 module Token_L4(){
81   $spots_absent = true;
82   Spots_Extrude_Upper()
83     Token_Spots();
84 }
85
86 module Token_L5(){
87   Spots_Extrude_Upper()
88     Token_Spots();
89 }
90
91 module Demo(){
92   color("red") { Token_L3(); }
93   color("white") { Token_L1(); Token_L5(); }
94   color("black") { Token_L2(); Token_L4(); }
95 }
96
97 Demo();