update stamp logic
This commit is contained in:
parent
cc8fa6bf23
commit
49bdada671
1 changed files with 20 additions and 34 deletions
50
main.scad
50
main.scad
|
|
@ -1,16 +1,14 @@
|
||||||
/* [Main design variables] */
|
/* [Main design variables] */
|
||||||
variant = "stamp"; // ["stamp", "stencil"]
|
variant = "stamp"; // ["stamp", "stencil"]
|
||||||
// Set the width of the object. Height is calculated automatically.
|
|
||||||
width = 80; // [0:200]
|
|
||||||
// Set the text size to match the width.
|
// Set the text size to match the width.
|
||||||
textsize = 12; // [10:36]
|
textsize = 36; // [10:36]
|
||||||
font_set = 2; // [0:"linux", 1:"windows", 2:"custom", 3:"stencil"]
|
font_set = 4; // [0:"linux", 1:"windows", 2:"custom", 3:"stencil", 4:"manual"]
|
||||||
|
font_manual = "Ubuntu:style=Bold";
|
||||||
font_index = 0;
|
font_index = 0;
|
||||||
lines = ["line one", "line two"];
|
line = "lorem ipsum";
|
||||||
|
|
||||||
/* [common technical vars] */
|
/* [common technical vars] */
|
||||||
linespacing_custom = 0.8;
|
border = 3;
|
||||||
border = 0;
|
|
||||||
|
|
||||||
/* [stamp technical vars] */
|
/* [stamp technical vars] */
|
||||||
base_thickness_stamp = 1;
|
base_thickness_stamp = 1;
|
||||||
|
|
@ -36,7 +34,8 @@ fonts_custom = [
|
||||||
"Anonymous Pro Minus",
|
"Anonymous Pro Minus",
|
||||||
"Kings:style=Regular",
|
"Kings:style=Regular",
|
||||||
"CAT FrankenDeutsch:style=Regular",
|
"CAT FrankenDeutsch:style=Regular",
|
||||||
"Bounded:style=Medium"
|
"Bounded:style=Medium",
|
||||||
|
"LT Effervescent:style=Regular"
|
||||||
];
|
];
|
||||||
|
|
||||||
fonts_stencil = ["Depot:style=Regular",
|
fonts_stencil = ["Depot:style=Regular",
|
||||||
|
|
@ -50,10 +49,8 @@ fonts_stencil = ["Depot:style=Regular",
|
||||||
|
|
||||||
/* [hidden] */
|
/* [hidden] */
|
||||||
|
|
||||||
linespacing = textsize*1.6 * linespacing_custom;
|
fonts_manual = [font_manual];
|
||||||
height = (len(lines) * linespacing) + border*2;
|
font_sets = [fonts_linux, fonts_windows, fonts_custom, fonts_stencil, fonts_manual];
|
||||||
|
|
||||||
font_sets = [fonts_linux, fonts_windows, fonts_custom, fonts_stencil];
|
|
||||||
font = font_sets[font_set][font_index];
|
font = font_sets[font_set][font_index];
|
||||||
|
|
||||||
if (font == undef)
|
if (font == undef)
|
||||||
|
|
@ -62,20 +59,11 @@ if (font == undef)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (version()[0] != 2021 || version()[1] != 1)
|
tm = textmetrics(line, size=textsize, font=font);
|
||||||
{
|
|
||||||
echo();
|
|
||||||
echo();
|
|
||||||
echo();
|
|
||||||
echo("WARNING!");
|
|
||||||
echo("Version is not 2021.01");
|
|
||||||
echo("Edit model text in the code editor");
|
|
||||||
echo("pending changes in the customizer may be overwritten");
|
|
||||||
echo();
|
|
||||||
echo();
|
|
||||||
echo();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
width = tm.size[0];
|
||||||
|
height = tm.size[1];
|
||||||
|
base_position = tm.position;
|
||||||
|
|
||||||
// All variables are set, make main
|
// All variables are set, make main
|
||||||
main();
|
main();
|
||||||
|
|
@ -119,16 +107,14 @@ module stamp()
|
||||||
{
|
{
|
||||||
union()
|
union()
|
||||||
{
|
{
|
||||||
stamp_base(x = width, y = height, z = base_thickness_stamp, rounding = base_rounding_stamp);
|
translate(base_position)
|
||||||
|
translate([-border,-border,0])
|
||||||
|
stamp_base(x = width+2*border, y = height+2*border, z = base_thickness_stamp, rounding = base_rounding_stamp);
|
||||||
|
|
||||||
for (i = [0 : 1 : len(lines)])
|
|
||||||
{
|
|
||||||
line = lines[(len(lines)-1)-i];
|
|
||||||
translate(v = [width/2, linespacing/2 +border + i*linespacing, 0])
|
|
||||||
color("white")
|
color("white")
|
||||||
linear_extrude(height = base_thickness_stamp+stamp_depth)
|
linear_extrude(height = base_thickness_stamp+stamp_depth)
|
||||||
text(line, font = font, halign="center", valign="center", size=textsize);
|
text(line, font = font, size=textsize);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue