poker-chips/chip.scad

54 lines
1.3 KiB
OpenSCAD
Raw Normal View History

// Diameter of the coin (mm)
diameter = 22;
// Height of the coin (mm)
height = 2;
// Engraving depth (mm)
depth = 0.5;
// Number of sides on your coin
sides = 6; // [3:360]
// Text to display
TEXT = "100";
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() {
cylinder(h=height, d=diameter*0.8-0.0, center=true, $fn=sides);
cylinder(h=height, d=diameter*0.8-2, center=true, $fn=sides);
}
}
for (i = [0 : 30 : 360]) {
rotate(i) cube([diameter*0.8, diameter/8, height*0.7], center=true);
}
}
}
}
difference() {
rotate(rotation) chip();
translate([0, 0, height/2-depth])
linear_extrude(height=depth+0.1, convexity = 10, twist = 0)
text(text=TEXT, font="Droid Sans:style=Bold", size=fontSize, halign="center", valign="center");
}