Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support negative numbers in cubic-bezier(...) function #2667

Conversation

colelawrence
Copy link
Contributor

Required to support ease in back / bounce kinds of easings.

Tested with mutation testing alongside cargo test test-driver-interpreter.

Comment on lines +4 to +10
// Test that cubic-bezier() can accept negative numbers

TestCase := Rectangle {
animate background {
easing: cubic-bezier(0.600, -0.280, 0.735, 0.045); // ease-in-back
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just for the interpreter, so there might be a better place to put this.

@colelawrence colelawrence force-pushed the fix/2023-04/enable-using-negative-numbers-in-cubic-bezier-fn branch from 7319ea2 to a41cb8e Compare May 1, 2023 15:51
@colelawrence
Copy link
Contributor Author

Question if this code over here is relevant @ogoffart for this change, or if everything is going to be fine. I can observe that overshooting works on animations. I just might ben having trouble understanding what this code affects.

pub fn easing_curve(curve: &EasingCurve, value: f32) -> f32 {
match curve {
EasingCurve::Linear => value,
EasingCurve::CubicBezier([a, b, c, d]) => {
if !(0.0..=1.0).contains(a) && !(0.0..=1.0).contains(c) {
return value;
};

@ogoffart
Copy link
Member

ogoffart commented May 2, 2023

Question if this code over here is relevant

In CSS, the first and third number need to be between 0 and 1, but the second an last can be anything.

@ogoffart ogoffart merged commit 95e00c5 into slint-ui:master May 2, 2023
24 checks passed
@ogoffart
Copy link
Member

ogoffart commented May 2, 2023

Thanks for the patch!

@colelawrence colelawrence deleted the fix/2023-04/enable-using-negative-numbers-in-cubic-bezier-fn branch May 2, 2023 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants