From 1174b457884bb15b308935c7df48e8a182e8c784 Mon Sep 17 00:00:00 2001 From: Bob Date: Thu, 7 May 2020 11:55:15 -0400 Subject: [PATCH] Difference inside from artisan() If you are making an artisan with a shape on the outside, it'd be pretty helpful if that shape didn't intrude on the stem or underside of the key --- customizer.scad | 18 ++++++++++++++---- src/key.scad | 18 ++++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/customizer.scad b/customizer.scad index f31317e..a595a1d 100644 --- a/customizer.scad +++ b/customizer.scad @@ -3352,7 +3352,7 @@ SMALLEST_POSSIBLE = 1/128; $fs = .1; $unit = 19.05; -// key shape including dish. used as the ouside and inside shape in keytop(). allows for itself to be shrunk in depth and width / height +// key shape including dish. used as the ouside and inside shape in hollow_key(). allows for itself to be shrunk in depth and width / height module shape(thickness_difference, depth_difference=0){ dished(depth_difference, $inverted_dish) { color($primary_color) shape_hull(thickness_difference, depth_difference, $inverted_dish ? 2 : 0); @@ -3505,6 +3505,14 @@ module inside() { } } +// for when you want something to only exist outside the keycap +module outside() { + difference() { + children(); + shape($wall_thickness, $keytop_thickness); + } +} + // put something at the top of the key, with no adjustments for dishing module top_placement(depth_difference=0) { top_tilt_by_height = -$top_tilt / $key_height; @@ -3685,7 +3693,7 @@ module artisan(depth) { } // key with hollowed inside but no stem -module keytop() { +module hollow_key() { difference(){ if ($rounded_key) { rounded_shape(); @@ -3706,16 +3714,18 @@ module key(inset = false) { difference() { union(){ // the shape of the key, inside and out - keytop(); + hollow_key(); if($key_bump) top_of_key() keybump($key_bump_depth, $key_bump_edge); // additive objects at the top of the key - if(!inset) artisan(0) children(); + // outside() makes them stay out of the inside. it's a bad name + if(!inset) outside() artisan(0) children(); if($outset_legends) legends(0); // 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 + // no outside() - I can't think of a use for it. will save render time if (inset) artisan($inset_legend_depth) children(); if(!$outset_legends) legends($inset_legend_depth); // subtract the clearance check if it's enabled, letting the user see the diff --git a/src/key.scad b/src/key.scad index 54f73e4..b6ef72c 100644 --- a/src/key.scad +++ b/src/key.scad @@ -21,7 +21,7 @@ SMALLEST_POSSIBLE = 1/128; $fs = .1; $unit = 19.05; -// key shape including dish. used as the ouside and inside shape in keytop(). allows for itself to be shrunk in depth and width / height +// key shape including dish. used as the ouside and inside shape in hollow_key(). allows for itself to be shrunk in depth and width / height module shape(thickness_difference, depth_difference=0){ dished(depth_difference, $inverted_dish) { color($primary_color) shape_hull(thickness_difference, depth_difference, $inverted_dish ? 2 : 0); @@ -174,6 +174,14 @@ module inside() { } } +// for when you want something to only exist outside the keycap +module outside() { + difference() { + children(); + shape($wall_thickness, $keytop_thickness); + } +} + // put something at the top of the key, with no adjustments for dishing module top_placement(depth_difference=0) { top_tilt_by_height = -$top_tilt / $key_height; @@ -354,7 +362,7 @@ module artisan(depth) { } // key with hollowed inside but no stem -module keytop() { +module hollow_key() { difference(){ if ($rounded_key) { rounded_shape(); @@ -375,16 +383,18 @@ module key(inset = false) { difference() { union(){ // the shape of the key, inside and out - keytop(); + hollow_key(); if($key_bump) top_of_key() keybump($key_bump_depth, $key_bump_edge); // additive objects at the top of the key - if(!inset) artisan(0) children(); + // outside() makes them stay out of the inside. it's a bad name + if(!inset) outside() artisan(0) children(); if($outset_legends) legends(0); // 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 + // no outside() - I can't think of a use for it. will save render time if (inset) artisan($inset_legend_depth) children(); if(!$outset_legends) legends($inset_legend_depth); // subtract the clearance check if it's enabled, letting the user see the