mirror of
https://github.com/rsheldiii/KeyV2.git
synced 2025-09-16 00:59:53 +00:00
Merge branch 'v2.0.0' into key-features
This commit is contained in:
commit
b29a5f3c5f
9 changed files with 220 additions and 66 deletions
|
@ -37,7 +37,7 @@ module rounded_shape() {
|
|||
// half minkowski in the z direction
|
||||
color($primary_color) shape_hull($minkowski_radius * 2, $minkowski_radius/2, $inverted_dish ? 2 : 0);
|
||||
/* cube($minkowski_radius); */
|
||||
sphere(r=$minkowski_radius, $fn=48);
|
||||
sphere(r=$minkowski_radius, $fn=$minkowski_facets);
|
||||
}
|
||||
}
|
||||
/* %envelope(); */
|
||||
|
|
|
@ -1,17 +1,35 @@
|
|||
function rounded_rectangle_profile(size=[1,1],r=1,fn=32) = [
|
||||
for (index = [0:fn-1])
|
||||
let(a = index/fn*360)
|
||||
r * [cos(a), sin(a)]
|
||||
+ sign_x(index, fn) * [size[0]/2-r,0]
|
||||
+ sign_y(index, fn) * [0,size[1]/2-r]
|
||||
];
|
||||
|
||||
function sign_x(i,n) =
|
||||
i < n/4 || i > n-n/4 ? 1 :
|
||||
i > n/4 && i < n-n/4 ? -1 :
|
||||
i < n/4 || i > n*3/4 ? 1 :
|
||||
i > n/4 && i < n*3/4 ? -1 :
|
||||
0;
|
||||
|
||||
function sign_y(i,n) =
|
||||
i > 0 && i < n/2 ? 1 :
|
||||
i > n/2 ? -1 :
|
||||
0;
|
||||
|
||||
|
||||
function rectangle_profile(size=[1,1],fn=32) = [
|
||||
for (index = [0:fn-1])
|
||||
let(a = index/fn*360)
|
||||
sign_x(index, fn) * [size[0]/2,0]
|
||||
+ sign_y(index, fn) * [0,size[1]/2]
|
||||
];
|
||||
|
||||
function rounded_rectangle_profile(size=[1,1],r=1,fn=32) = [
|
||||
let(max_fn = max(fn,8))
|
||||
for (index = [0:max_fn-1])
|
||||
let(a = index/max_fn*360)
|
||||
r * [cos(a), sin(a)]
|
||||
+ sign_x(index, max_fn) * [size[0]/2-r,0]
|
||||
+ sign_y(index, max_fn) * [0,size[1]/2-r]
|
||||
];
|
||||
|
||||
function double_rounded_rectangle_profile(size=[1,1], r=1, fn=32) = [
|
||||
let(max_fn = max(fn,8))
|
||||
for (index = [0:max_fn-1])
|
||||
let(a = index/max_fn*360)
|
||||
r * [cos(a), sin(a)]
|
||||
+ sign_x(index, max_fn) * [size[0]/2-r,0]
|
||||
+ sign_y(index, max_fn) * [0,size[1]/2-r]
|
||||
];
|
||||
|
|
|
@ -86,7 +86,7 @@ $extra_long_stem_support = false;
|
|||
|
||||
// Key shape type, determines the shape of the key. default is 'rounded square'
|
||||
$key_shape_type = "rounded_square";
|
||||
// ISO enter needs to be linear extruded NOT from the center. this tells the program how far up 'not from the center' is
|
||||
// ISO enter needs to be linear extruded NOT from the center when not using skin. this tells the program how far up 'not from the center' is
|
||||
$linear_extrude_height_adjustment = 0;
|
||||
// How many slices will be made, to approximate curves on corners. Leave at 1 if you are not curving corners
|
||||
// If you're doing fancy bowed keycap sides, this controls how many slices you take
|
||||
|
@ -183,3 +183,7 @@ $secondary_color = [.4412, .7, .3784];
|
|||
$tertiary_color = [1, .6941, .2];
|
||||
$quaternary_color = [.4078, .3569, .749];
|
||||
$warning_color = [1,0,0, 0.15];
|
||||
|
||||
// how many facets circles will have when used in these features
|
||||
$minkowski_facets = 30;
|
||||
$shape_facets =30;
|
||||
|
|
|
@ -32,9 +32,11 @@ module key_shape(size, delta, progress = 0) {
|
|||
|
||||
function skin_key_shape(size, delta, progress = 0, thickness_difference) =
|
||||
$key_shape_type == "rounded_square" ?
|
||||
skin_rounded_square(size, delta, progress) :
|
||||
skin_rounded_square(size, delta, progress, thickness_difference) :
|
||||
$key_shape_type == "sculpted_square" ?
|
||||
skin_sculpted_square_shape(size, delta, progress) :
|
||||
skin_sculpted_square_shape(size, delta, progress, thickness_difference) :
|
||||
$key_shape_type == "square" ?
|
||||
skin_square_shape(size, delta, progress, thickness_difference) :
|
||||
$key_shape_type == "iso_enter" ?
|
||||
skin_iso_enter_shape(size, delta, progress, thickness_difference) :
|
||||
echo("Warning: unsupported $key_shape_type for skin shape. disable skin_extrude_shape or pick a new shape");
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
include <../libraries/rounded_rectangle_profile.scad>
|
||||
|
||||
module rounded_square_shape(size, delta, progress, center = true) {
|
||||
offset(r=$corner_radius){
|
||||
offset(r=$corner_radius, $fa=360/$shape_facets){
|
||||
square_shape([size.x - $corner_radius*2, size.y - $corner_radius*2], delta, progress);
|
||||
}
|
||||
}
|
||||
|
||||
// for skin
|
||||
|
||||
function skin_rounded_square(size, delta, progress) =
|
||||
rounded_rectangle_profile(size - (delta * progress), fn=36, r=$corner_radius);
|
||||
function skin_rounded_square(size, delta, progress, thickness_difference) =
|
||||
rounded_rectangle_profile(size - (delta * progress), fn=$shape_facets, r=$corner_radius);
|
||||
|
|
|
@ -37,7 +37,7 @@ module sculpted_square_shape(size, delta, progress) {
|
|||
height - extra_height_this_slice
|
||||
];
|
||||
|
||||
offset(r = extra_corner_radius_this_slice) {
|
||||
offset(r = extra_corner_radius_this_slice, $fa=360/$shape_facets) {
|
||||
offset(r = -extra_corner_radius_this_slice) {
|
||||
side_rounded_square(square_size, r = $more_side_sculpting_factor * progress);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ module sculpted_square_shape(size, delta, progress) {
|
|||
|
||||
// fudging the hell out of this, I don't remember what the negative-offset-positive-offset was doing in the module above
|
||||
// also no 'bowed' square shape for now
|
||||
function skin_sculpted_square_shape(size, delta, progress) =
|
||||
function skin_sculpted_square_shape(size, delta, progress, thickness_difference) =
|
||||
let(
|
||||
width = size[0],
|
||||
height = size[1],
|
||||
|
@ -64,10 +64,10 @@ function skin_sculpted_square_shape(size, delta, progress) =
|
|||
extra_corner_radius_this_slice = ($corner_radius + extra_corner_size),
|
||||
|
||||
square_size = [
|
||||
width - extra_width_this_slice,
|
||||
height - extra_height_this_slice
|
||||
width - extra_width_this_slice - thickness_difference,
|
||||
height - extra_height_this_slice - thickness_difference
|
||||
]
|
||||
) rounded_rectangle_profile(square_size - [extra_corner_radius_this_slice, extra_corner_radius_this_slice]/4, fn=36, r=extra_corner_radius_this_slice/1.5 + $more_side_sculpting_factor * progress);
|
||||
) double_rounded_rectangle_profile(square_size - [extra_corner_radius_this_slice, extra_corner_radius_this_slice]/4, fn=$shape_facets, r=extra_corner_radius_this_slice/1.5 + $more_side_sculpting_factor * progress);
|
||||
|
||||
/* offset(r = extra_corner_radius_this_slice) {
|
||||
offset(r = -extra_corner_radius_this_slice) {
|
||||
|
@ -85,10 +85,10 @@ module side_rounded_square(size, r) {
|
|||
sw = iw / resolution;
|
||||
union() {
|
||||
if (sr > 0) {
|
||||
translate([-iw/2, 0]) scale([sr, sh]) circle(d = resolution);
|
||||
translate([iw/2, 0]) scale([sr, sh]) circle(d = resolution);
|
||||
translate([0, -ih/2]) scale([sw, sr]) circle(d = resolution);
|
||||
translate([0, ih/2]) scale([sw, sr]) circle(d = resolution);
|
||||
translate([-iw/2, 0]) scale([sr, sh]) circle(d = resolution, $fa=360/$shape_facets);
|
||||
translate([iw/2, 0]) scale([sr, sh]) circle(d = resolution, $fa=360/$shape_facets);
|
||||
translate([0, -ih/2]) scale([sw, sr]) circle(d = resolution, $fa=360/$shape_facets);
|
||||
translate([0, ih/2]) scale([sw, sr]) circle(d = resolution, $fa=360/$shape_facets);
|
||||
}
|
||||
square([iw, ih], center=true);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
use <../functions.scad>
|
||||
include <../libraries/rounded_rectangle_profile.scad>
|
||||
|
||||
|
||||
// we do this weird key_shape_type check here because rounded_square uses
|
||||
// square_shape, and we want flat sides to work for that too.
|
||||
|
@ -28,3 +30,17 @@ module flat_sided_square_shape(size, delta, progress) {
|
|||
[(-size.x + (delta.x - extra_keytop_length_for_flat_sides()) * progress)/2, (size.y - delta.y * progress)/2]
|
||||
]);
|
||||
}
|
||||
|
||||
function skin_square_shape(size, delta, progress, thickness_difference) =
|
||||
let(
|
||||
width = size[0],
|
||||
height = size[1],
|
||||
|
||||
width_difference = delta[0] * progress,
|
||||
height_difference = delta[1] * progress,
|
||||
|
||||
square_size = [
|
||||
width - width_difference - thickness_difference,
|
||||
height - height_difference - thickness_difference
|
||||
]
|
||||
) rectangle_profile(square_size, fn=36);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue