Add pointlog2svg utility for the thesis
[numtypysics.git] / Canvas.h
blob5f2aaa2cb7051050cf511f6db1664d4b76793a36
1 /*
2 * This file is part of NumptyPhysics
3 * Copyright (C) 2008 Tim Edmonds
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 3 of the
8 * License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
17 #ifndef CANVAS_H
18 #define CANVAS_H
20 #include "Common.h"
21 class Path;
23 class Canvas
25 typedef void* State;
26 public:
27 Canvas( int w, int h );
28 virtual ~Canvas();
29 int width() const;
30 int height() const;
31 int makeColour( int c ) const;
32 int makeColour( int r, int g, int b ) const;
33 void resetClip();
34 void setClip( int x, int y, int w, int h );
35 void setBackground( int c );
36 void setBackground( Canvas* bg );
37 void clear();
38 void clear( const Rect& r );
39 void fade( const Rect& r );
40 Canvas* scale( int factor ) const;
41 void scale( int w, int h );
42 void drawImage( Canvas *canvas, int x, int y );
43 void drawPixel( int x, int y, int c );
44 int readPixel( int x, int y ) const;
45 void drawLine( int x1, int y1, int x2, int y2, int c );
46 void drawPath( const Path& path, int color, bool thick=false );
47 void drawRect( int x, int y, int w, int h, int c, bool fill=true );
48 void drawRect( const Rect& r, int c, bool fill=true );
49 void previewCursor(int cursor_id, int x, int y);
50 int writeBMP( const char* filename ) const;
51 protected:
52 Canvas( State state=NULL );
53 State m_state;
54 int m_bgColour;
55 Canvas* m_bgImage;
56 Rect m_clip;
59 class Window : public Canvas
61 public:
62 Window( int w, int h, const char* title=NULL, const char* winclass=NULL, bool fullscreen=false );
63 void update( const Rect& r );
64 void raise();
65 void setSubName( const char *sub );
69 class Image : public Canvas
71 public:
72 Image( const char* file, bool alpha=false );
76 #endif //CANVAS_H