mirror of
https://github.com/rsheldiii/KeyV2.git
synced 2024-11-22 21:23:40 +00:00
fix negative top tilt keytop tucking
This commit is contained in:
parent
4b9cb50e48
commit
8557d19b02
@ -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) =
|
||||
|
@ -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]
|
||||
]);
|
||||
|
Loading…
Reference in New Issue
Block a user