Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple font legends on the same key #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions keys.scad
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ include <./includes.scad>
// example key
dcs_row(5) legend("⇪", size=9) key();

// different font legends
translate_u(0,-1) dsa_row(3) legend("A", position=[-1,-1], size=4, font_name="Arial") legend("%", position=[1,0], size=3, font_name="Arial Rounded MT Bold")key();

// example row
/* for (x = [0:1:4]) {
translate_u(0,-x) dcs_row(x) key();
Expand Down
8 changes: 4 additions & 4 deletions src/key.scad
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,12 @@ module top_of_key(){
}
}

module keytext(text, position, font_size, depth) {
module keytext(text, position, font_size, font_name, depth) {
woffset = (top_total_key_width()/3.5) * position[0];
hoffset = (top_total_key_height()/3.5) * -position[1];
translate([woffset, hoffset, -depth]){
color($tertiary_color) linear_extrude(height=$dish_depth){
text(text=text, font=$font, size=font_size, halign="center", valign="center");
text(text=text, font=font_name, size=font_size, halign="center", valign="center");
}
}
}
Expand Down Expand Up @@ -333,7 +333,7 @@ module legends(depth=0) {
front_placement() {
if (len($front_legends) > 0) {
for (i=[0:len($front_legends)-1]) {
rotate([90,0,0]) keytext($front_legends[i][0], $front_legends[i][1], $front_legends[i][2], depth);
rotate([90,0,0]) keytext($front_legends[i][0], $front_legends[i][1], $front_legends[i][2], $front_legends[i][3], depth);
}
}
}
Expand All @@ -343,7 +343,7 @@ module legends(depth=0) {
// outset legend
if (len($legends) > 0) {
for (i=[0:len($legends)-1]) {
keytext($legends[i][0], $legends[i][1], $legends[i][2], depth);
keytext($legends[i][0], $legends[i][1], $legends[i][2], $legends[i][3], depth);
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/key_transformations.scad
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,17 @@ module flat_support() {
children();
}

module legend(text, position=[0,0], size=undef) {
module legend(text, position=[0,0], size=undef, font_name=undef) {
font_size = size == undef ? $font_size : size;
$legends = [for(L=[$legends, [[text, position, font_size]]], a=L) a];
font_name = font_name == undef ? $font : font_name;
$legends = [for(L=[$legends, [[text, position, font_size, font_name]]], a=L) a];
children();
}

module front_legend(text, position=[0,0], size=undef) {
module front_legend(text, position=[0,0], size=undef, font_name=undef) {
font_size = size == undef ? $font_size : size;
$front_legends = [for(L=[$front_legends, [[text, position, font_size]]], a=L) a];
font_name = font_name == undef ? $font : font_name;
$front_legends = [for(L=[$front_legends, [[text, position, font_size, font_name]]], a=L) a];
children();
}

Expand Down