diff --git a/RectSaver.cpp b/RectSaver.cpp new file mode 100644 index 0000000..70874ec --- /dev/null +++ b/RectSaver.cpp @@ -0,0 +1,24 @@ +// +// RectSaver.cpp +// screensaver +// +// Created by Bob Polis at 2020-10-26 +// Copyright (c) 2020 SwiftCoder. All rights reserved. +// + +#include "RectSaver.hpp" + +RectSaver::RectSaver(cairo_t* context, const cairo_rectangle_t& rect) : ScreensaverPlugin {context, rect} { + make_black(); +} + +void RectSaver::draw_frame() { + cairo_set_source_rgb(_c, random01(), random01(), random01()); + cairo_rectangle_t rect {random_rect()}; + cairo_rectangle(_c, rect.x, rect.y, rect.width, rect.height); + cairo_fill(_c); +} + +int RectSaver::fps() const { + return 5; +} diff --git a/RectSaver.hpp b/RectSaver.hpp new file mode 100644 index 0000000..712099d --- /dev/null +++ b/RectSaver.hpp @@ -0,0 +1,23 @@ +// +// RectSaver.hpp +// screensaver +// +// Created by Bob Polis at 2020-10-26 +// Copyright (c) 2020 SwiftCoder. All rights reserved. +// + +#ifndef _RectSaver_H_ +#define _RectSaver_H_ + +#include "ScreensaverPlugin.hpp" + +class RectSaver : public ScreensaverPlugin { + public: + RectSaver(cairo_t* context, const cairo_rectangle_t& rect); + ~RectSaver() = default; + + void draw_frame() override; + int fps() const override; +}; + +#endif // _RectSaver_H_