mirror of
https://github.com/rsheldiii/KeyV2.git
synced 2025-05-16 10:56:16 +00:00
flat-sided keycaps
make square_shape and rounded_square_shape use trapezoids as their top surface, perfectly shaped so that the sides of the keycap are flat, and can be used as a printing surface
This commit is contained in:
parent
ed1b8841fb
commit
4b9cb50e48
2 changed files with 30 additions and 20 deletions
src/shapes
|
@ -1,26 +1,20 @@
|
|||
include <../libraries/rounded_rectangle_profile.scad>
|
||||
|
||||
module rounded_square_shape(size, delta, progress, center = true) {
|
||||
width = size[0];
|
||||
height = size[1];
|
||||
offset(r=$corner_radius){
|
||||
square_shape([size.x - $corner_radius*2, size.y - $corner_radius*2], delta, progress);
|
||||
}
|
||||
}
|
||||
|
||||
width_difference = delta[0];
|
||||
height_difference = delta[1];
|
||||
|
||||
// computed values for this slice
|
||||
extra_width_this_slice = (width_difference) * progress;
|
||||
extra_height_this_slice = (height_difference) * progress;
|
||||
extra_corner_radius_this_slice = ($corner_radius);
|
||||
|
||||
offset(r=extra_corner_radius_this_slice){
|
||||
square(
|
||||
[
|
||||
width - extra_width_this_slice - extra_corner_radius_this_slice * 2,
|
||||
height - extra_height_this_slice - extra_corner_radius_this_slice * 2
|
||||
],
|
||||
center=center
|
||||
);
|
||||
}
|
||||
module square_shape(size, delta, progress) {
|
||||
alpha = sin($top_tilt) * (top_total_key_height() - $corner_radius * 2) * 0.5;
|
||||
gamma = ($width_difference * alpha) / ($total_depth+alpha);
|
||||
polygon(points=[
|
||||
[-size.x /2 + delta.x * progress/2 , -size.y / 2 + delta.y * progress/2],
|
||||
[size.x / 2 - delta.x * progress/2,-size.y / 2 + delta.y * progress/2],
|
||||
[size.x / 2 - delta.x * progress/2 + gamma * progress, size.y / 2 - delta.y * progress/2],
|
||||
[-size.x / 2 + delta.x * progress/2 - gamma * progress, size.y / 2 - delta.y * progress/2]
|
||||
]);
|
||||
}
|
||||
|
||||
// for skin
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
module square_shape(size, delta, progress){
|
||||
module square_shape_old(size, delta, progress){
|
||||
square(size - delta * progress, center = true);
|
||||
}
|
||||
/*
|
||||
[-size.x /2,-size.y / 2],
|
||||
[size.x / 2,-size.y / 2],
|
||||
[size.x / 2, size.y / 2],
|
||||
[-size.x / 2, size.y / 2] */
|
||||
|
||||
module square_shape(size, delta, progress) {
|
||||
alpha = sin($top_tilt) * (top_total_key_height() - $corner_radius * 2) * 0.5;
|
||||
gamma = ($width_difference * alpha) / ($total_depth+alpha);
|
||||
polygon(points=[
|
||||
[-size.x /2 + delta.x * progress/2 , -size.y / 2 + delta.y * progress/2],
|
||||
[size.x / 2 - delta.x * progress/2,-size.y / 2 + delta.y * progress/2],
|
||||
[size.x / 2 - delta.x * progress/2 + gamma * progress, size.y / 2 - delta.y * progress/2],
|
||||
[-size.x / 2 + delta.x * progress/2 - gamma * progress, size.y / 2 - delta.y * progress/2]
|
||||
]);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue