-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
field.h
42 lines (34 loc) · 910 Bytes
/
field.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
/*
* GTK Cervi
* vim:set sw=4 sta:
*
* Copyright (C) 2003 Tomas Janousek <tomi@nomi.cz>
* See file COPYRIGHT and COPYING
*/
#ifndef FIELD_H_INCLUDED
#define FIELD_H_INCLUDED
#pragma interface
#include <vector>
namespace std {
class Field {
public:
vector<bool> _b; // bitfield
vector<unsigned char> _l; // lightness of pixels (for antialias)
int width, height;
Field(int _width, int _height) : _b(_width*_height + 1,false),
_l(_width*_height+1,0), width(_width), height(_height) {
_b[_width*_height] = 1;
}
// short for counting bit's index from x and y values
// also does range checking
inline unsigned int pos(int x, int y) {
if (x >= width || y >= height || x < 0 || y < 0) {
return width*height;
}
return y*width + x;
}
};
const int defwidth = 600;
const int defheight = 410;
}
#endif /* FIELD_H_INCLUDED */