libscscreensaver/ScreensaverPlugin.hpp

39 lines
876 B
C++
Raw Normal View History

2020-10-27 13:39:55 +01:00
//
// 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() = default;
2020-10-27 13:39:55 +01:00
virtual ~ScreensaverPlugin() = default;
virtual void setup(cairo_t* context, const cairo_rectangle_t& rect);
virtual int fps() const;
2020-10-27 13:39:55 +01:00
virtual void draw_frame() = 0;
protected:
cairo_t* _c {nullptr};
cairo_rectangle_t _r {};
std::random_device _dev {};
2020-10-27 13:39:55 +01:00
std::default_random_engine _eng {_dev()};
void make_black();
cairo_rectangle_t random_rect();
double random_x();
double random_y();
double random01();
};
#endif // _ScreensaverPlugin_H_