-
Notifications
You must be signed in to change notification settings - Fork 3
/
a good version of the logo.scad
213 lines (171 loc) · 5.1 KB
/
a good version of the logo.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
// SPDX-License-Identifier: GPL-3.0-or-later
// Well, openscad fucks up its svg export, so you need _something_ in the frame
circle(r = 0.0001);
// === Nix logo specification
// number of lambdas. doesn't really work if changed in this model.
num = 6;
res = (cos(($t * 360)) + 1) / 2;
// Central aperture diameter, in units. It does produce nice effects if animated.
aperture = 2 + -2 * res;
// lambda height in units. fun to play with
length = 4 + -4 * res;
// Clipping polygon diameter, in units
clipr = 8 + -8 * res;
// === Some calculated core stuff
// lambda thickness, also a segment size. Should affects nothing except size.
unit = 25;
// The angle™
th = 360 / num / 2;
// Unit value of Y when mapped to coordinate space with angle between axes of "th"
tunit = tan(th)*unit;
// === Rendering props
// Shrinkage for each of lambdas. Basically control inverse "font weight"
gaps = 1;
// colors to use
colors = ["#5277c3", "#7caedc"];
// inverse clipping order
invclip = false;
show_hexgrid = false;
show_full = true;
printed_version = "none"; // ["none", "one piece", "module"]
printed_h = 30;
circle_r = 43;
circle_t = 6;
circle_h = 6;
pin_l = 4*tunit;
pin_r = 3;
// Pin/hole size ratio, to account for plastic heat deformation
hole_ratio = 1.07;
// copied from <MCAD/regular_shapes.scad> so customizer will work on thingiverse
module regular_polygon(sides, radius)
{
function dia(r) = sqrt(pow(r*2,2)/2); //sqrt((r*2^2)/2) if only we had an exponention op
angles=[ for (i = [0:sides-1]) i*(360/sides) ];
coords=[ for (th=angles) [radius*cos(th), radius*sin(th)] ];
polygon(coords);
}
module hexgrid(thickness=1.5) union() {
// Yes you can go lower for hexagonal grids.
for (i=[0:num-1]) {
rotate(i*th*2+th)
for (i=[-clipr:clipr]) {
translate([i*unit/2,0])
square([thickness, clipr * unit * 2],center=true);
};
};
}
// draw a ~perfect~ 2D lambda
module lambda() {
intersection(){
union() {
// Lambda arm
rotate(-th)
translate([0,-tunit*length])
square([unit,length*tunit*2], center=true);
// Lambda bar
rotate(th)
square([unit,tunit*(length*2 + 1)], center=true);
}
// Cutting top and bottom of squares to be left with a perfect lambda
// Lambda *almost* scales uniformly.
// We just need to account for corner triangles, making it + 2 wider.
square([tunit*(length + 2), unit*length], center=true);
}
}
// Subtracts a rotated child from itself
module diff(nextangle, debug=false) {
difference() {
children();
rotate(invclip ? nextangle : -nextangle) children();
}
}
module clipper(){
// that's not as easy to autotune as it would seem
intersection() {
regular_polygon(num, clipr * tunit);
children();
}
}
module move_to_lambda_origin(index) {
}
module placed_lambda() {
offset(delta = -gaps)
clipper()
// cutting it up with the same lambda at the next place
diff(360/num)
// translation to endpoint
translate([tunit * -aperture, unit * -aperture])
// initial in-place rotation
lambda();
}
module render_logo(segments=[0:num-1]) {
for (r=segments)
// color it with next color in array
color(colors[r % len(colors)])
rotate(th*2*r)
placed_lambda();
}
module make_pin(scl = 1, r = pin_r) {
// Only rescale crossection, so length doesn't change
scale([1,scl,scl])
translate([tunit * -aperture, unit * -aperture])
rotate(th)
// extrude pin from the center to the side of a limbda
translate([0,pin_l/2,0])
rotate([90,45])
cube([r * 2, r * 2, pin_l], center=true);
//cylinder(50, r, r, center=true);
}
module render_module() {
render()
difference() {
union() {
make_pin(1);
linear_extrude(printed_h, center=true)
clipper()
placed_lambda();
}
// ensuring that hole is slightly larger
rotate((invclip ? -1 : 1) * 360/num) make_pin(hole_ratio);
// usually not needed, but you
// can actually thread stuff thru two next lambdas
rotate((invclip ? -2 : 2) * 360/num) make_pin(hole_ratio);
}
}
// Actual rendering
if (printed_version == "none") {
difference() {
render_logo();
if (show_hexgrid)
hexgrid();
};
}
if (printed_version == "module") {
difference() {
render_module();
if (show_hexgrid)
translate([0,0,printed_h/2-1])
linear_extrude(2)
hexgrid();
}
if (show_full)
translate([0,0, printed_h / -2])
color("#ff000033")
render_logo();
}
if (printed_version == "one piece")
union() {
linear_extrude(circle_h, center=true)
difference() {
circle(circle_r);
circle(circle_r - circle_t);
}
difference() {
linear_extrude(printed_h, center=true)
render_logo();
if (show_hexgrid)
translate([0,0,printed_h/2-1])
linear_extrude(1)
hexgrid();
}
};