update stamp logic
This commit is contained in:
parent
cc8fa6bf23
commit
49bdada671
1 changed files with 20 additions and 34 deletions
54
main.scad
54
main.scad
|
|
@ -1,16 +1,14 @@
|
|||
/* [Main design variables] */
|
||||
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.
|
||||
textsize = 12; // [10:36]
|
||||
font_set = 2; // [0:"linux", 1:"windows", 2:"custom", 3:"stencil"]
|
||||
textsize = 36; // [10:36]
|
||||
font_set = 4; // [0:"linux", 1:"windows", 2:"custom", 3:"stencil", 4:"manual"]
|
||||
font_manual = "Ubuntu:style=Bold";
|
||||
font_index = 0;
|
||||
lines = ["line one", "line two"];
|
||||
line = "lorem ipsum";
|
||||
|
||||
/* [common technical vars] */
|
||||
linespacing_custom = 0.8;
|
||||
border = 0;
|
||||
border = 3;
|
||||
|
||||
/* [stamp technical vars] */
|
||||
base_thickness_stamp = 1;
|
||||
|
|
@ -36,7 +34,8 @@ fonts_custom = [
|
|||
"Anonymous Pro Minus",
|
||||
"Kings:style=Regular",
|
||||
"CAT FrankenDeutsch:style=Regular",
|
||||
"Bounded:style=Medium"
|
||||
"Bounded:style=Medium",
|
||||
"LT Effervescent:style=Regular"
|
||||
];
|
||||
|
||||
fonts_stencil = ["Depot:style=Regular",
|
||||
|
|
@ -50,10 +49,8 @@ fonts_stencil = ["Depot:style=Regular",
|
|||
|
||||
/* [hidden] */
|
||||
|
||||
linespacing = textsize*1.6 * linespacing_custom;
|
||||
height = (len(lines) * linespacing) + border*2;
|
||||
|
||||
font_sets = [fonts_linux, fonts_windows, fonts_custom, fonts_stencil];
|
||||
fonts_manual = [font_manual];
|
||||
font_sets = [fonts_linux, fonts_windows, fonts_custom, fonts_stencil, fonts_manual];
|
||||
font = font_sets[font_set][font_index];
|
||||
|
||||
if (font == undef)
|
||||
|
|
@ -62,20 +59,11 @@ if (font == undef)
|
|||
}
|
||||
|
||||
|
||||
if (version()[0] != 2021 || version()[1] != 1)
|
||||
{
|
||||
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();
|
||||
}
|
||||
tm = textmetrics(line, size=textsize, font=font);
|
||||
|
||||
width = tm.size[0];
|
||||
height = tm.size[1];
|
||||
base_position = tm.position;
|
||||
|
||||
// All variables are set, make main
|
||||
main();
|
||||
|
|
@ -119,16 +107,14 @@ module stamp()
|
|||
{
|
||||
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);
|
||||
|
||||
color("white")
|
||||
linear_extrude(height = base_thickness_stamp+stamp_depth)
|
||||
text(line, font = font, size=textsize);
|
||||
|
||||
for (i = [0 : 1 : len(lines)])
|
||||
{
|
||||
line = lines[(len(lines)-1)-i];
|
||||
translate(v = [width/2, linespacing/2 +border + i*linespacing, 0])
|
||||
color("white")
|
||||
linear_extrude(height = base_thickness_stamp+stamp_depth)
|
||||
text(line, font = font, halign="center", valign="center", size=textsize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue