mirror of
https://github.com/rsheldiii/KeyV2.git
synced 2024-11-23 05:34:23 +00:00
Move legend from key function to legend function.
legend function may be called repeatedly, with posititioning and sizing parameters to place multiple legends on a key.
This commit is contained in:
parent
d7311d2dac
commit
ad86c1a7a9
@ -38,3 +38,6 @@ for (p = [0:len(key_profiles)-1]) {
|
||||
}
|
||||
|
||||
/* translate_u(0, 0) one_row_profile("oem"); */
|
||||
|
||||
dcs_row(3) cherry() legend("X", "top", "left", 3) legend("X") key(true);
|
||||
translate_u(1, 0) dcs_row(3) cherry() legend("M", "top", "left", 3) legend("Z") key(true);
|
||||
|
20
src/key.scad
20
src/key.scad
@ -161,10 +161,12 @@ module top_of_key(){
|
||||
}
|
||||
}
|
||||
|
||||
module keytext(text, depth = 0) {
|
||||
translate([0, 0, -depth]){
|
||||
module keytext(text, halign, valign, font_size, depth) {
|
||||
woffset = (top_total_key_width()/3.5) * (halign == "center" ? 0 : halign == "left" ? -1 : 1);
|
||||
hoffset = (top_total_key_height()/3.5) * (valign == "center" ? 0 : valign == "bottom" ? -1 : 1);
|
||||
translate([woffset, hoffset, -depth]){
|
||||
linear_extrude(height=$dish_depth){
|
||||
text(text=text, font=$font, size=$font_size, halign="center", valign="center");
|
||||
text(text=text, font=$font, size=font_size, halign="center", valign="center");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -217,10 +219,12 @@ module clearance_check() {
|
||||
}
|
||||
|
||||
// legends / artisan support
|
||||
module artisan(legend, depth) {
|
||||
module artisan(depth) {
|
||||
top_of_key() {
|
||||
// outset legend
|
||||
if (legend != "") keytext(legend, depth);
|
||||
for (i=[0:len($legends)-1]) {
|
||||
keytext($legends[i][0], $legends[i][1], $legends[i][2], $legends[i][3], depth);
|
||||
}
|
||||
// artisan objects / outset shape legends
|
||||
children();
|
||||
}
|
||||
@ -244,19 +248,19 @@ module keytop() {
|
||||
|
||||
// The final, penultimate key generation function.
|
||||
// takes all the bits and glues them together. requires configuration with special variables.
|
||||
module key(legend = "", inset = false) {
|
||||
module key(inset = false) {
|
||||
difference() {
|
||||
union(){
|
||||
// the shape of the key, inside and out
|
||||
keytop();
|
||||
// additive objects at the top of the key
|
||||
if(!inset) artisan(legend) children();
|
||||
if(!inset) artisan() children();
|
||||
// render the clearance check if it's enabled, but don't have it intersect with anything
|
||||
if ($clearance_check) %clearance_check();
|
||||
}
|
||||
|
||||
// subtractive objects at the top of the key
|
||||
if (inset) artisan(legend, 0.3) children();
|
||||
if (inset) artisan(0.3) children();
|
||||
// subtract the clearance check if it's enabled, letting the user see the
|
||||
// parts of the keycap that will hit the cherry switch
|
||||
if ($clearance_check) clearance_check();
|
||||
|
@ -100,3 +100,10 @@ module flat_support() {
|
||||
$support_type = "flat";
|
||||
children();
|
||||
}
|
||||
|
||||
module legend(text, valign="center", halign="center", size=0) {
|
||||
//valign = "top" or "center" or "bottom"
|
||||
//halign = "left" or "center" or "right"
|
||||
$legends = [for(L=[$legends, [[text, halign, valign, size > 0 ? size : $font_size]]], a=L) a];
|
||||
children();
|
||||
}
|
||||
|
@ -109,3 +109,9 @@ $rounded_cherry_stem_d = 5.5;
|
||||
|
||||
// dimensions of alps stem
|
||||
$alps_stem = [4.45, 2.25];
|
||||
|
||||
//list of legends to place on a key format: [text, halign, valign, size]
|
||||
//halign = "left" or "center" or "right"
|
||||
//valign = "top" or "center" or "bottom"
|
||||
$legends = [];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user