Switch colorized shapes by default.
[flatland.git] / canvas_cairo.h
1
2 /*
3
4    flatland is a simple 2d physical simulator
5
6    Copyright (c) 2016 Idiap Research Institute, http://www.idiap.ch/
7    Written by Francois Fleuret <francois.fleuret@idiap.ch>
8
9    This file is part of flatland
10
11    flatland is free software: you can redistribute it and/or modify it
12    under the terms of the GNU General Public License version 3 as
13    published by the Free Software Foundation.
14
15    flatland is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with flatland.  If not, see <http://www.gnu.org/licenses/>.
22
23 */
24
25 #ifndef CANVAS_CAIRO_H
26 #define CANVAS_CAIRO_H
27
28 #include "canvas.h"
29
30 #include <stdio.h>
31 #include <cairo.h>
32
33 class CanvasCairo : public Canvas {
34   scalar_t _scale;
35   cairo_surface_t *_image;
36   cairo_t *_context_resource;
37
38 public:
39   const static int _depth = 4;
40   int _actual_width, _actual_height;
41   unsigned char *_data;
42
43   CanvasCairo(scalar_t scale, int nb_rows, int nb_cols, CanvasCairo **ca);
44   CanvasCairo(scalar_t scale, int width, int height);
45   CanvasCairo(int nb_rows, int nb_cols, CanvasCairo **x);
46
47   virtual ~CanvasCairo();
48
49   virtual void clear();
50   virtual void set_line_width(scalar_t w);
51   virtual void set_drawing_color(scalar_t r, scalar_t g, scalar_t b);
52   virtual void draw_polygon(int filled, int nb, scalar_t *x, scalar_t *y);
53   virtual void write_png(FILE *file);
54 };
55
56 #endif