From 16f97911aee8cd1f55bdd397b1114ecd14027005 Mon Sep 17 00:00:00 2001 From: Bob - Home - Windows Date: Tue, 17 Oct 2017 00:50:48 -0400 Subject: [PATCH] finalize keysets.scad (just 60%, the other profiles will take too much work for negligent gain since who prints an 86 key keyset out in one go) and add top_of_key to allow for children of key() to be rendered smack in the middle of the keytop --- key.scad | 18 +++++++++++++++--- keys.scad | 15 +++++++-------- keysets.scad | 11 ++++------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/key.scad b/key.scad index c446c65..f9bf66a 100644 --- a/key.scad +++ b/key.scad @@ -186,12 +186,21 @@ module dished(depth_difference, inverted = false) { } } -module keytext() { +// puts it's children at the center of the dishing on the key. this DOES rotate them though, it's not straight up +module top_of_key(){ extra_dish_depth = ($dish_type == "no dish") ? 0 : $dish_depth; + translate([$dish_skew_x, $top_skew + $dish_skew_y, $total_depth - extra_dish_depth]){ + rotate([-$top_tilt,0,0]){ + children(); + } + } +} + +module keytext() { extra_inset_depth = ($inset_text) ? keytop_thickness/4 : 0; - translate([$dish_skew_x, $top_skew + $dish_skew_y, $total_depth - extra_dish_depth - extra_inset_depth]){ - rotate([-$top_tilt,0,0]){ + translate([0, 0, -extra_inset_depth]){ + top_of_key(){ linear_extrude(height=$dish_depth){ text(text=$text, font=font, size=font_size, halign="center", valign="center"); } @@ -252,6 +261,9 @@ module key() { if($stem_profile != "blank") connectors($stem_profile); if(!$inset_text) keytext(); clearance_check(); + top_of_key() { + children(); + } } if ($inset_text) keytext(); } diff --git a/keys.scad b/keys.scad index 2cb01a3..cd9f897 100644 --- a/keys.scad +++ b/keys.scad @@ -1,17 +1,15 @@ // the point of this file is to be a sort of DSL for constructing keycaps. // when you create a method chain you are just changing the parameters // key.scad uses, it doesn't generate anything itself until the end. This -// makes it remain easy to use key.scad like before (except without key profiles) +// lets it remain easy to use key.scad like before (except without key profiles) // without having to rely on this file. Unfortunately that means setting tons of // special variables, but that's a limitation of SCAD we have to work around /* TODO: * can now measure keycaps very accurately. need to redo measurements: [x] SA [ ] DCS [X] DSA [X] OEM? - * make OEM profile from my WASD keyset - * Pregenerated keysets for DCS (rounded tops too intense) WITH rounded spacebar [ ] 60% [ ] TKL [ ] full - * Add inset stem to all profiles that need it (DCS?) - * generate dishes via math? kind of hard + * Add inset stem to all profiles that need it. [x] OEM [ ] DCS? * customizer version where everything is copy/pasted in. needs to be last. + * generate dishes via math? kind of hard, maybe later */ use @@ -414,8 +412,9 @@ module legend(text, inset=false) { children(); } -rows = [4,3,2,1,5]; +/*rows = [4,3,2,1,5]; -translate_u(0, 0) oem_row(rows[0]) cherry() key(); -translate_u(0, 1) oem_row(rows[1]) cherry() key(); +translate_u(0, 0) oem_row(1) cherry() key() { + cube(2, center=true); +};*/ diff --git a/keysets.scad b/keysets.scad index 4eab4b3..a99d7c5 100644 --- a/keysets.scad +++ b/keysets.scad @@ -15,18 +15,15 @@ function sum(list, x=0) = x + list[0] : sum([for (x = [1: len(list) - 1]) list[x]], x+list[0]); -echo(sum([1,2,3])); - -for (row = [0:len(60_percent)]){ - for(column = [0:len(60_percent[row])]) { +for (row = [0:len(60_percent)-1]){ + for(column = [0:len(60_percent[row])-1]) { columnDist = sum([for (x = [0 : column]) 60_percent[row][x]]); a = 60_percent[row][column]; - translate_u(columnDist - (a/2), -row) dishless() dcs_row((row+4) % 5 + 1) u(a) blank(){ + translate_u(columnDist - (a/2), -row) dishless() dcs_row((row+4) % 5 + 1) u(a) cherry() { if (a != 6.25) { key(); } else { - $dish_type = 2; - key(); + spacebar() key(); } } }