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

Add more easing functions #81

Closed
willmcgugan opened this issue Sep 4, 2021 · 15 comments · Fixed by #88
Closed

Add more easing functions #81

willmcgugan opened this issue Sep 4, 2021 · 15 comments · Fixed by #88
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@willmcgugan
Copy link
Collaborator

willmcgugan commented Sep 4, 2021

There are a number of 'easing functions' used by the animation system. At the top of _animator.py you will see the following:

EASING = {
    "none": lambda x: 1.0,
    "round": lambda x: 0.0 if x < 0.5 else 1.0,
    "linear": lambda x: x,
    "in_cubic": lambda x: x * x * x,
    "in_out_cubic": lambda x: 4 * x * x * x if x < 0.5 else 1 - pow(-2 * x + 2, 3) / 2,
    "out_cubic": lambda x: 1 - pow(1 - x, 3),
}

These function have been copied from https://easings.net/ and translated from Javascript to Python. I would like to add the remaining functions to the EASING dict above.

See the animation.py example as a way of testing the above functions.

@willmcgugan willmcgugan added help wanted Extra attention is needed good first issue Good for newcomers labels Sep 4, 2021
@rodrigogiraoserrao
Copy link
Contributor

I'm having a go at this. Some of the easing functions will look ugly as one-line lambdas. I'll use short defs for those and then you'll see how it looks. Does that make sense?

@willmcgugan
Copy link
Collaborator Author

Sounds good! Agree re not always using lambda.

@willmcgugan
Copy link
Collaborator Author

Can you assign yourself to this? Want to avoid more than one person jumping on a task.

@rodrigogiraoserrao
Copy link
Contributor

Can you assign yourself to this? Want to avoid more than one person jumping on a task.

I can't, probably don't have permission to do that? I think you have to assign me?

@willmcgugan
Copy link
Collaborator Author

Ah, I guess I do.

@tusharsadhwani
Copy link
Contributor

oh well, I was already done with this one :p

should've messaged first

@willmcgugan
Copy link
Collaborator Author

@tusharsadhwani Really? That was quick. Do you want to compare notes with @RojerGS ?

@tusharsadhwani
Copy link
Contributor

sure, submitting a patch in 5

@rodrigogiraoserrao
Copy link
Contributor

Go ahead and open a PR, I'm currently AFK.

@github-actions
Copy link

github-actions bot commented Sep 5, 2021

Did I solve your problem?

Consider sponsoring my work on Textual with a monthly donation.

Or buy me a coffee to say thanks.

Will McGugan

@willmcgugan
Copy link
Collaborator Author

No need for a donation! ;-)

@rodrigogiraoserrao
Copy link
Contributor

Did I solve your problem? Consider buying me a coffee 🤣

That GH action is a nice addition! To prevent you from adding too many "no donation needed" replies, maybe you'll want to have it not trigger when the issue was opened by you? Just a random thought. Maybe leave it be...

@willmcgugan
Copy link
Collaborator Author

I owe you a ☕

@tusharsadhwani
Copy link
Contributor

@RojerGS if you don't already have one, you should set up a ko-fi account, it's free and they take no commission.

@rodrigogiraoserrao
Copy link
Contributor

I have a Buy Me a Coffee account (associated with my blog) where people can buy me a slice of pizza, maybe I'll move it to ko-fi...

But I do not want Will's coffee for this contribution, and I will refund it if needed 🤣

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants