2020-10-26 23:03:12 +01:00
|
|
|
//
|
|
|
|
// RectSaver.cpp
|
|
|
|
// screensaver
|
|
|
|
//
|
|
|
|
// Created by Bob Polis at 2020-10-26
|
|
|
|
// Copyright (c) 2020 SwiftCoder. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "RectSaver.hpp"
|
2020-10-27 17:20:23 +01:00
|
|
|
#include <libscscreensaver.hpp>
|
|
|
|
|
|
|
|
class RectSaver : public ScreensaverPlugin {
|
|
|
|
public:
|
|
|
|
RectSaver() = default;
|
|
|
|
~RectSaver() = default;
|
|
|
|
|
|
|
|
int fps() const override;
|
2020-11-15 13:16:49 +01:00
|
|
|
void update() override;
|
|
|
|
void render() override;
|
2020-10-27 17:20:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
ScreensaverPlugin* create_instance() {
|
|
|
|
return new RectSaver;
|
|
|
|
}
|
2020-10-26 23:03:12 +01:00
|
|
|
|
2020-10-27 15:28:26 +01:00
|
|
|
int RectSaver::fps() const {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2020-11-15 13:16:49 +01:00
|
|
|
void RectSaver::update() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void RectSaver::render() {
|
2020-11-24 14:50:19 +01:00
|
|
|
cairo_set_source_rgba(_c, random01(), random01(), random01(), random01());
|
2020-10-26 23:03:12 +01:00
|
|
|
cairo_rectangle_t rect {random_rect()};
|
|
|
|
cairo_rectangle(_c, rect.x, rect.y, rect.width, rect.height);
|
|
|
|
cairo_fill(_c);
|
|
|
|
}
|