Skip to content

Commit de143ce

Browse files
authored
Ease center (Makuna#238)
* New Center Ease methods * New Version
1 parent 61d917b commit de143ce

File tree

4 files changed

+97
-2
lines changed

4 files changed

+97
-2
lines changed

keywords.txt

+7
Original file line numberDiff line numberDiff line change
@@ -146,24 +146,31 @@ setTimeScale KEYWORD2
146146
QuadraticIn KEYWORD2
147147
QuadraticOut KEYWORD2
148148
QuadraticInOut KEYWORD2
149+
QuadraticCenter KEYWORD2
149150
CubicIn KEYWORD2
150151
CubicOut KEYWORD2
151152
CubicInOut KEYWORD2
153+
CubicCenter KEYWORD2
152154
QuarticIn KEYWORD2
153155
QuarticOut KEYWORD2
154156
QuarticInOut KEYWORD2
157+
QuarticCenter KEYWORD2
155158
QuinticIn KEYWORD2
156159
QuinticOut KEYWORD2
157160
QuinticInOut KEYWORD2
161+
QuinticCenter KEYWORD2
158162
SinusoidalIn KEYWORD2
159163
SinusoidalOut KEYWORD2
160164
SinusoidalInOut KEYWORD2
165+
SinusoidalCenter KEYWORD2
161166
ExponentialIn KEYWORD2
162167
ExponentialOut KEYWORD2
163168
ExponentialInOut KEYWORD2
169+
ExponentialCenter KEYWORD2
164170
CircularIn KEYWORD2
165171
CircularOut KEYWORD2
166172
CircularInOut KEYWORD2
173+
CircularCenter KEYWORD2
167174
Gamma KEYWORD2
168175
Map KEYWORD2
169176
MapProbe KEYWORD2

library.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"type": "git",
99
"url": "https://github.com/Makuna/NeoPixelBus"
1010
},
11-
"version": "2.3.4",
11+
"version": "2.3.5",
1212
"frameworks": "arduino",
1313
"platforms": "*"
1414
}

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=NeoPixelBus by Makuna
2-
version=2.3.4
2+
version=2.3.5
33
author=Michael C. Miller ([email protected])
44
maintainer=Michael C. Miller ([email protected])
55
sentence=A library that makes controlling NeoPixels (WS2811, WS2812, WS2813 & SK6812) and DotStars (APA102) easy.

src/internal/NeoEase.h

+88
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ class NeoEase
7171
}
7272
}
7373

74+
static float QuadraticCenter(float unitValue)
75+
{
76+
unitValue *= 2.0f;
77+
if (unitValue < 1.0f)
78+
{
79+
return (-0.5f * (unitValue * unitValue - 2.0f));
80+
}
81+
else
82+
{
83+
unitValue -= 1.0f;
84+
return (0.5f * (unitValue * unitValue + 1.0f));
85+
}
86+
}
87+
7488
static float CubicIn(float unitValue)
7589
{
7690
return (unitValue * unitValue * unitValue);
@@ -96,6 +110,13 @@ class NeoEase
96110
}
97111
}
98112

113+
static float CubicCenter(float unitValue)
114+
{
115+
unitValue *= 2.0f;
116+
unitValue -= 1.0f;
117+
return (0.5f * (unitValue * unitValue * unitValue) + 1);
118+
}
119+
99120
static float QuarticIn(float unitValue)
100121
{
101122
return (unitValue * unitValue * unitValue * unitValue);
@@ -121,6 +142,20 @@ class NeoEase
121142
}
122143
}
123144

145+
static float QuarticCenter(float unitValue)
146+
{
147+
unitValue *= 2.0f;
148+
unitValue -= 1.0f;
149+
if (unitValue < 0.0f)
150+
{
151+
return (-0.5f * (unitValue * unitValue * unitValue * unitValue - 1.0f));
152+
}
153+
else
154+
{
155+
return (0.5f * (unitValue * unitValue * unitValue * unitValue + 1.0f));
156+
}
157+
}
158+
124159
static float QuinticIn(float unitValue)
125160
{
126161
return (unitValue * unitValue * unitValue * unitValue * unitValue);
@@ -146,6 +181,13 @@ class NeoEase
146181
}
147182
}
148183

184+
static float QuinticCenter(float unitValue)
185+
{
186+
unitValue *= 2.0f;
187+
unitValue -= 1.0f;
188+
return (0.5f * (unitValue * unitValue * unitValue * unitValue * unitValue + 1.0f));
189+
}
190+
149191
static float SinusoidalIn(float unitValue)
150192
{
151193
return (-cos(unitValue * HALF_PI) + 1.0f);
@@ -161,6 +203,19 @@ class NeoEase
161203
return -0.5 * (cos(PI * unitValue) - 1.0f);
162204
}
163205

206+
static float SinusoidalCenter(float unitValue)
207+
{
208+
if (unitValue < 0.5f)
209+
{
210+
return (0.5 * sin(PI * unitValue));
211+
}
212+
else
213+
{
214+
return (-0.5 * (cos(PI * (unitValue-0.5f)) + 1.0f));
215+
}
216+
217+
}
218+
164219
static float ExponentialIn(float unitValue)
165220
{
166221
return (pow(2, 10.0f * (unitValue - 1.0f)));
@@ -185,6 +240,20 @@ class NeoEase
185240
}
186241
}
187242

243+
static float ExponentialCenter(float unitValue)
244+
{
245+
unitValue *= 2.0f;
246+
if (unitValue < 1.0f)
247+
{
248+
return (0.5f * (-pow(2, -10.0f * unitValue) + 1.0f));
249+
}
250+
else
251+
{
252+
unitValue -= 2.0f;
253+
return (0.5f * (pow(2, 10.0f * unitValue) + 1.0f));
254+
}
255+
}
256+
188257
static float CircularIn(float unitValue)
189258
{
190259
if (unitValue == 1.0f)
@@ -217,6 +286,25 @@ class NeoEase
217286
}
218287
}
219288

289+
static float CircularCenter(float unitValue)
290+
{
291+
unitValue *= 2.0f;
292+
unitValue -= 1.0f;
293+
if (unitValue == 0.0f)
294+
{
295+
return 1.0f;
296+
}
297+
else if (unitValue < 0.0f)
298+
{
299+
return (0.5f * sqrt(1.0f - unitValue * unitValue));
300+
}
301+
else
302+
{
303+
unitValue -= 2.0f;
304+
return (-0.5f * (sqrt(1.0f - unitValue * unitValue) - 1.0f ) + 0.5f);
305+
}
306+
}
307+
220308
static float Gamma(float unitValue)
221309
{
222310
return pow(unitValue, 1.0f / 0.45f);

0 commit comments

Comments
 (0)