poker-chips/chip.scad

69 lines
1.8 KiB
OpenSCAD
Raw Permalink Normal View History

// Diameter of the coin (mm)
diameter = 39;
// Height of the coin (mm)
height = 3.5;
// Engraving depth (mm)
2022-08-30 16:29:36 -06:00
depth = 0.4;
// Number of sides on your coin
sides = 360; // [3:360]
2022-08-30 11:44:50 -06:00
// How many spokes do you want?
spokes = 6; // [0:12]
2022-08-30 10:14:50 -06:00
// Text to display
2022-08-30 10:14:50 -06:00
text = "100";
// The font must be installed locally on your system
font = "Droid Sans:style=Bold";
fontScale = (
sides == 3 ? 0.50
: sides == 4 ? 0.80
: sides == 5 ? 0.80
: sides == 6 ? 0.90
: 1.00
);
// Enough width to fit four digits
fontSize = diameter * 0.21 * fontScale;
// Rotate odd-numbers of sides to maximize width
rotation = (sides%2)?90:0;
module chip() {
intersection() {
cylinder(h=height, d=diameter, center=true, $fn=sides);
union() {
difference() {
cube([diameter, diameter, height], center=true);
difference() {
2022-08-30 10:14:50 -06:00
cylinder(h=height, d=diameter*0.8, center=true, $fn=sides);
cylinder(h=height, d=diameter*0.7, center=true, $fn=sides);
}
}
2022-08-30 10:14:50 -06:00
2022-08-30 16:29:36 -06:00
spokeHeight = height - (2*depth);
2022-08-30 11:44:50 -06:00
if (spokes == 0) {
2022-08-30 16:29:36 -06:00
cube([diameter, diameter, spokeHeight], center=true);
2022-08-30 10:14:50 -06:00
} else {
2022-08-30 11:44:50 -06:00
spokeWidth = (diameter/spokes) * 0.8;
rotate((sides+spokes)%2?90:0) {
for (i = [0 : 360/spokes : 360]) {
2022-08-30 16:29:36 -06:00
rotate(i) translate([diameter/2, 0, 0]) cube([diameter, spokeWidth, spokeHeight], center=true);
2022-08-30 10:14:50 -06:00
}
}
}
}
}
}
difference() {
rotate(rotation) chip();
translate([0, 0, height/2-depth])
linear_extrude(height=depth+0.1, convexity = 10, twist = 0)
2022-08-30 10:14:50 -06:00
text(text=text, font=font, size=fontSize, halign="center", valign="center");
}