#include "Flashlight.h" #include "../Static.h" Flashlight::Flashlight() : Figment("Flashlight", Task::Stopped) { m_blobs.forEach([](Blob &blob) { blob.setHue(random(255)); blob.setSaturation(10); blob.setPos(random(255)); if (random(255) >= 128) { blob.setVelocity(-1); } }); } void Flashlight::handleEvent(const InputEvent& evt) { if (evt.intent == InputEvent::Acceleration) { if (evt.asInt() > 10) { m_blobs.forEach([](Blob& blob) {blob.update();}); } } } void Flashlight::loop() { m_blobs.update(); } void Flashlight::render(Display* dpy) const { m_blobs.render(dpy); Surface(dpy, {0, 0}, {255, 0}) |= 100; } STATIC_ALLOC(Flashlight); STATIC_TASK(Flashlight);