00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef HEADER_CONSTRUO_GRAPHIC_CONTEXT_HXX
00021 #define HEADER_CONSTRUO_GRAPHIC_CONTEXT_HXX
00022
00023 #include <string>
00024 #include <vector>
00025 #include "math.hxx"
00026 #include "vector2d.hxx"
00027 #include "color.hxx"
00028
00030 class GraphicContext
00031 {
00032 private:
00033 public:
00034 struct Line
00035 {
00036 float x1, y1;
00037 float x2, y2;
00038 };
00039
00040 struct Circle
00041 {
00042 float x, y, r;
00043 };
00044
00045 void draw_circle(const Vector2d& pos, float radius, Color color)
00046 {
00047 draw_circle (pos.x, pos.y, radius, color);
00048 }
00049
00050 void draw_fill_circle(const Vector2d& pos, float radius, Color color)
00051 {
00052 draw_fill_circle (pos.x, pos.y, radius, color);
00053 }
00054
00055 void draw_string(const Vector2d& pos, const std::string& str, Color color = Color (0xFFFFFFFF))
00056 {
00057 draw_string (pos.x, pos.y, str, color);
00058 }
00059
00060 void draw_line (const Vector2d& pos1, const Vector2d& pos2, Color color, int wide = 0)
00061 {
00062 draw_line (pos1.x, pos1.y, pos2.x, pos2.y, color, wide);
00063 }
00064
00065 void draw_rect (const Vector2d& pos1, const Vector2d& pos2, Color color)
00066 {
00067 draw_rect (Math::min(pos1.x, pos2.x),
00068 Math::min(pos1.y, pos2.y),
00069 Math::max(pos1.x, pos2.x),
00070 Math::max(pos1.y, pos2.y),
00071 color);
00072 }
00073
00074 void draw_fill_rect (const Vector2d& pos1, const Vector2d& pos2, Color color)
00075 {
00076 draw_fill_rect (pos1.x, pos1.y, pos2.x, pos2.y, color);
00077 }
00078
00079 virtual void draw_lines (std::vector<Line>& lines, Color color, int wide = 0) =0;
00080 virtual void draw_line(float x1, float y1, float x2, float y2, Color color, int wide = 0) =0;
00081 virtual void draw_rect(float x1, float y1, float x2, float y2, Color color) =0;
00082 virtual void draw_circle(float x, float y, float radius, Color color) =0;
00083 virtual void draw_circles(std::vector<Circle>& circles, Color color) =0;
00084 virtual void draw_fill_circle(float x, float y, float radius, Color color) =0;
00085 virtual void draw_fill_rect(float x1, float y1, float x2, float y2, Color color) =0;
00086 virtual void draw_string(float x, float y, const std::string& str, Color color = Color (0xFFFFFFFF)) =0;
00087
00088 virtual void draw_string_centered(float x, float y, const std::string& str, Color color = Color (0xFFFFFFFF)) =0;
00089
00090 virtual void set_clip_rect (int x1_, int y1_, int x2_, int y2_) =0;
00091
00092 virtual int get_width () =0;
00093 virtual int get_height () =0;
00094
00095 virtual void clear () =0;
00096
00098 virtual void flip () =0;
00099 virtual void real_flip () {}
00100 virtual void flip (int x1, int y1, int x2, int y2) =0;
00101 };
00102
00103 #endif
00104
00105