| 26 | AnimationOptions::~AnimationOptions() = default; |
| 27 | |
| 28 | Ref<ValueMap> AnimationOptions::toValueMap() const { |
| 29 | auto out = makeShared<ValueMap>(); |
| 30 | |
| 31 | static auto linear = STRING_LITERAL("linear"); |
| 32 | static auto easeIn = STRING_LITERAL("easeIn"); |
| 33 | static auto easeOut = STRING_LITERAL("easeOut"); |
| 34 | static auto easeInOut = STRING_LITERAL("easeInOut"); |
| 35 | |
| 36 | auto typeStr = linear; |
| 37 | switch (type) { |
| 38 | case snap::valdi_core::AnimationType::Linear: |
| 39 | typeStr = linear; |
| 40 | break; |
| 41 | case snap::valdi_core::AnimationType::EaseIn: |
| 42 | typeStr = easeIn; |
| 43 | break; |
| 44 | case snap::valdi_core::AnimationType::EaseOut: |
| 45 | typeStr = easeOut; |
| 46 | break; |
| 47 | case snap::valdi_core::AnimationType::EaseInOut: |
| 48 | typeStr = easeInOut; |
| 49 | break; |
| 50 | } |
| 51 | |
| 52 | auto outControlPoints = ValueArray::make(controlPoints.size()); |
| 53 | |
| 54 | size_t controlPointsIndex = 0; |
| 55 | for (const auto& controlPoint : controlPoints) { |
| 56 | outControlPoints->emplace(controlPointsIndex++, Value(controlPoint)); |
| 57 | } |
| 58 | |
| 59 | static auto type = STRING_LITERAL("type"); |
| 60 | static auto duration = STRING_LITERAL("duration"); |
| 61 | static auto controlPoints = STRING_LITERAL("controlPoints"); |
| 62 | static auto beginFromCurrentState = STRING_LITERAL("beginFromCurrentState"); |
| 63 | static auto crossfade = STRING_LITERAL("crossfade"); |
| 64 | static auto completion = STRING_LITERAL("completion"); |
| 65 | static auto stiffness = STRING_LITERAL("stiffness"); |
| 66 | static auto damping = STRING_LITERAL("damping"); |
| 67 | |
| 68 | out->try_emplace(type, typeStr); |
| 69 | out->try_emplace(duration, this->duration); |
| 70 | out->try_emplace(controlPoints, outControlPoints); |
| 71 | out->try_emplace(beginFromCurrentState, this->beginFromCurrentState); |
| 72 | out->try_emplace(crossfade, this->crossfade); |
| 73 | out->try_emplace(completion, completionCallback); |
| 74 | out->try_emplace(stiffness, this->stiffness); |
| 75 | out->try_emplace(damping, this->damping); |
| 76 | |
| 77 | return out; |
| 78 | } |
| 79 | |
| 80 | } // namespace Valdi |