73 lines
No EOL
3 KiB
C++
73 lines
No EOL
3 KiB
C++
/*******************************************************************************
|
|
Copyright © 2017 Philips Lighting Holding B.V.
|
|
All Rights Reserved.
|
|
********************************************************************************/
|
|
|
|
#include <huestream/config/HueConfig.h>
|
|
#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 "LightpointMarqueeEffect.h"
|
|
namespace huestream {
|
|
|
|
LightpointMarqueeEffect::LightpointMarqueeEffect(const string &name, unsigned int priority) : LightSourceEffect(name, priority) {}
|
|
|
|
void LightpointMarqueeEffect::PrepareEffect(std::shared_ptr<PlayableConstant> speedAnimation, std::shared_ptr<PlayableConstant> alphaAnimation) {
|
|
|
|
auto time = 250;
|
|
auto maxBrightness = 0.5;
|
|
|
|
auto g = std::make_shared<PlayableSequence>(INF);
|
|
auto r = std::make_shared<PlayableSequence>(INF);
|
|
auto b = std::make_shared<PlayableSequence>(INF);
|
|
|
|
auto rampUpGreena = std::make_shared<PlayableTween>(0, maxBrightness, time, TweenType::Linear);
|
|
g->Append(rampUpGreena, "UpGreen");
|
|
|
|
auto rampDownGreena = std::make_shared<PlayableTween>(maxBrightness, 0, time, TweenType::Linear);
|
|
g->Append(rampDownGreena, "DownGreen");
|
|
|
|
auto rampUpReda = std::make_shared<PlayableTween>(0, maxBrightness, time, TweenType::Linear);
|
|
r->Append(rampUpReda, "UpRed");
|
|
|
|
auto rampDownReda = std::make_shared<PlayableTween>(maxBrightness, 0, time, TweenType::Linear);
|
|
r->Append(rampDownReda, "DownRed");
|
|
|
|
auto rampUpBluea = std::make_shared<PlayableTween>(0, maxBrightness, time, TweenType::Linear);
|
|
b->Append(rampUpBluea, "UpRed");
|
|
|
|
auto rampDownBluea = std::make_shared<PlayableTween>(maxBrightness, 0, time, TweenType::Linear);
|
|
b->Append(rampDownBluea, "DownBlue");
|
|
|
|
|
|
SetColorAnimation(r, g, b);
|
|
SetOpacityAnimation(alphaAnimation);
|
|
auto radius = std::make_shared<PlayableConstant>(.1);
|
|
SetRadiusAnimation(radius);
|
|
|
|
//Position aninmation per light
|
|
auto config = huestream::HueConfig::GetInstance();
|
|
auto engine = config->GetEngine();
|
|
auto group = engine->GetGroup();
|
|
auto lights = group->GetLights();
|
|
|
|
auto x = std::make_shared<PlayableSequence>(INF);
|
|
auto y = std::make_shared<PlayableSequence>(INF);
|
|
|
|
for (auto light : *lights) {
|
|
auto pos = light->GetPosition();
|
|
auto posX = pos.GetX();
|
|
auto posY = pos.GetY();
|
|
auto id = light->GetId();
|
|
|
|
auto timesOnOneLight = 3;
|
|
auto timePos = time * 2 * timesOnOneLight;
|
|
|
|
x->Append(std::make_shared<PlayableTween>(posX, posX, timePos, TweenType::Linear), "PosXLight" + id);
|
|
y->Append(std::make_shared<PlayableTween>(posY, posY, timePos, TweenType::Linear), "PosYLight" + id);
|
|
}
|
|
SetPositionAnimation(x, y);
|
|
SetSpeedAnimation(speedAnimation);
|
|
}
|
|
|
|
} |