libscscreensaver/ScreensaverPlugin.hpp
2020-10-27 13:39:55 +01:00

40 lines
977 B
C++

//
// ScreensaverPlugin.hpp
// screensaver
//
// Created by Bob Polis at 2020-10-26
// Copyright (c) 2020 SwiftCoder. All rights reserved.
//
#ifndef _ScreensaverPlugin_H_
#define _ScreensaverPlugin_H_
#include <cairo/cairo.h>
#include <random>
class ScreensaverPlugin {
public:
ScreensaverPlugin(cairo_t* context, const cairo_rectangle_t& rect);
virtual ~ScreensaverPlugin() = default;
virtual void draw_frame() = 0;
virtual int fps() const = 0;
protected:
cairo_t* _c;
cairo_rectangle_t _r;
std::random_device _dev;
std::default_random_engine _eng {_dev()};
std::uniform_real_distribution<> _01_dist {};
std::uniform_real_distribution<> _x_dist;
std::uniform_real_distribution<> _y_dist;
void make_black();
cairo_rectangle_t random_rect();
double random_x();
double random_y();
double random01();
};
#endif // _ScreensaverPlugin_H_