2 // Written and (C) by Francois Fleuret
3 // Contact <francois.fleuret@idiap.ch> for comments & bug reports
22 scalar_t red, green, blue;
28 // We have our own stack of tags to avoid numerous news and deletes
29 Tag *_tag_stack, *_tag_stack_top;
30 scalar_t *_red_imap, *_green_imap, *_blue_imap;
34 inline void protected_push_tag(int x, int y, scalar_t r, scalar_t g, scalar_t b) {
35 if(y >= 0 && y < _height) {
38 else if(x >= _width) { x = _width - 1; }
40 int t = y * _width + x;
42 _tag_stack_top->next = _tag_map[t];
43 _tag_stack_top->index = _current_polygon;
44 _tag_stack_top->red = r;
45 _tag_stack_top->green = g;
46 _tag_stack_top->blue = b;
47 _tag_map[t] = _tag_stack_top;
52 inline void push_tag(int x, int y, scalar_t r, scalar_t g, scalar_t b) {
53 int t = y * _width + x;
54 _tag_stack_top->next = _tag_map[t];
55 _tag_stack_top->index = _current_polygon;
56 _tag_stack_top->red = r;
57 _tag_stack_top->green = g;
58 _tag_stack_top->blue = b;
59 _tag_map[t] = _tag_stack_top;
63 inline scalar_t red_sum(int xmin, int ymin, int xmax, int ymax) {
64 return _red_imap[xmax + (_width + 1) * ymax]
65 + _red_imap[xmin + (_width + 1) * ymin]
66 - _red_imap[xmax + (_width + 1) * ymin]
67 - _red_imap[xmin + (_width + 1) * ymax];
70 inline scalar_t green_sum(int xmin, int ymin, int xmax, int ymax) {
71 return _green_imap[xmax + (_width + 1) * ymax]
72 + _green_imap[xmin + (_width + 1) * ymin]
73 - _green_imap[xmax + (_width + 1) * ymin]
74 - _green_imap[xmin + (_width + 1) * ymax];
77 inline scalar_t blue_sum(int xmin, int ymin, int xmax, int ymax) {
78 return _blue_imap[xmax + (_width + 1) * ymax]
79 + _blue_imap[xmin + (_width + 1) * ymin]
80 - _blue_imap[xmax + (_width + 1) * ymin]
81 - _blue_imap[xmin + (_width + 1) * ymax];
86 void draw_polygon(Polygon *p);
90 Plotter(int width, int height, int scaling);
93 void save_as_ppm(Universe *universe, const char *filename);