Silence App.cpp's debugging output
[numtypysics.git] / Canvas.h
blob40f04bccd116e888da764694ef4993e5aedbed44
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 int writeBMP( const char* filename ) const;
50 protected:
51 Canvas( State state=NULL );
52 State m_state;
53 int m_bgColour;
54 Canvas* m_bgImage;
55 Rect m_clip;
58 class Window : public Canvas
60 public:
61 Window( int w, int h, const char* title=NULL, const char* winclass=NULL, bool fullscreen=false );
62 void update( const Rect& r );
63 void raise();
64 void setSubName( const char *sub );
68 class Image : public Canvas
70 public:
71 Image( const char* file, bool alpha=false );
75 #endif //CANVAS_H