-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrianglescene.h
More file actions
executable file
·56 lines (41 loc) · 1.43 KB
/
trianglescene.h
File metadata and controls
executable file
·56 lines (41 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef SCENE_H
#define SCENE_H
#include "poly.h"
#include <QVector>
#include <QDataStream>
#include <QColor>
#include <QPair>
#include "abstractscene.h"
class QImage;
class QPicture;
/** A scene defines a collection of triangles used to create a single image */
class TriangleScene : public AbstractScene
{
public:
/// randomly initialise a scene with a set number of triangles, a set size and background colour
TriangleScene( int polyCount, int width, int height, const QColor &backgroundColor );
/// copy from another scene
TriangleScene( const TriangleScene &other );
virtual ~TriangleScene();
/// cross-breeds this scene with another one
virtual QPair< AbstractScene*, AbstractScene* > breed( AbstractScene *other, int mutationStrength );
// rendering methods
virtual bool renderTo( QImage &image );
void drawTo( QPicture &image );
void drawTo( QPainter &image );
virtual void saveToFile( const QString &fn );
virtual void randomise();
virtual AbstractScene *clone() const;
/// dumps the scene to a datastream for later processing
virtual void saveToStream( QDataStream &stream );
/// loads the scene from a datastream for later processing
virtual void loadFromStream( QDataStream &stream );
protected:
virtual void mutateOnce();
private:
QVector< Poly* > m_polys;
QColor m_backgroundColor;
int m_width;
int m_height;
};
#endif //SCENE_H