@dropecho/easings 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ This code is licensed under the MIT License:
2
+
3
+ > Copyright (c) 2020: Ben Van Treese
4
+ >
5
+ > Permission is hereby granted, free of charge, to any person obtaining
6
+ > a copy of this software and associated documentation files (the
7
+ > "Software"), to deal in the Software without restriction, including
8
+ > without limitation the rights to use, copy, modify, merge, publish,
9
+ > distribute, sublicense, and/or sell copies of the Software, and to
10
+ > permit persons to whom the Software is furnished to do so, subject to
11
+ > the following conditions:
12
+ >
13
+ > The above copyright notice and this permission notice shall be
14
+ > included in all copies or substantial portions of the Software.
15
+ >
16
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ > EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ > MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ > NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ > LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ > OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ > WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # dropecho.easings
2
+
3
+ A small Haxe library of easing functions (linear transformations) and interpolation
4
+ helpers for games and animation. Compiles to JavaScript and C#.
5
+
6
+ ## Install
7
+
8
+ ```bash
9
+ haxelib install dropecho.easings # Haxe
10
+ npm install @dropecho/easings # JavaScript
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Easing functions take a normalized time `t` in `[0, 1]` and return the eased value,
16
+ also in `[0, 1]`.
17
+
18
+ ### Haxe
19
+
20
+ ```haxe
21
+ import dropecho.Easings;
22
+
23
+ Easings.easeInQuad(0.25); // 0.0625
24
+ Easings.easeOutCubic(0.25); // 0.578125
25
+ Easings.smoothStep(0.5); // 0.5
26
+ Easings.mix(0, 100, 0.25); // 25 (lerp is an alias)
27
+ Easings.rangeMap(0.25, 0, 1, 0, 255); // 63.75
28
+ Easings.rangeMapClamped(5, 0, 1, 0, 255); // 255 (input clamped to the in-range)
29
+ Easings.clamp(value, 0, 1);
30
+ ```
31
+
32
+ ### JavaScript
33
+
34
+ The library is exposed as the `easings` object (CommonJS export, or a global in the browser).
35
+
36
+ ```js
37
+ const { easings } = require("@dropecho/easings");
38
+
39
+ easings.easeInQuad(0.25); // 0.0625
40
+ easings.smoothStep(0.5); // 0.5
41
+ ```
42
+
43
+ ## API
44
+
45
+ | Group | Functions |
46
+ |---|---|
47
+ | Range / interpolation | `clamp`, `rangeMap`, `rangeMapClamped`, `mix`, `lerp` |
48
+ | Ease in (accelerate from 0) | `easeInQuad`, `easeInCubic`, `easeInQuart`, `easeInQuint`, `easeInSine` |
49
+ | Ease out (decelerate to 1) | `easeOutQuad`, `easeOutCubic`, `easeOutQuart`, `easeOutQuint` |
50
+ | Composite / misc | `smoothStep`, `scale` |
51
+
52
+ - **`rangeMap`** extrapolates outside the in-range; **`rangeMapClamped`** pins the result to
53
+ the out-range and handles inverted in-ranges (`inMin > inMax`).
54
+ - **`scale(t, easing)`** returns `t · easing(t)`, a cheap way to sharpen an ease.
55
+
56
+ ## Development
57
+
58
+ ```bash
59
+ npm run build # build JS + C#
60
+ npm test # run the utest suite (via dropecho.testing)
61
+ npm run bench # run the benchmarks
62
+ ```
63
+
64
+ ## License
65
+
66
+ MIT
@@ -0,0 +1,76 @@
1
+ // Generated by Haxe 4.3.4
2
+ (function ($hx_exports, $global) { "use strict";
3
+ class dropecho_Easings {
4
+ static clamp(value,min,max) {
5
+ return Math.min(Math.max(value,min),max);
6
+ }
7
+ static rangeMap(value,inMin,inMax,outMin,outMax) {
8
+ return (value - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;
9
+ }
10
+ static rangeMapClamped(value,inMin,inMax,outMin,outMax) {
11
+ value = inMin > inMax ? Math.min(Math.max(value,inMax),inMin) : Math.min(Math.max(value,inMin),inMax);
12
+ return (value - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;
13
+ }
14
+ static mix(a,b,amount) {
15
+ return (1 - amount) * a + amount * b;
16
+ }
17
+ static lerp(a,b,amount) {
18
+ return (1 - amount) * a + amount * b;
19
+ }
20
+ static easeInQuad(t) {
21
+ return t * t;
22
+ }
23
+ static easeInCubic(t) {
24
+ return t * t * t;
25
+ }
26
+ static easeInQuart(t) {
27
+ return t * t * t * t;
28
+ }
29
+ static easeInQuint(t) {
30
+ return t * t * t * t * t;
31
+ }
32
+ static easeInSine(t) {
33
+ return 1 - Math.cos(t * Math.PI / 2);
34
+ }
35
+ static easeOutQuad(t) {
36
+ let __pow_base = 1 - t;
37
+ return 1 - __pow_base * __pow_base;
38
+ }
39
+ static easeOutCubic(t) {
40
+ let __pow_base = 1 - t;
41
+ return 1 - __pow_base * __pow_base * __pow_base;
42
+ }
43
+ static easeOutQuart(t) {
44
+ let __pow_base = 1 - t;
45
+ return 1 - __pow_base * __pow_base * __pow_base * __pow_base;
46
+ }
47
+ static easeOutQuint(t) {
48
+ let __pow_base = 1 - t;
49
+ return 1 - __pow_base * __pow_base * __pow_base * __pow_base * __pow_base;
50
+ }
51
+ static smoothStep(t) {
52
+ let __pow_base = 1 - t;
53
+ return (1 - t) * (t * t) + t * (1 - __pow_base * __pow_base);
54
+ }
55
+ static scale(t,easing) {
56
+ return t * easing(t);
57
+ }
58
+ }
59
+ $hx_exports["easings"] = dropecho_Easings;
60
+ class dropecho_macros_MathMacros {
61
+ }
62
+ class haxe_iterators_ArrayIterator {
63
+ constructor(array) {
64
+ this.current = 0;
65
+ this.array = array;
66
+ }
67
+ hasNext() {
68
+ return this.current < this.array.length;
69
+ }
70
+ next() {
71
+ return this.array[this.current++];
72
+ }
73
+ }
74
+ {
75
+ }
76
+ })(typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this, {});
@@ -0,0 +1,6 @@
1
+
2
+ /**
3
+ The Std class provides standard methods for manipulating basic types.
4
+ */
5
+ export declare class Std {
6
+ }
@@ -0,0 +1,18 @@
1
+ import {Register} from "./genes/Register.js"
2
+
3
+ /**
4
+ The Std class provides standard methods for manipulating basic types.
5
+ */
6
+ export const Std = Register.global("$hxClasses")["Std"] =
7
+ class Std {
8
+ static get __name__() {
9
+ return "Std"
10
+ }
11
+ get __class__() {
12
+ return Std
13
+ }
14
+ }
15
+
16
+
17
+ ;{
18
+ }
@@ -0,0 +1,57 @@
1
+
2
+ /**
3
+ An `Iterator` is a structure that permits iteration over elements of type `T`.
4
+
5
+ Any class with matching `hasNext()` and `next()` fields is considered an `Iterator`
6
+ and can then be used e.g. in `for`-loops. This makes it easy to implement
7
+ custom iterators.
8
+
9
+ @see https://haxe.org/manual/lf-iterators.html
10
+ */
11
+ export type Iterator<T> = {
12
+ /**
13
+ Returns `false` if the iteration is complete, `true` otherwise.
14
+
15
+ Usually iteration is considered to be complete if all elements of the
16
+ underlying data structure were handled through calls to `next()`. However,
17
+ in custom iterators any logic may be used to determine the completion
18
+ state.
19
+ */
20
+ hasNext: () => boolean,
21
+ /**
22
+ Returns the current item of the `Iterator` and advances to the next one.
23
+
24
+ This method is not required to check `hasNext()` first. A call to this
25
+ method while `hasNext()` is `false` yields unspecified behavior.
26
+
27
+ On the other hand, iterators should not require a call to `hasNext()`
28
+ before the first call to `next()` if an element is available.
29
+ */
30
+ next: () => T
31
+ }
32
+
33
+ /**
34
+ An `Iterable` is a data structure which has an `iterator()` method.
35
+ See `Lambda` for generic functions on iterable structures.
36
+
37
+ @see https://haxe.org/manual/lf-iterators.html
38
+ */
39
+ export type Iterable<T> = {
40
+ iterator: () => Iterator<T>
41
+ }
42
+
43
+ /**
44
+ A `KeyValueIterator` is an `Iterator` that has a key and a value.
45
+ */
46
+ export type KeyValueIterator<K, V> = Iterator<{
47
+ key: K,
48
+ value: V
49
+ }>
50
+
51
+ /**
52
+ A `KeyValueIterable` is a data structure which has a `keyValueIterator()`
53
+ method to iterate over key-value-pairs.
54
+ */
55
+ export type KeyValueIterable<K, V> = {
56
+ keyValueIterator: () => KeyValueIterator<K, V>
57
+ }
@@ -0,0 +1,165 @@
1
+
2
+ /**
3
+ A small collection of easing and interpolation helpers.
4
+
5
+ The easing functions (`easeIn*`, `easeOut*`, `easeInSine`, `smoothStep`) take a
6
+ normalized time `t` in `[0, 1]` and return the eased value, also in `[0, 1]`.
7
+ The range and interpolation helpers (`clamp`, `rangeMap`, `mix`/`lerp`) are
8
+ general-purpose and accept any range.
9
+
10
+ Exposed to JavaScript as the `easings` object via `@:expose`.
11
+ */
12
+ export declare class Easings {
13
+
14
+ /**
15
+ Constrain `value` to the inclusive range `[min, max]`.
16
+
17
+ @param value The value to clamp.
18
+ @param min The lower bound.
19
+ @param max The upper bound.
20
+ @return `value` limited to `[min, max]`.
21
+ */
22
+ static clamp(value: number, min: number, max: number): number
23
+
24
+ /**
25
+ Linearly remap `value` from `[inMin, inMax]` onto `[outMin, outMax]`.
26
+
27
+ The input is not clamped, so values outside the in-range extrapolate beyond
28
+ the out-range. Use `rangeMapClamped` to pin the result to the out-range.
29
+
30
+ @param value The value to remap.
31
+ @param inMin The lower bound of the input range.
32
+ @param inMax The upper bound of the input range.
33
+ @param outMin The lower bound of the output range.
34
+ @param outMax The upper bound of the output range.
35
+ @return `value` mapped onto `[outMin, outMax]`.
36
+ */
37
+ static rangeMap(value: number, inMin: number, inMax: number, outMin: number, outMax: number): number
38
+
39
+ /**
40
+ Like `rangeMap`, but `value` is first clamped to the in-range so the result
41
+ always stays within `[outMin, outMax]`. Inverted in-ranges (`inMin > inMax`)
42
+ are handled.
43
+
44
+ @param value The value to remap.
45
+ @param inMin One bound of the input range.
46
+ @param inMax The other bound of the input range.
47
+ @param outMin The lower bound of the output range.
48
+ @param outMax The upper bound of the output range.
49
+ @return `value` clamped to the in-range and mapped onto `[outMin, outMax]`.
50
+ */
51
+ static rangeMapClamped(value: number, inMin: number, inMax: number, outMin: number, outMax: number): number
52
+
53
+ /**
54
+ Linearly interpolate from `a` to `b` by `amount`.
55
+
56
+ @param a The start value, returned when `amount` is `0`.
57
+ @param b The end value, returned when `amount` is `1`.
58
+ @param amount The interpolation factor, typically in `[0, 1]`.
59
+ @return The interpolated value between `a` and `b`.
60
+ */
61
+ static mix(a: number, b: number, amount: number): number
62
+
63
+ /**
64
+ Alias of `mix`.
65
+
66
+ @param a The start value, returned when `amount` is `0`.
67
+ @param b The end value, returned when `amount` is `1`.
68
+ @param amount The interpolation factor, typically in `[0, 1]`.
69
+ @return The interpolated value between `a` and `b`.
70
+ @see `Easings.mix`
71
+ */
72
+ static lerp(a: number, b: number, amount: number): number
73
+
74
+ /**
75
+ Quadratic ease-in (`t²`): accelerates from `0`.
76
+
77
+ @param t Normalized time in `[0, 1]`.
78
+ @return The eased value in `[0, 1]`.
79
+ */
80
+ static easeInQuad(t: number): number
81
+
82
+ /**
83
+ Cubic ease-in (`t³`): accelerates from `0`.
84
+
85
+ @param t Normalized time in `[0, 1]`.
86
+ @return The eased value in `[0, 1]`.
87
+ */
88
+ static easeInCubic(t: number): number
89
+
90
+ /**
91
+ Quartic ease-in (`t⁴`): accelerates from `0`.
92
+
93
+ @param t Normalized time in `[0, 1]`.
94
+ @return The eased value in `[0, 1]`.
95
+ */
96
+ static easeInQuart(t: number): number
97
+
98
+ /**
99
+ Quintic ease-in (`t⁵`): accelerates from `0`.
100
+
101
+ @param t Normalized time in `[0, 1]`.
102
+ @return The eased value in `[0, 1]`.
103
+ */
104
+ static easeInQuint(t: number): number
105
+
106
+ /**
107
+ Sine ease-in (`1 - cos(t·π/2)`): accelerates gently from `0`.
108
+
109
+ @param t Normalized time in `[0, 1]`.
110
+ @return The eased value in `[0, 1]`.
111
+ */
112
+ static easeInSine(t: number): number
113
+
114
+ /**
115
+ Quadratic ease-out (`1 - (1 - t)²`): decelerates to `1`.
116
+
117
+ @param t Normalized time in `[0, 1]`.
118
+ @return The eased value in `[0, 1]`.
119
+ */
120
+ static easeOutQuad(t: number): number
121
+
122
+ /**
123
+ Cubic ease-out (`1 - (1 - t)³`): decelerates to `1`.
124
+
125
+ @param t Normalized time in `[0, 1]`.
126
+ @return The eased value in `[0, 1]`.
127
+ */
128
+ static easeOutCubic(t: number): number
129
+
130
+ /**
131
+ Quartic ease-out (`1 - (1 - t)⁴`): decelerates to `1`.
132
+
133
+ @param t Normalized time in `[0, 1]`.
134
+ @return The eased value in `[0, 1]`.
135
+ */
136
+ static easeOutQuart(t: number): number
137
+
138
+ /**
139
+ Quintic ease-out (`1 - (1 - t)⁵`): decelerates to `1`.
140
+
141
+ @param t Normalized time in `[0, 1]`.
142
+ @return The eased value in `[0, 1]`.
143
+ */
144
+ static easeOutQuint(t: number): number
145
+
146
+ /**
147
+ Smooth start-and-stop S-curve, blending quadratic ease-in and ease-out.
148
+
149
+ @param t Normalized time in `[0, 1]`.
150
+ @return The eased value in `[0, 1]`.
151
+ */
152
+ static smoothStep(t: number): number
153
+
154
+ /**
155
+ Scale `easing(t)` by the raw time `t`, i.e. `t · easing(t)`.
156
+
157
+ Multiplying by `t` biases the curve toward `0`, a cheap way to sharpen an
158
+ ease-in (e.g. `scale(t, easeInQuad)` behaves like `easeInCubic`).
159
+
160
+ @param t Normalized time in `[0, 1]`.
161
+ @param easing The easing function to apply before scaling.
162
+ @return `t · easing(t)`.
163
+ */
164
+ static scale(t: number, easing: ((arg0: number) => number)): number
165
+ }
@@ -0,0 +1,212 @@
1
+ import {Register} from "../genes/Register.js"
2
+
3
+ /**
4
+ A small collection of easing and interpolation helpers.
5
+
6
+ The easing functions (`easeIn*`, `easeOut*`, `easeInSine`, `smoothStep`) take a
7
+ normalized time `t` in `[0, 1]` and return the eased value, also in `[0, 1]`.
8
+ The range and interpolation helpers (`clamp`, `rangeMap`, `mix`/`lerp`) are
9
+ general-purpose and accept any range.
10
+
11
+ Exposed to JavaScript as the `easings` object via `@:expose`.
12
+ */
13
+ export const Easings = Register.global("$hxClasses")["dropecho.Easings"] =
14
+ class Easings {
15
+
16
+ /**
17
+ Constrain `value` to the inclusive range `[min, max]`.
18
+
19
+ @param value The value to clamp.
20
+ @param min The lower bound.
21
+ @param max The upper bound.
22
+ @return `value` limited to `[min, max]`.
23
+ */
24
+ static clamp(value, min, max) {
25
+ return Math.min(Math.max(value, min), max);
26
+ }
27
+
28
+ /**
29
+ Linearly remap `value` from `[inMin, inMax]` onto `[outMin, outMax]`.
30
+
31
+ The input is not clamped, so values outside the in-range extrapolate beyond
32
+ the out-range. Use `rangeMapClamped` to pin the result to the out-range.
33
+
34
+ @param value The value to remap.
35
+ @param inMin The lower bound of the input range.
36
+ @param inMax The upper bound of the input range.
37
+ @param outMin The lower bound of the output range.
38
+ @param outMax The upper bound of the output range.
39
+ @return `value` mapped onto `[outMin, outMax]`.
40
+ */
41
+ static rangeMap(value, inMin, inMax, outMin, outMax) {
42
+ return (value - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;
43
+ }
44
+
45
+ /**
46
+ Like `rangeMap`, but `value` is first clamped to the in-range so the result
47
+ always stays within `[outMin, outMax]`. Inverted in-ranges (`inMin > inMax`)
48
+ are handled.
49
+
50
+ @param value The value to remap.
51
+ @param inMin One bound of the input range.
52
+ @param inMax The other bound of the input range.
53
+ @param outMin The lower bound of the output range.
54
+ @param outMax The upper bound of the output range.
55
+ @return `value` clamped to the in-range and mapped onto `[outMin, outMax]`.
56
+ */
57
+ static rangeMapClamped(value, inMin, inMax, outMin, outMax) {
58
+ value = (inMin > inMax) ? Math.min(Math.max(value, inMax), inMin) : Math.min(Math.max(value, inMin), inMax);
59
+ return (value - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;
60
+ }
61
+
62
+ /**
63
+ Linearly interpolate from `a` to `b` by `amount`.
64
+
65
+ @param a The start value, returned when `amount` is `0`.
66
+ @param b The end value, returned when `amount` is `1`.
67
+ @param amount The interpolation factor, typically in `[0, 1]`.
68
+ @return The interpolated value between `a` and `b`.
69
+ */
70
+ static mix(a, b, amount) {
71
+ return (1 - amount) * a + amount * b;
72
+ }
73
+
74
+ /**
75
+ Alias of `mix`.
76
+
77
+ @param a The start value, returned when `amount` is `0`.
78
+ @param b The end value, returned when `amount` is `1`.
79
+ @param amount The interpolation factor, typically in `[0, 1]`.
80
+ @return The interpolated value between `a` and `b`.
81
+ @see `Easings.mix`
82
+ */
83
+ static lerp(a, b, amount) {
84
+ return (1 - amount) * a + amount * b;
85
+ }
86
+
87
+ /**
88
+ Quadratic ease-in (`t²`): accelerates from `0`.
89
+
90
+ @param t Normalized time in `[0, 1]`.
91
+ @return The eased value in `[0, 1]`.
92
+ */
93
+ static easeInQuad(t) {
94
+ return t * t;
95
+ }
96
+
97
+ /**
98
+ Cubic ease-in (`t³`): accelerates from `0`.
99
+
100
+ @param t Normalized time in `[0, 1]`.
101
+ @return The eased value in `[0, 1]`.
102
+ */
103
+ static easeInCubic(t) {
104
+ return t * t * t;
105
+ }
106
+
107
+ /**
108
+ Quartic ease-in (`t⁴`): accelerates from `0`.
109
+
110
+ @param t Normalized time in `[0, 1]`.
111
+ @return The eased value in `[0, 1]`.
112
+ */
113
+ static easeInQuart(t) {
114
+ return t * t * t * t;
115
+ }
116
+
117
+ /**
118
+ Quintic ease-in (`t⁵`): accelerates from `0`.
119
+
120
+ @param t Normalized time in `[0, 1]`.
121
+ @return The eased value in `[0, 1]`.
122
+ */
123
+ static easeInQuint(t) {
124
+ return t * t * t * t * t;
125
+ }
126
+
127
+ /**
128
+ Sine ease-in (`1 - cos(t·π/2)`): accelerates gently from `0`.
129
+
130
+ @param t Normalized time in `[0, 1]`.
131
+ @return The eased value in `[0, 1]`.
132
+ */
133
+ static easeInSine(t) {
134
+ return 1 - Math.cos(t * Math.PI / 2);
135
+ }
136
+
137
+ /**
138
+ Quadratic ease-out (`1 - (1 - t)²`): decelerates to `1`.
139
+
140
+ @param t Normalized time in `[0, 1]`.
141
+ @return The eased value in `[0, 1]`.
142
+ */
143
+ static easeOutQuad(t) {
144
+ var __pow_base = 1 - t;
145
+ return 1 - __pow_base * __pow_base;
146
+ }
147
+
148
+ /**
149
+ Cubic ease-out (`1 - (1 - t)³`): decelerates to `1`.
150
+
151
+ @param t Normalized time in `[0, 1]`.
152
+ @return The eased value in `[0, 1]`.
153
+ */
154
+ static easeOutCubic(t) {
155
+ var __pow_base = 1 - t;
156
+ return 1 - __pow_base * __pow_base * __pow_base;
157
+ }
158
+
159
+ /**
160
+ Quartic ease-out (`1 - (1 - t)⁴`): decelerates to `1`.
161
+
162
+ @param t Normalized time in `[0, 1]`.
163
+ @return The eased value in `[0, 1]`.
164
+ */
165
+ static easeOutQuart(t) {
166
+ var __pow_base = 1 - t;
167
+ return 1 - __pow_base * __pow_base * __pow_base * __pow_base;
168
+ }
169
+
170
+ /**
171
+ Quintic ease-out (`1 - (1 - t)⁵`): decelerates to `1`.
172
+
173
+ @param t Normalized time in `[0, 1]`.
174
+ @return The eased value in `[0, 1]`.
175
+ */
176
+ static easeOutQuint(t) {
177
+ var __pow_base = 1 - t;
178
+ return 1 - __pow_base * __pow_base * __pow_base * __pow_base * __pow_base;
179
+ }
180
+
181
+ /**
182
+ Smooth start-and-stop S-curve, blending quadratic ease-in and ease-out.
183
+
184
+ @param t Normalized time in `[0, 1]`.
185
+ @return The eased value in `[0, 1]`.
186
+ */
187
+ static smoothStep(t) {
188
+ var __pow_base = 1 - t;
189
+ return (1 - t) * (t * t) + t * (1 - __pow_base * __pow_base);
190
+ }
191
+
192
+ /**
193
+ Scale `easing(t)` by the raw time `t`, i.e. `t · easing(t)`.
194
+
195
+ Multiplying by `t` biases the curve toward `0`, a cheap way to sharpen an
196
+ ease-in (e.g. `scale(t, easeInQuad)` behaves like `easeInCubic`).
197
+
198
+ @param t Normalized time in `[0, 1]`.
199
+ @param easing The easing function to apply before scaling.
200
+ @return `t · easing(t)`.
201
+ */
202
+ static scale(t, easing) {
203
+ return t * easing(t);
204
+ }
205
+ static get __name__() {
206
+ return "dropecho.Easings"
207
+ }
208
+ get __class__() {
209
+ return Easings
210
+ }
211
+ }
212
+
@@ -0,0 +1,6 @@
1
+
2
+ /**
3
+ Compile-time math helpers implemented as expression macros.
4
+ */
5
+ export declare class MathMacros {
6
+ }
@@ -0,0 +1,15 @@
1
+ import {Register} from "../../genes/Register.js"
2
+
3
+ /**
4
+ Compile-time math helpers implemented as expression macros.
5
+ */
6
+ export const MathMacros = Register.global("$hxClasses")["dropecho.macros.MathMacros"] =
7
+ class MathMacros {
8
+ static get __name__() {
9
+ return "dropecho.macros.MathMacros"
10
+ }
11
+ get __class__() {
12
+ return MathMacros
13
+ }
14
+ }
15
+
@@ -0,0 +1,15 @@
1
+ import {Iterator} from "../StdTypes"
2
+
3
+ export declare class Register {
4
+ static $global: any
5
+ protected static globals: {
6
+ }
7
+ static global(name: number): any
8
+ static createStatic<T>(obj: {
9
+ }, name: string, get: (() => T)): void
10
+ static iter<T>(a: T[]): Iterator<T>
11
+ static extend(superClass: any): void
12
+ static inherits(resolve: any, defer?: boolean): void
13
+ protected static fid: number
14
+ static bind(o: any, m: any): null | any
15
+ }
@@ -0,0 +1,107 @@
1
+
2
+ export class Register {
3
+ static global(name) {
4
+ if (Register.globals[name]) {
5
+ return Register.globals[name];
6
+ } else {
7
+ return Register.globals[name] = {};
8
+ };
9
+ }
10
+ static createStatic(obj, name, get) {
11
+ var value = null;
12
+ Object.defineProperty(obj, name, {"enumerable": true, "get": function () {
13
+ if (get != null) {
14
+ value = get();
15
+ get = null;
16
+ };
17
+ return value;
18
+ }, "set": function (v) {
19
+ if (get != null) {
20
+ value = get();
21
+ get = null;
22
+ };
23
+ value = v;
24
+ }});
25
+ }
26
+ static iter(a) {
27
+ if (!Array.isArray(a)) {
28
+ return a.iterator();
29
+ } else {
30
+ return {"cur": 0, "arr": a, "hasNext": function () {
31
+ return this.cur < this.arr.length;
32
+ }, "next": function () {
33
+ return this.arr[this.cur++];
34
+ }};
35
+ };
36
+ }
37
+ static extend(superClass) {
38
+
39
+ function res() {
40
+ this.new.apply(this, arguments)
41
+ }
42
+ Object.setPrototypeOf(res.prototype, superClass.prototype)
43
+ return res
44
+ ;
45
+ }
46
+ static inherits(resolve, defer) {
47
+ if (defer == null) {
48
+ defer = false;
49
+ };
50
+
51
+ function res() {
52
+ if (defer && resolve && res.__init__) res.__init__()
53
+ this.new.apply(this, arguments)
54
+ }
55
+ if (!defer) {
56
+ if (resolve && resolve.__init__) {
57
+ defer = true
58
+ res.__init__ = () => {
59
+ resolve.__init__()
60
+ Object.setPrototypeOf(res.prototype, resolve.prototype)
61
+ res.__init__ = undefined
62
+ }
63
+ } else if (resolve) {
64
+ Object.setPrototypeOf(res.prototype, resolve.prototype)
65
+ }
66
+ } else {
67
+ res.__init__ = () => {
68
+ const superClass = resolve()
69
+ if (superClass.__init__) superClass.__init__()
70
+ Object.setPrototypeOf(res.prototype, superClass.prototype)
71
+ res.__init__ = undefined
72
+ }
73
+ }
74
+ return res
75
+ ;
76
+ }
77
+ static bind(o, m) {
78
+ if (m == null) {
79
+ return null;
80
+ };
81
+ if (m.__id__ == null) {
82
+ m.__id__ = Register.fid++;
83
+ };
84
+ var f = null;
85
+ if (o.hx__closures__ == null) {
86
+ o.hx__closures__ = {};
87
+ } else {
88
+ f = o.hx__closures__[m.__id__];
89
+ };
90
+ if (f == null) {
91
+ f = m.bind(o);
92
+ o.hx__closures__[m.__id__] = f;
93
+ };
94
+ return f;
95
+ }
96
+ static get __name__() {
97
+ return "genes.Register"
98
+ }
99
+ get __class__() {
100
+ return Register
101
+ }
102
+ }
103
+
104
+
105
+ Register.$global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : undefined
106
+ Register.globals = {}
107
+ Register.fid = 0
@@ -0,0 +1,7 @@
1
+
2
+ export type V8CallSite = {
3
+ getColumnNumber: () => number,
4
+ getFileName: () => string,
5
+ getFunctionName: () => string,
6
+ getLineNumber: () => number
7
+ }
@@ -0,0 +1,2 @@
1
+
2
+ export type NativeRest<T> = T[]
@@ -0,0 +1,11 @@
1
+
2
+ /**
3
+ DEPRECATED: use haxe.Rest instead.
4
+
5
+ A special type that represents "rest" function argument.
6
+ Should be used as a type for the last argument of an extern method,
7
+ representing that arbitrary number of arguments of given type can be
8
+ passed to that method.
9
+ @see <https://haxe.org/manual/lf-externs.html>
10
+ */
11
+ export type Rest<T> = T[]
@@ -0,0 +1,19 @@
1
+
2
+ /**
3
+ This iterator is used only when `Array<T>` is passed to `Iterable<T>`
4
+ */
5
+ export declare class ArrayIterator<T> {
6
+ constructor(array: T[])
7
+ protected array: T[]
8
+ protected current: number
9
+
10
+ /**
11
+ See `Iterator.hasNext`
12
+ */
13
+ hasNext(): boolean
14
+
15
+ /**
16
+ See `Iterator.next`
17
+ */
18
+ next(): T
19
+ }
@@ -0,0 +1,33 @@
1
+ import {Register} from "../../genes/Register.js"
2
+
3
+ /**
4
+ This iterator is used only when `Array<T>` is passed to `Iterable<T>`
5
+ */
6
+ export const ArrayIterator = Register.global("$hxClasses")["haxe.iterators.ArrayIterator"] =
7
+ class ArrayIterator extends Register.inherits() {
8
+ new(array) {
9
+ this.current = 0;
10
+ this.array = array;
11
+ }
12
+
13
+ /**
14
+ See `Iterator.hasNext`
15
+ */
16
+ hasNext() {
17
+ return this.current < this.array.length;
18
+ }
19
+
20
+ /**
21
+ See `Iterator.next`
22
+ */
23
+ next() {
24
+ return this.array[this.current++];
25
+ }
26
+ static get __name__() {
27
+ return "haxe.iterators.ArrayIterator"
28
+ }
29
+ get __class__() {
30
+ return ArrayIterator
31
+ }
32
+ }
33
+
@@ -0,0 +1,2 @@
1
+
2
+ export {Easings} from "./dropecho/Easings"
@@ -0,0 +1,3 @@
1
+ import {Register} from "./genes/Register.js"
2
+
3
+ export {Easings} from "./dropecho/Easings.js"
@@ -0,0 +1,82 @@
1
+
2
+ /**
3
+ Type for
4
+ @see <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object>
5
+ */
6
+ export type ObjectPrototype = {
7
+ /**
8
+ Returns a boolean indicating whether an object contains the specified
9
+ property as a direct property of that object and not inherited through
10
+ the prototype chain.
11
+ */
12
+ hasOwnProperty: Function,
13
+ /**
14
+ Returns a boolean indicating whether the object this method is called
15
+ upon is in the prototype chain of the specified object.
16
+ */
17
+ isPrototypeOf: Function,
18
+ /**
19
+ Returns a boolean indicating if the internal enumerable attribute is set.
20
+ */
21
+ propertyIsEnumerable: Function,
22
+ /**
23
+ Calls `toString()`.
24
+ */
25
+ toLocaleString: Function,
26
+ /**
27
+ Returns a string representation of the object.
28
+ */
29
+ toString: Function,
30
+ /**
31
+ Returns the primitive value of the specified object.
32
+ */
33
+ valueOf: Function
34
+ }
35
+
36
+ /**
37
+ @see <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty>
38
+ */
39
+ export type ObjectPropertyDescriptor = {
40
+ /**
41
+ `true` if and only if the type of this property descriptor may be
42
+ changed and if the property may be deleted from the corresponding object.
43
+
44
+ Defaults to `false`.
45
+ */
46
+ configurable?: null | boolean,
47
+ /**
48
+ `true` if and only if this property shows up during enumeration of the
49
+ properties on the corresponding object.
50
+
51
+ Defaults to `false`.
52
+ */
53
+ enumerable?: null | boolean,
54
+ /**
55
+ A function which serves as a getter for the property, or `undefined` if
56
+ there is no getter. When the property is accessed, this function is
57
+ called without arguments and with `this` set to the object through which
58
+ the property is accessed (this may not be the object on which the
59
+ property is defined due to inheritance).
60
+ The return value will be used as the value of the property.
61
+ */
62
+ get?: null | (() => any),
63
+ /**
64
+ A function which serves as a setter for the property, or undefined if
65
+ there is no setter. When the property is assigned to, this function
66
+ is called with one argument (the value being assigned to the property)
67
+ and with `this` set to the object through which the property is assigned.
68
+ */
69
+ set?: null | ((arg0: any) => void),
70
+ /**
71
+ The value associated with the property.
72
+ Can be any valid JavaScript value (number, object, function, etc).
73
+ */
74
+ value?: null | any,
75
+ /**
76
+ `true` if and only if the value associated with the property may be
77
+ changed with an assignment operator.
78
+
79
+ Defaults to `false`.
80
+ */
81
+ writable?: null | boolean
82
+ }
@@ -0,0 +1,10 @@
1
+
2
+ export type ThenableStruct<T> = {
3
+ then: <TOut>(onFulfilled: null | ((arg0: T) => any), onRejected?: ((arg0: any) => any)) => ThenableStruct<TOut>
4
+ }
5
+
6
+ export type PromiseSettleOutcome<T> = {
7
+ reason?: null | any,
8
+ status: string,
9
+ value?: null | T
10
+ }
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@dropecho/easings",
3
+ "version": "0.1.0",
4
+ "description": "A library of easings (linear transformations).",
5
+ "author": "vantreeseba <vantreeseba@gmail.com>",
6
+ "repository": "github:dropecho/easings",
7
+ "type": "module",
8
+ "main": "./dist/js/cjs/index.cjs",
9
+ "types": "./dist/js/esm/index.d.ts",
10
+ "files": [
11
+ "dist/js/**/*"
12
+ ],
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "license": "MIT",
17
+ "scripts": {
18
+ "prepare": "lix download",
19
+ "build": "npm run clean && haxe build.hxml",
20
+ "test": "lix dropecho.testing",
21
+ "clean": "rm -rf dist artifacts",
22
+ "bench": "haxe test.hxml --main dropecho.testing.AutoTest -D RUN_BENCHMARKS && node artifacts/js_test.cjs"
23
+ },
24
+ "exports": {
25
+ ".": {
26
+ "require": "./dist/js/cjs/index.cjs",
27
+ "import": "./dist/js/esm/index.js"
28
+ }
29
+ },
30
+ "devDependencies": {
31
+ "@semantic-release/changelog": "^6.0.3",
32
+ "@semantic-release/commit-analyzer": "^13.0.1",
33
+ "@semantic-release/exec": "^7.1.0",
34
+ "@semantic-release/git": "^10.0.1",
35
+ "@semantic-release/github": "^12.0.8",
36
+ "@semantic-release/npm": "^13.1.5",
37
+ "@semantic-release/release-notes-generator": "^14.1.1",
38
+ "lix": "^16.0.2",
39
+ "semantic-release": "^25.0.5",
40
+ "semantic-release-haxelib": "^1.1.0"
41
+ }
42
+ }