friz
An animation control system for JUCE
Loading...
Searching...
No Matches
parametric.h
1/*
2 Copyright (c) 2019-2023 Brett g Porter
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21*/
22
23#pragma once
24
25#include "animatedValue.h"
26
27namespace friz
28{
29
38class Parametric : public TimedValue
39{
40public:
41 // All the curves are generated by a function that accepts a float
42 // between 0..1 (percentage of the curve completion) and returns a
43 // float that's typically between 0..1 (curve position) but may overshoot
44 // that 0..1 range.
45 using CurveFn = std::function<float (float)>;
46
47 enum CurveType
48 {
49 kLinear = 0,
50 kEaseInSine,
51 kEaseOutSine,
52 kEaseInOutSine,
53 kEaseInQuad,
54 kEaseOutQuad,
55 kEaseInOutQuad,
56 kEaseInCubic,
57 kEaseOutCubic,
58 kEaseInOutCubic,
59 kEaseInQuartic,
60 kEaseOutQuartic,
61 kEaseInOutQuartic,
62 kEaseInQuintic,
63 kEaseOutQuintic,
64 kEaseInOutQuintic,
65 kEaseInExpo,
66 kEaseOutExpo,
67 kEaseInOutExpo,
68 kEaseInCirc,
69 kEaseOutCirc,
70 kEaseInOutCirc,
71 kEaseInBack,
72 kEaseOutBack,
73 kEaseInOutBack,
74 kEaseInElastic,
75 kEaseOutElastic,
76 kEaseInOutElastic,
77 kEaseInBounce,
78 kEaseOutBounce,
79 kEaseInOutBounce
80 };
81
92 [[deprecated ("Use ctor with CurveType as last argument")]]
93
94 Parametric (CurveType type, float startVal, float endVal, int duration);
95
106 Parametric (float startVal, float endVal, int duration, CurveType type);
107
113 void SetCurve (CurveFn curve);
114
115private:
116 float generateNextValue (float progress) override;
117
118private:
119 CurveFn curve;
120};
121
122} // namespace friz
A class that can generate different parametric easing curves.
Definition: parametric.h:39
void SetCurve(CurveFn curve)
Set a new curve function for the generator.
Definition: parametric.cpp:273
float generateNextValue(float progress) override
generate the value according to progress in time.
Definition: parametric.cpp:278
Definition: animatedValue.h:194
int duration
duration of the event in ms.
Definition: animatedValue.h:237