From c52d223f3984b69942e9fb4f6db7f6f3e87063ed Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Mon, 26 Oct 2020 23:03:12 +0100 Subject: [PATCH] added concrete screensaver --- RectSaver.cpp | 24 ++++++++++++++++++++++++ RectSaver.hpp | 23 +++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 RectSaver.cpp create mode 100644 RectSaver.hpp 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_