-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblueprint.h
100 lines (96 loc) · 2.88 KB
/
blueprint.h
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#ifndef BLUEPRINT_H
#define BLUEPRINT_H
#include <QObject>
#include <QColor>
#include <QImage>
#include <QMap>
class Blueprint : public QObject {
Q_OBJECT
public:
using Ink = QColor;
static const Ink Cross;
static const Ink Tunnel;
static const Ink Mesh;
static const Ink Bus1;
static const Ink Bus2;
static const Ink Bus3;
static const Ink Bus4;
static const Ink Bus5;
static const Ink Bus6;
static const Ink Write;
static const Ink Read;
static const Ink Trace1;
static const Ink Trace2;
static const Ink Trace3;
static const Ink Trace4;
static const Ink Trace5;
static const Ink Trace6;
static const Ink Trace7;
static const Ink Trace8;
static const Ink Trace9;
static const Ink Trace10;
static const Ink Trace11;
static const Ink Trace12;
static const Ink Trace13;
static const Ink Trace14;
static const Ink Trace15;
static const Ink Trace16;
static const Ink Buffer;
static const Ink And;
static const Ink Or;
static const Ink Nor;
static const Ink Not;
static const Ink Nand;
static const Ink Xor;
static const Ink Xnor;
static const Ink LatchOn;
static const Ink LatchOff;
static const Ink Clock;
static const Ink LED;
static const Ink Timer;
static const Ink Random;
static const Ink Break;
static const Ink Wifi0;
static const Ink Wifi1;
static const Ink Wifi2;
static const Ink Wifi3;
static const Ink Annotation;
static const Ink Filler;
static const Ink Empty;
static const Ink Invalid;
enum Layer {
Logic = 0,
DecoOn = 1,
DecoOff = 2
};
explicit Blueprint (QString bpString, QObject *parent = nullptr);
Blueprint (QImage bpImage, Layer layer, QObject *parent = nullptr);
Blueprint (int width, int height, QObject *parent = nullptr);
QImage layer (Layer which) const { return layers_[which]; }
void setPixel (Layer which, int x, int y, Ink ink);
void set (int x, int y, Ink ink) { setPixel(Logic, x, y, ink); }
QString bpString () const;
int width () const { return layers_.first().width(); }
int height () const { return layers_.first().height(); }
Ink getPixel (Layer which, int x, int y) const;
Ink get (int x, int y) const { return getPixel(Logic, x, y); }
// utilities
QString toDiscordEmoji () const;
private:
mutable QString bpString_;
QMap<Layer,QImage> layers_;
void generateBlueprintString () const;
};
inline bool operator < (const Blueprint::Ink &a, const Blueprint::Ink &b) {
if (a.red() != b.red())
return a.red() < b.red();
else if (a.green() != b.green())
return a.green() < b.green();
else if (a.blue() != b.blue())
return a.blue() < b.blue();
else if (a.alpha() != b.alpha())
return a.alpha() < b.alpha();
else
return false;
}
#endif // BLUEPRINT_H