JD2022-TU1/main/extern/Hue/examples/StreamTest/RGBSineEffect.cpp

49 lines
No EOL
2 KiB
C++

/*******************************************************************************
Copyright © 2017 Philips Lighting Holding B.V.
All Rights Reserved.
********************************************************************************/
#include <huestream/effect/animation/data/Playables/PlayableConstant.h>
#include <huestream/effect/animation/data/Playables/PlayableSequence.h>
#include <huestream/effect/animation/data/Playables/PlayableTween.h>
#include "RGBSineEffect.h"
namespace huestream {
RGBSineEffect::RGBSineEffect(const string &name, unsigned int priority) : LightSourceEffect(name, priority) {}
void RGBSineEffect::PrepareEffect(std::shared_ptr<PlayableConstant> speedAnimation, std::shared_ptr<PlayableConstant> alphaAnimation) {
auto time = 1000;
auto maxBrightness = 1;
auto g = std::make_shared<PlayableSequence>(INF);
auto r = std::make_shared<PlayableSequence>(INF);
auto b = std::make_shared<PlayableSequence>(INF);
auto rampUp = std::make_shared<PlayableTween>(0, maxBrightness, time, TweenType::EaseInOutSine);
auto rampDown = std::make_shared<PlayableTween>(maxBrightness, 0, time, TweenType::EaseInOutSine);
auto off = std::make_shared<PlayableTween>(0, 0, 2*time, TweenType::Linear);
g->Append(rampUp, "UpGreenA");
g->Append(rampDown, "DownGreenA");
r->Append(off, "OffRedA");
b->Append(off, "OffBlueA");
g->Append(off, "OffGreenB");
r->Append(rampUp, "UpRedB");
r->Append(rampDown, "DownRedB");
b->Append(off, "OffBlueB");
g->Append(off, "OffGreenC");
r->Append(off, "OffRedC");
b->Append(rampUp, "UpBlueC");
b->Append(rampDown, "DownBlueC");
SetColorAnimation(r, g, b);
SetOpacityAnimation(alphaAnimation);
auto radius = std::make_shared<PlayableConstant>(10);
SetRadiusAnimation(radius);
SetSpeedAnimation(speedAnimation);
}
}