EASING.BI 0.6 [updated June 17th 2024]

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
Post Reply
Velatus
Posts: 86
Joined: Mar 21, 2009 23:43
Location: France

EASING.BI 0.6 [updated June 17th 2024]

Post by Velatus »

Hi everyone.

I've just posted a little easing library on GitHub. It can be found here: https://github.com/guillaumerangheard/easing.bi.
It contains two classes. The first one (which is more of a type alias, really) is easing.equation. It's basically a function that takes a double and returns another double. All the classics are here: circular, cubic, exponential, linear (of course), quadratic, quartic, quintic, sine and smooth(er)step easing. The second class, easing.curve, emulates CSS's cubic-bezier. It takes four numbers (as doubles) : x1, y1, x2, and y2, corresponding to the curve's second and third keypoints (as the other two are implicit). Once you've created your curve, just call its .compute method (which takes a double and returns a double, and voilà.
Any and all feedback, criticism, and/or suggestion is of course welcome. :-)
I believe the code is self-explanatory, but here's a little example:

Code: Select all

#include "easing/easing.bi"

using easing

print !"easing.equation:\n"
for i as double => 0d to 10d
	print i, cubicInOut(i / 10d)
next i

print !"\neasing.curve:\n"
dim as curve c => curve(0d, .42d, .58d, 1d)
for i as double => 0d to 10d
	print i, c.compute(i / 10d)
next i

sleep
Last edited by Velatus on Jun 17, 2024 10:00, edited 4 times in total.
hhr
Posts: 223
Joined: Nov 29, 2019 10:41

Re: An easing library for FreeBASIC

Post by hhr »

In easing.bi I have added an underscore to line 4.
Velatus
Posts: 86
Joined: Mar 21, 2009 23:43
Location: France

Re: An easing library for FreeBASIC

Post by Velatus »

Thanks hhr! I just did as well.
Velatus
Posts: 86
Joined: Mar 21, 2009 23:43
Location: France

Re: easing.bi - an easing library for FreeBASIC

Post by Velatus »

Hi everyone.

Just a quick post to tell you that I just wrote a little manual for easing.bi.
Also, as for the next version, and for the sake of flexibility, I was planning to add the option to switch to single precision. How does that sound?

Cheers,

V.
Velatus
Posts: 86
Joined: Mar 21, 2009 23:43
Location: France

Re: [v0.5, updated June 12th 2024] easing.bi - an easing library for FreeBASIC

Post by Velatus »

Hi everyone.

I just posted an update. easing.curve's can now be exported to CSS and JSON (see https://github.com/guillaumerangheard/e ... /README.md).

Have a nice day. :-)

V.
Velatus
Posts: 86
Joined: Mar 21, 2009 23:43
Location: France

Re: EASING.BI 0.6 [updated June 17th 2024]

Post by Velatus »

Hi everyone.

I just updated easing.bi.
I refactored some of the code in the previous version, and added easing.back, easing.bounce, and easing.elastic.
I also added clamping to every function to make sure that t is always in the [0,1] range.

Have a nice day. :-)
Post Reply