Merge branch 'v2.0.0' into key-features
This commit is contained in:
commit
b29a5f3c5f
|
@ -60,7 +60,7 @@ You can chain as many modifier functions as you like!
|
||||||
|
|
||||||
## Modifier functions
|
## Modifier functions
|
||||||
|
|
||||||
There is a bevy of supporting functions to customize your keycaps. You can add a brim to more easily print the stem with `brimmed_stem_support`, make 2x2 keycaps with `2u() 2uh()`, add legends, rotate stems, and more. All these functions manipulate the settings available to you in [`settings.scad`](https://github.com/rsheldiii/KeyV2/blob/master/src/settings.scad), though [some of them](https://github.com/rsheldiii/KeyV2/blob/master/src/key_transformations.scad#L128) are quite complex.
|
There is a bevy of supporting functions to customize your keycaps. You can add a brim to more easily print the stem with `brimmed_stem_support`, make 2x2 keycaps with `2u() 2uh()`, add legends, rotate stems, and more. All these functions manipulate the settings available to you in [`settings.scad`](https://github.com/rsheldiii/KeyV2/blob/master/src/settings.scad), though [some of them](https://github.com/rsheldiii/KeyV2/blob/851ececdb297c77bfbcd0a7cb4cdbc5e21970396/src/key_transformations.scad#L128) are quite complex.
|
||||||
|
|
||||||
These modifier functions can be found in [`key_profiles/`](https://github.com/rsheldiii/KeyV2/blob/master/src/key_profiles) for different keycap profiles, [`key_types.scad`](https://github.com/rsheldiii/KeyV2/blob/master/src/key_types.scad) for predefined settings for common keys (spacebar, left shift, etc), [`key_sizes.scad`](https://github.com/rsheldiii/KeyV2/blob/master/src/key_sizes.scad) for common unit sizes, and [`key_transformations.scad`](https://github.com/rsheldiii/KeyV2/blob/master/src/key_transformations.scad) for everything else. I encourage you to do some sleuthing but for a list of (most) helper functions with explanations, [Check out the wiki!](https://github.com/rsheldiii/KeyV2/wiki/KeyV2-Helper-Documentation)
|
These modifier functions can be found in [`key_profiles/`](https://github.com/rsheldiii/KeyV2/blob/master/src/key_profiles) for different keycap profiles, [`key_types.scad`](https://github.com/rsheldiii/KeyV2/blob/master/src/key_types.scad) for predefined settings for common keys (spacebar, left shift, etc), [`key_sizes.scad`](https://github.com/rsheldiii/KeyV2/blob/master/src/key_sizes.scad) for common unit sizes, and [`key_transformations.scad`](https://github.com/rsheldiii/KeyV2/blob/master/src/key_transformations.scad) for everything else. I encourage you to do some sleuthing but for a list of (most) helper functions with explanations, [Check out the wiki!](https://github.com/rsheldiii/KeyV2/wiki/KeyV2-Helper-Documentation)
|
||||||
|
|
||||||
|
|
192
customizer.scad
192
customizer.scad
|
@ -52,7 +52,7 @@ $outset_legends = false;
|
||||||
// Height in units of key. should remain 1 for most uses
|
// Height in units of key. should remain 1 for most uses
|
||||||
$key_height = 1.0;
|
$key_height = 1.0;
|
||||||
// Keytop thickness, aka how many millimeters between the inside and outside of the top surface of the key
|
// Keytop thickness, aka how many millimeters between the inside and outside of the top surface of the key
|
||||||
$keytop_thickness = 1;
|
$keytop_thickness = 2;
|
||||||
// Wall thickness, aka the thickness of the sides of the keycap. note this is the total thickness, aka 3 = 1.5mm walls
|
// Wall thickness, aka the thickness of the sides of the keycap. note this is the total thickness, aka 3 = 1.5mm walls
|
||||||
$wall_thickness = 3;
|
$wall_thickness = 3;
|
||||||
// Radius of corners of keycap
|
// Radius of corners of keycap
|
||||||
|
@ -101,7 +101,7 @@ $extra_long_stem_support = false;
|
||||||
|
|
||||||
// Key shape type, determines the shape of the key. default is 'rounded square'
|
// Key shape type, determines the shape of the key. default is 'rounded square'
|
||||||
$key_shape_type = "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;
|
$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
|
// 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
|
// If you're doing fancy bowed keycap sides, this controls how many slices you take
|
||||||
|
@ -199,6 +199,19 @@ $tertiary_color = [1, .6941, .2];
|
||||||
$quaternary_color = [.4078, .3569, .749];
|
$quaternary_color = [.4078, .3569, .749];
|
||||||
$warning_color = [1,0,0, 0.15];
|
$warning_color = [1,0,0, 0.15];
|
||||||
|
|
||||||
|
// 3d surface variables
|
||||||
|
// see functions.scad for the surface function
|
||||||
|
$3d_surface_size = 10;
|
||||||
|
$3d_surface_step = 1;
|
||||||
|
// normally the bottom of the keytop looks like the top - curved, at least
|
||||||
|
// underneath the support structure. This ensures there's a minimum thickness for the
|
||||||
|
// underside of the keycap, but it's a fair bit of geometry
|
||||||
|
$flat_keytop_bottom = true;
|
||||||
|
|
||||||
|
// how many facets circles will have when used in these features
|
||||||
|
$minkowski_facets = 30;
|
||||||
|
$shape_facets =30;
|
||||||
|
|
||||||
// key width functions
|
// key width functions
|
||||||
|
|
||||||
module u(u=1) {
|
module u(u=1) {
|
||||||
|
@ -970,17 +983,9 @@ function iso_enter_vertices(width, height, width_ratio, height_ratio, wd, hd) =
|
||||||
// no rounding on the corners at all
|
// no rounding on the corners at all
|
||||||
function skin_iso_enter_shape(size, delta, progress, thickness_difference) =
|
function skin_iso_enter_shape(size, delta, progress, thickness_difference) =
|
||||||
iso_enter_vertices(size.x, size.y, unit_length(1.25) / unit_length(1.5), unit_length(1) / unit_length(2), thickness_difference/2 + delta.x * progress/2, thickness_difference/2 + delta.y * progress/2);
|
iso_enter_vertices(size.x, size.y, unit_length(1.25) / unit_length(1.5), unit_length(1) / unit_length(2), thickness_difference/2 + delta.x * progress/2, thickness_difference/2 + delta.y * progress/2);
|
||||||
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) =
|
function sign_x(i,n) =
|
||||||
i < n/4 || i > n-n/4 ? 1 :
|
i < n/4 || i > n*3/4 ? 1 :
|
||||||
i > n/4 && i < n-n/4 ? -1 :
|
i > n/4 && i < n*3/4 ? -1 :
|
||||||
0;
|
0;
|
||||||
|
|
||||||
function sign_y(i,n) =
|
function sign_y(i,n) =
|
||||||
|
@ -988,6 +993,32 @@ function sign_y(i,n) =
|
||||||
i > n/2 ? -1 :
|
i > n/2 ? -1 :
|
||||||
0;
|
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]
|
||||||
|
];
|
||||||
|
|
||||||
// rounded square shape with additional sculpting functions to better approximate
|
// rounded square shape with additional sculpting functions to better approximate
|
||||||
|
|
||||||
// When sculpting sides, how much in should the tops come
|
// When sculpting sides, how much in should the tops come
|
||||||
|
@ -1025,7 +1056,7 @@ module sculpted_square_shape(size, delta, progress) {
|
||||||
height - extra_height_this_slice
|
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) {
|
offset(r = -extra_corner_radius_this_slice) {
|
||||||
side_rounded_square(square_size, r = $more_side_sculpting_factor * progress);
|
side_rounded_square(square_size, r = $more_side_sculpting_factor * progress);
|
||||||
}
|
}
|
||||||
|
@ -1034,7 +1065,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
|
// 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
|
// 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(
|
let(
|
||||||
width = size[0],
|
width = size[0],
|
||||||
height = size[1],
|
height = size[1],
|
||||||
|
@ -1052,10 +1083,10 @@ function skin_sculpted_square_shape(size, delta, progress) =
|
||||||
extra_corner_radius_this_slice = ($corner_radius + extra_corner_size),
|
extra_corner_radius_this_slice = ($corner_radius + extra_corner_size),
|
||||||
|
|
||||||
square_size = [
|
square_size = [
|
||||||
width - extra_width_this_slice,
|
width - extra_width_this_slice - thickness_difference,
|
||||||
height - extra_height_this_slice
|
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) {
|
||||||
offset(r = -extra_corner_radius_this_slice) {
|
offset(r = -extra_corner_radius_this_slice) {
|
||||||
|
@ -1073,25 +1104,17 @@ module side_rounded_square(size, r) {
|
||||||
sw = iw / resolution;
|
sw = iw / resolution;
|
||||||
union() {
|
union() {
|
||||||
if (sr > 0) {
|
if (sr > 0) {
|
||||||
translate([-iw/2, 0]) scale([sr, sh]) 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);
|
translate([iw/2, 0]) scale([sr, sh]) circle(d = resolution, $fa=360/$shape_facets);
|
||||||
translate([0, -ih/2]) scale([sw, sr]) circle(d = resolution);
|
translate([0, -ih/2]) scale([sw, sr]) circle(d = resolution, $fa=360/$shape_facets);
|
||||||
translate([0, ih/2]) scale([sw, sr]) circle(d = resolution);
|
translate([0, ih/2]) scale([sw, sr]) circle(d = resolution, $fa=360/$shape_facets);
|
||||||
}
|
}
|
||||||
square([iw, ih], center=true);
|
square([iw, ih], center=true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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) =
|
function sign_x(i,n) =
|
||||||
i < n/4 || i > n-n/4 ? 1 :
|
i < n/4 || i > n*3/4 ? 1 :
|
||||||
i > n/4 && i < n-n/4 ? -1 :
|
i > n/4 && i < n*3/4 ? -1 :
|
||||||
0;
|
0;
|
||||||
|
|
||||||
function sign_y(i,n) =
|
function sign_y(i,n) =
|
||||||
|
@ -1099,16 +1122,42 @@ function sign_y(i,n) =
|
||||||
i > n/2 ? -1 :
|
i > n/2 ? -1 :
|
||||||
0;
|
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]
|
||||||
|
];
|
||||||
|
|
||||||
module rounded_square_shape(size, delta, progress, center = true) {
|
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);
|
square_shape([size.x - $corner_radius*2, size.y - $corner_radius*2], delta, progress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// for skin
|
// for skin
|
||||||
|
|
||||||
function skin_rounded_square(size, delta, progress) =
|
function skin_rounded_square(size, delta, progress, thickness_difference) =
|
||||||
rounded_rectangle_profile(size - (delta * progress), fn=36, r=$corner_radius);
|
rounded_rectangle_profile(size - (delta * progress), fn=$shape_facets, r=$corner_radius);
|
||||||
SMALLEST_POSSIBLE = 1/128;
|
SMALLEST_POSSIBLE = 1/128;
|
||||||
|
|
||||||
// I use functions when I need to compute special variables off of other special variables
|
// I use functions when I need to compute special variables off of other special variables
|
||||||
|
@ -1151,6 +1200,42 @@ function vertical_inclination_due_to_top_tilt() = sin($top_tilt) * (top_total_ke
|
||||||
// of the keycap a flat plane. 1 = front, -1 = back
|
// of the keycap a flat plane. 1 = front, -1 = back
|
||||||
// I derived this through a bunch of trig reductions I don't really understand.
|
// I derived this through a bunch of trig reductions I don't really understand.
|
||||||
function extra_keytop_length_for_flat_sides() = ($width_difference * vertical_inclination_due_to_top_tilt()) / ($total_depth);
|
function extra_keytop_length_for_flat_sides() = ($width_difference * vertical_inclination_due_to_top_tilt()) / ($total_depth);
|
||||||
|
function sign_x(i,n) =
|
||||||
|
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]
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
// we do this weird key_shape_type check here because rounded_square uses
|
// 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.
|
// square_shape, and we want flat sides to work for that too.
|
||||||
|
@ -1180,6 +1265,20 @@ 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]
|
[(-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);
|
||||||
module oblong_shape(size, delta, progress) {
|
module oblong_shape(size, delta, progress) {
|
||||||
// .05 is because of offset. if we set offset to be half the height of the shape, and then subtract height from the shape, the height of the shape will be zero (because the shape would be [width - height, height - height]). that doesn't play well with openSCAD (understandably), so we add this tiny fudge factor to make sure the shape we offset has a positive width
|
// .05 is because of offset. if we set offset to be half the height of the shape, and then subtract height from the shape, the height of the shape will be zero (because the shape would be [width - height, height - height]). that doesn't play well with openSCAD (understandably), so we add this tiny fudge factor to make sure the shape we offset has a positive width
|
||||||
height = size[1] - delta[1] * progress - .05;
|
height = size[1] - delta[1] * progress - .05;
|
||||||
|
@ -1217,9 +1316,11 @@ module key_shape(size, delta, progress = 0) {
|
||||||
|
|
||||||
function skin_key_shape(size, delta, progress = 0, thickness_difference) =
|
function skin_key_shape(size, delta, progress = 0, thickness_difference) =
|
||||||
$key_shape_type == "rounded_square" ?
|
$key_shape_type == "rounded_square" ?
|
||||||
skin_rounded_square(size, delta, progress) :
|
skin_rounded_square(size, delta, progress, thickness_difference) :
|
||||||
$key_shape_type == "sculpted_square" ?
|
$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" ?
|
$key_shape_type == "iso_enter" ?
|
||||||
skin_iso_enter_shape(size, delta, progress, thickness_difference) :
|
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");
|
echo("Warning: unsupported $key_shape_type for skin shape. disable skin_extrude_shape or pick a new shape");
|
||||||
|
@ -3420,7 +3521,7 @@ module rounded_shape() {
|
||||||
// half minkowski in the z direction
|
// half minkowski in the z direction
|
||||||
color($primary_color) shape_hull($minkowski_radius * 2, $minkowski_radius/2, $inverted_dish ? 2 : 0);
|
color($primary_color) shape_hull($minkowski_radius * 2, $minkowski_radius/2, $inverted_dish ? 2 : 0);
|
||||||
/* cube($minkowski_radius); */
|
/* cube($minkowski_radius); */
|
||||||
sphere(r=$minkowski_radius, $fn=48);
|
sphere(r=$minkowski_radius, $fn=$minkowski_facets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* %envelope(); */
|
/* %envelope(); */
|
||||||
|
@ -3795,7 +3896,7 @@ $outset_legends = false;
|
||||||
// Height in units of key. should remain 1 for most uses
|
// Height in units of key. should remain 1 for most uses
|
||||||
$key_height = 1.0;
|
$key_height = 1.0;
|
||||||
// Keytop thickness, aka how many millimeters between the inside and outside of the top surface of the key
|
// Keytop thickness, aka how many millimeters between the inside and outside of the top surface of the key
|
||||||
$keytop_thickness = 1;
|
$keytop_thickness = 2;
|
||||||
// Wall thickness, aka the thickness of the sides of the keycap. note this is the total thickness, aka 3 = 1.5mm walls
|
// Wall thickness, aka the thickness of the sides of the keycap. note this is the total thickness, aka 3 = 1.5mm walls
|
||||||
$wall_thickness = 3;
|
$wall_thickness = 3;
|
||||||
// Radius of corners of keycap
|
// Radius of corners of keycap
|
||||||
|
@ -3844,7 +3945,7 @@ $extra_long_stem_support = false;
|
||||||
|
|
||||||
// Key shape type, determines the shape of the key. default is 'rounded square'
|
// Key shape type, determines the shape of the key. default is 'rounded square'
|
||||||
$key_shape_type = "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;
|
$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
|
// 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
|
// If you're doing fancy bowed keycap sides, this controls how many slices you take
|
||||||
|
@ -3941,6 +4042,19 @@ $secondary_color = [.4412, .7, .3784];
|
||||||
$tertiary_color = [1, .6941, .2];
|
$tertiary_color = [1, .6941, .2];
|
||||||
$quaternary_color = [.4078, .3569, .749];
|
$quaternary_color = [.4078, .3569, .749];
|
||||||
$warning_color = [1,0,0, 0.15];
|
$warning_color = [1,0,0, 0.15];
|
||||||
|
|
||||||
|
// 3d surface variables
|
||||||
|
// see functions.scad for the surface function
|
||||||
|
$3d_surface_size = 10;
|
||||||
|
$3d_surface_step = 1;
|
||||||
|
// normally the bottom of the keytop looks like the top - curved, at least
|
||||||
|
// underneath the support structure. This ensures there's a minimum thickness for the
|
||||||
|
// underside of the keycap, but it's a fair bit of geometry
|
||||||
|
$flat_keytop_bottom = true;
|
||||||
|
|
||||||
|
// how many facets circles will have when used in these features
|
||||||
|
$minkowski_facets = 30;
|
||||||
|
$shape_facets =30;
|
||||||
key();
|
key();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ module rounded_shape() {
|
||||||
// half minkowski in the z direction
|
// half minkowski in the z direction
|
||||||
color($primary_color) shape_hull($minkowski_radius * 2, $minkowski_radius/2, $inverted_dish ? 2 : 0);
|
color($primary_color) shape_hull($minkowski_radius * 2, $minkowski_radius/2, $inverted_dish ? 2 : 0);
|
||||||
/* cube($minkowski_radius); */
|
/* cube($minkowski_radius); */
|
||||||
sphere(r=$minkowski_radius, $fn=48);
|
sphere(r=$minkowski_radius, $fn=$minkowski_facets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* %envelope(); */
|
/* %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) =
|
function sign_x(i,n) =
|
||||||
i < n/4 || i > n-n/4 ? 1 :
|
i < n/4 || i > n*3/4 ? 1 :
|
||||||
i > n/4 && i < n-n/4 ? -1 :
|
i > n/4 && i < n*3/4 ? -1 :
|
||||||
0;
|
0;
|
||||||
|
|
||||||
function sign_y(i,n) =
|
function sign_y(i,n) =
|
||||||
i > 0 && i < n/2 ? 1 :
|
i > 0 && i < n/2 ? 1 :
|
||||||
i > n/2 ? -1 :
|
i > n/2 ? -1 :
|
||||||
0;
|
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, determines the shape of the key. default is 'rounded square'
|
||||||
$key_shape_type = "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;
|
$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
|
// 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
|
// 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];
|
$tertiary_color = [1, .6941, .2];
|
||||||
$quaternary_color = [.4078, .3569, .749];
|
$quaternary_color = [.4078, .3569, .749];
|
||||||
$warning_color = [1,0,0, 0.15];
|
$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) =
|
function skin_key_shape(size, delta, progress = 0, thickness_difference) =
|
||||||
$key_shape_type == "rounded_square" ?
|
$key_shape_type == "rounded_square" ?
|
||||||
skin_rounded_square(size, delta, progress) :
|
skin_rounded_square(size, delta, progress, thickness_difference) :
|
||||||
$key_shape_type == "sculpted_square" ?
|
$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" ?
|
$key_shape_type == "iso_enter" ?
|
||||||
skin_iso_enter_shape(size, delta, progress, thickness_difference) :
|
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");
|
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>
|
include <../libraries/rounded_rectangle_profile.scad>
|
||||||
|
|
||||||
module rounded_square_shape(size, delta, progress, center = true) {
|
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);
|
square_shape([size.x - $corner_radius*2, size.y - $corner_radius*2], delta, progress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// for skin
|
// for skin
|
||||||
|
|
||||||
function skin_rounded_square(size, delta, progress) =
|
function skin_rounded_square(size, delta, progress, thickness_difference) =
|
||||||
rounded_rectangle_profile(size - (delta * progress), fn=36, r=$corner_radius);
|
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
|
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) {
|
offset(r = -extra_corner_radius_this_slice) {
|
||||||
side_rounded_square(square_size, r = $more_side_sculpting_factor * progress);
|
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
|
// 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
|
// 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(
|
let(
|
||||||
width = size[0],
|
width = size[0],
|
||||||
height = size[1],
|
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),
|
extra_corner_radius_this_slice = ($corner_radius + extra_corner_size),
|
||||||
|
|
||||||
square_size = [
|
square_size = [
|
||||||
width - extra_width_this_slice,
|
width - extra_width_this_slice - thickness_difference,
|
||||||
height - extra_height_this_slice
|
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) {
|
||||||
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;
|
sw = iw / resolution;
|
||||||
union() {
|
union() {
|
||||||
if (sr > 0) {
|
if (sr > 0) {
|
||||||
translate([-iw/2, 0]) scale([sr, sh]) 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);
|
translate([iw/2, 0]) scale([sr, sh]) circle(d = resolution, $fa=360/$shape_facets);
|
||||||
translate([0, -ih/2]) scale([sw, sr]) circle(d = resolution);
|
translate([0, -ih/2]) scale([sw, sr]) circle(d = resolution, $fa=360/$shape_facets);
|
||||||
translate([0, ih/2]) scale([sw, sr]) circle(d = resolution);
|
translate([0, ih/2]) scale([sw, sr]) circle(d = resolution, $fa=360/$shape_facets);
|
||||||
}
|
}
|
||||||
square([iw, ih], center=true);
|
square([iw, ih], center=true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
use <../functions.scad>
|
use <../functions.scad>
|
||||||
|
include <../libraries/rounded_rectangle_profile.scad>
|
||||||
|
|
||||||
|
|
||||||
// we do this weird key_shape_type check here because rounded_square uses
|
// 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.
|
// 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]
|
[(-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…
Reference in New Issue