Skip to content

Instantly share code, notes, and snippets.

@ridercz
Created October 17, 2020 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ridercz/9ad085283d4e66de8db06e4ce3938b63 to your computer and use it in GitHub Desktop.
Save ridercz/9ad085283d4e66de8db06e4ce3938b63 to your computer and use it in GitHub Desktop.
Děkujeme za názor a tady máte klíčenku
// For more information about this code (in Czech) see
// https://www.altair.blog/2019/11/layered-text
/* [Base] */
base_color = "#333333";
base_paddding = 2;
base_height = 2;
/* [Text layers] */
layer_heights = [1, 1];
layer_text_strings = [ "NÁZOR", "DÍKY ZA"];
layer_text_sizes = [20, 15];
layer_colors = [ "#FF6600", "#EEEEEE"];
font_name = "Arial Rounded MT Bold";
/* [Hanging hole] */
hole_position = [49, -4];
hole_diameter = 5;
// Create base
color(base_color) linear_extrude(base_height) difference() {
offset(base_paddding) union() {
for(i = [0:len(layer_heights) - 1]) text(text = layer_text_strings[i], font = font_name, size = layer_text_sizes[i], halign = "center", valign = "center");
if(hole_diameter > 0) translate(hole_position) circle(d = hole_diameter, $fn = 32);
}
if(hole_diameter > 0) translate(hole_position) circle(d = hole_diameter, $fn = 32);
}
// Create text layers
translate([0, 0, base_height]) for(i = [0:len(layer_heights) - 1]) {
lh = csum(layer_heights, i);
color(layer_colors[i]) linear_extrude(lh) text(text = layer_text_strings[i], font = font_name, size = layer_text_sizes[i], halign = "center", valign = "center");
}
// Helper function to compute total layer height
function csum(items, i, val = 0, n = 0) = n >= i ? val + items[n] : csum(items, i, val + items[n], n + 1);
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment