// // Huey.cpp // screensaver // // Created by Bob Polis at 2020-10-26 // Copyright (c) 2020 SwiftCoder. All rights reserved. // #include "Huey.hpp" #include class Huey : public ScreensaverPlugin { public: Huey() = default; ~Huey() = default; int fps() const override; void draw_frame() override; private: double _hue {0}; }; ScreensaverPlugin* create_instance() { return new Huey; } int Huey::fps() const { return 40; } void Huey::draw_frame() { // next color HSB hsb; hsb.h = _hue; hsb.s = 1.0; hsb.b = 0.4; // convert to rgb Color color {hsb}; RGB rgb {RGB(color)}; // setup color, fill whole window cairo_set_source_rgb(_c, rgb.r, rgb.g, rgb.b); cairo_rectangle(_c, _r.x, _r.y, _r.width, _r.height); cairo_fill(_c); // update for next frame _hue += 0.5; if (_hue > 360.0) { _hue -= 360.0; } }