-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathlayer.h
More file actions
62 lines (53 loc) · 1.3 KB
/
layer.h
File metadata and controls
62 lines (53 loc) · 1.3 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
57
58
59
60
61
62
#ifndef LAYER_H
#define LAYER_H
#include <string>
enum eFlags
{
Dirty = 1 << 0,
};
typedef unsigned char byte;
class Layer
{
public:
Layer();
std::string _name;
int _flags = 0;
bool _visible = true;
bool isVisible() const { return _visible; }
void toggleVisibility()
{
_visible = !_visible;
setDirty();
}
void setDirty() { _flags |= Dirty; }
int dataSize() const;
void setSize(int size[2]);
void setSize(int w, int h);
void setSize(int size[2], const byte pixel[]);
void setSize(int w, int h, const byte pixel[]);
template <int N>
const byte *pixel(int x, int y) const
{
int position = y * _size[1] + x;
return &this->_data[position * N];
}
template <int N>
void setPixel(int x, int y, const byte pixel[])
{
int position = y * _size[1] + x;
for (int b = 0; b < N; b++)
{
this->_data[position * N + b] = pixel[b];
}
}
float _alpha = 1.0f;
int _alphaMode = 0;
int _offset[2] = {0, 0};
int _size[2] = {0, 0};
int _bpp = 4;
unsigned char *_data = nullptr;
static Layer *defaultLayer(int size[2], const byte pixel[]);
static Layer *fromFile(const char *filename);
static void overwrite(Layer *a, Layer *b);
};
#endif // LAYER_H