added concrete screensaver

This commit is contained in:
Bob Polis 2020-10-26 23:03:12 +01:00
parent 751d079225
commit c52d223f39
2 changed files with 47 additions and 0 deletions

24
RectSaver.cpp Normal file
View File

@ -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;
}

23
RectSaver.hpp Normal file
View File

@ -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_