Skip to content

Commit e546985

Browse files
committed
first commit
0 parents  commit e546985

39 files changed

+411
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.DS_Store
2+
npm-debug.log
3+
node_modules

.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
test.*
2+
.gitignore
3+
.DS_Store
4+
npm-debug.log

LICENSE.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
This software is released under the MIT license:
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
this software and associated documentation files (the "Software"), to deal in
5+
the Software without restriction, including without limitation the rights to
6+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7+
the Software, and to permit persons to whom the Software is furnished to do so,
8+
subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# glsl-easings [![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)
2+
3+
[Robert Penner's easing functions](http://www.robertpenner.com/easing/) in GLSL,
4+
available as a module for [glslify](http://github.com/chrisdickinson/glslify).
5+
6+
I tried as best I could to make them speedy for GLSL, but I'm sure there are a
7+
lot of gaps to fill – pull requests welcome!
8+
9+
## Usage
10+
11+
[![NPM](https://nodei.co/npm/glsl-easings.png)](https://nodei.co/npm/glsl-easings/)
12+
13+
Each easing function has its own file which can be required from glslify:
14+
15+
``` glsl
16+
#pragma glslify: ease = require(glsl-easings/back-in-out)
17+
#pragma glslify: ease = require(glsl-easings/back-in)
18+
#pragma glslify: ease = require(glsl-easings/back-out)
19+
#pragma glslify: ease = require(glsl-easings/bounce-in-out)
20+
#pragma glslify: ease = require(glsl-easings/bounce-in)
21+
#pragma glslify: ease = require(glsl-easings/bounce-out)
22+
#pragma glslify: ease = require(glsl-easings/circular-in-out)
23+
#pragma glslify: ease = require(glsl-easings/circular-in)
24+
#pragma glslify: ease = require(glsl-easings/circular-out)
25+
#pragma glslify: ease = require(glsl-easings/cubic-in-out)
26+
#pragma glslify: ease = require(glsl-easings/cubic-in)
27+
#pragma glslify: ease = require(glsl-easings/cubic-out)
28+
#pragma glslify: ease = require(glsl-easings/elastic-in-out)
29+
#pragma glslify: ease = require(glsl-easings/elastic-in)
30+
#pragma glslify: ease = require(glsl-easings/elastic-out)
31+
#pragma glslify: ease = require(glsl-easings/exponential-in-out)
32+
#pragma glslify: ease = require(glsl-easings/exponential-in)
33+
#pragma glslify: ease = require(glsl-easings/exponential-out)
34+
#pragma glslify: ease = require(glsl-easings/linear)
35+
#pragma glslify: ease = require(glsl-easings/quadratic-in-out)
36+
#pragma glslify: ease = require(glsl-easings/quadratic-in)
37+
#pragma glslify: ease = require(glsl-easings/quadratic-out)
38+
#pragma glslify: ease = require(glsl-easings/quartic-in-out)
39+
#pragma glslify: ease = require(glsl-easings/quartic-in)
40+
#pragma glslify: ease = require(glsl-easings/quartic-out)
41+
#pragma glslify: ease = require(glsl-easings/quintic-in-out)
42+
#pragma glslify: ease = require(glsl-easings/quintic-in)
43+
#pragma glslify: ease = require(glsl-easings/quintic-out)
44+
#pragma glslify: ease = require(glsl-easings/sine-in-out)
45+
#pragma glslify: ease = require(glsl-easings/sine-in)
46+
#pragma glslify: ease = require(glsl-easings/sine-out)
47+
```
48+
49+
And each function has the following signature:
50+
51+
``` glsl
52+
float ease(float t)
53+
```
54+
55+
Where `t` is a value between 0 and 1, returning a new float between 0 and 1.
56+
57+
## License
58+
59+
MIT. See [LICENSE.md](http://github.com/hughsk/glsl-easings/blob/master/LICENSE.md) for details.

back-in-out.glsl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef PI
2+
#define PI 3.141592653589793
3+
#endif
4+
5+
float backOut(float t) {
6+
float f = t < 0.5
7+
? 2.0 * t
8+
: 1.0 - (2.0 * t - 1.0);
9+
10+
float g = pow(f, 3.0) - f * sin(f * PI);
11+
12+
return t < 0.5
13+
? 0.5 * g
14+
: 0.5 * (1.0 - g) + 0.5;
15+
}
16+
17+
#pragma glslify: export(backOut)

back-in.glsl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef PI
2+
#define PI 3.141592653589793
3+
#endif
4+
5+
float backIn(float t) {
6+
return pow(t, 3.0) - t * sin(t * PI);
7+
}
8+
9+
#pragma glslify: export(backIn)

back-out.glsl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef PI
2+
#define PI 3.141592653589793
3+
#endif
4+
5+
float backOut(float t) {
6+
float f = 1.0 - t;
7+
return 1.0 - (pow(f, 3.0) - f * sin(f * PI));
8+
}
9+
10+
#pragma glslify: export(backOut)

bounce-in-out.glsl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma glslify: bounceOut = require(./bounce-out)
2+
3+
float bounceInOut(float t) {
4+
return t < 0.5
5+
? 0.5 * (1.0 - bounceOut(1.0 - t * 2.0))
6+
: 0.5 * bounceOut(t * 2.0 - 1.0) + 0.5;
7+
}
8+
9+
10+
11+
#pragma glslify: export(bounceInOut)

bounce-in.glsl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma glslify: bounceOut = require(./bounce-out)
2+
3+
float bounceIn(float t) {
4+
return 1.0 - bounceOut(1.0 - t);
5+
}
6+
7+
#pragma glslify: export(bounceIn)

bounce-out.glsl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#ifndef PI
2+
#define PI 3.141592653589793
3+
#endif
4+
5+
float bounceOut(float t) {
6+
const float a = 4.0 / 11.0;
7+
const float b = 8.0 / 11.0;
8+
const float c = 9.0 / 10.0;
9+
10+
const float ca = 4356.0 / 361.0;
11+
const float cb = 35442.0 / 1805.0;
12+
const float cc = 16061.0 / 1805.0;
13+
14+
float t2 = t * t;
15+
16+
return t < a
17+
? 7.5625 * t2
18+
: t < b
19+
? 9.075 * t2 - 9.9 * t + 3.4
20+
: t < c
21+
? ca * t2 - cb * t + cc
22+
: 10.8 * t * t - 20.52 * t + 10.72;
23+
}
24+
25+
#pragma glslify: export(bounceOut)

0 commit comments

Comments
 (0)