fix negative top tilt keytop tucking

This commit is contained in:
Bob 2020-03-21 13:45:49 -04:00
parent 4b9cb50e48
commit 8557d19b02
2 changed files with 8 additions and 14 deletions

View File

@ -6,17 +6,6 @@ module rounded_square_shape(size, delta, progress, center = true) {
}
}
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
function skin_rounded_square(size, delta, progress) =

View File

@ -8,11 +8,16 @@ module square_shape_old(size, delta, progress){
[-size.x / 2, size.y / 2] */
module square_shape(size, delta, progress) {
// vertical inclination due to top tilt
alpha = sin($top_tilt) * (top_total_key_height() - $corner_radius * 2) * 0.5;
gamma = ($width_difference * alpha) / ($total_depth+alpha);
// how much we have to tuck in the top and bottom of the keytop to make the sides parallel
gamma = min((($width_difference * alpha) / ($total_depth+alpha)), 0);
nega_gamma = max((($width_difference * alpha) / ($total_depth-alpha)), 0);
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 + nega_gamma * progress , -size.y / 2 + delta.y * progress/2],
[size.x / 2 - delta.x * progress/2 - nega_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],
[-size.x / 2 + delta.x * progress/2 - gamma * progress, size.y / 2 - delta.y * progress/2]
]);