GrAPiC
Graphics for Algo/Prog in C/C++
Grapic.h
Go to the documentation of this file.
1 /****************************************************************************
2 Copyright (C) 2010-2020 Alexandre Meyer
3 
4 This file is part of Grapic.
5 
6 Grapic is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10 
11 Grapic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with Grapic. If not, see <http://www.gnu.org/licenses/>.
18 *****************************************************************************/
19 
20 #ifndef GRAPIC_H
21 #define GRAPIC_H
22 
24 
25 #include <cassert>
26 #include <iostream>
27 #include <cstdlib>
28 #include <cstdio>
29 #include <vector>
30 #include <cmath>
31 #include <cassert>
32 #include <iostream>
33 #include <cstdlib>
34 #include <cstdio>
35 #include <thread>
36 #include <chrono>
37 #include <vector>
38 #include <algorithm>
39 
40 #include <SDL.h>
41 #include <SDL_ttf.h>
42 #include <SDL_image.h>
43 
45 
46 
47 namespace grapic
48 {
49 
51 
52 
53 
55 
66 class Grapic
67 {
68 public:
69  Grapic();
70  void init(const char* name, int w, int h, int posx=-1, int posy=-1, SDL_WindowFlags flag = SDL_WindowFlags(0), std::string render_driver="");
71  bool manageEvent();
72 
73  void clear();
74  void clearEvent();
75  bool display();
76  void quit();
77  void color(unsigned char r, unsigned char g, unsigned char b, unsigned char a=255);
78  void colorf(float r, float g, float b, float a=1.f);
79  SDL_Color& getColor();
80  SDL_Color& getBackgroundColor();
81  void backgroundColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a=255);
82  void backgroundColorf(float r, float g, float b, float a=1.f);
83  int inverseY(int y);
84  void setFont(int s, const char* ttf=NULL);
85  int keyHasBeenPressed(unsigned int sc);
86  void setKeyRepeatMode(bool kr);
87  int getFontSize();
88  void qToQuit(bool enable);
89  float framesPerSecond();
90  unsigned int lastFrameTime();
91 
92  const SDL_Window* window() const { return m_window; }
93  SDL_Window* window() { return m_window; }
94  SDL_Renderer * renderer() { return m_renderer; }
95  const SDL_Renderer * renderer() const { return m_renderer; }
96  TTF_Font* font() { return m_font; }
97  const TTF_Font* font() const { return m_font; }
98  bool hasFinished() const { return m_quit; }
99  bool isInit() const { return m_window; }
100  Uint32 textureFormat() const { return m_textureFormat; }
101  int winDimX() const { return m_width; }
102  int winDimY() const { return m_height; }
103 
104  static Grapic& singleton(bool secure=true);
105 
106 protected:
107  int m_width;
108  int m_height;
109  SDL_Window* m_window;
110  SDL_Renderer *m_renderer;
111  SDL_RendererInfo m_renderInfo;
112  Uint32 m_textureFormat;
113  TTF_Font *m_font;
114  std::string m_fontFile;
115  int m_fontSize;
116  bool m_quit;
117  bool m_anim;
118  bool press_q_quit;
119  SDL_Color m_currentColor;
120  SDL_Color m_backgroundColor;
121  std::vector<int> m_keyStates;
122  bool m_keyRepeatMode;
123  int imagesSavedCount;
124 
125  // vars used for framerate calculation
126  unsigned int m_frameTime[60];
127  float m_averageFramePerSecond;
128  unsigned int m_lastTime;
129  unsigned int m_frameNumber;
130  unsigned long m_frameSum;
131 
132  void initKeyArray();
133  void help() const;
134  bool manageOneEvent(SDL_Event event);
135 
136  void initFrameCounter();
137  void updateFrameCounter();
138 
139  static Grapic* currentGrapic;
140  friend void winInit(const char* name, int w, int h, int posx, int posy);
141  friend void winQuit();
142 };
143 
144 
145 
146 
147 class Image
148 {
149 public:
150  Image();
151  Image(const char* filename, bool transparency, unsigned char r, unsigned char g, unsigned b, unsigned char a);
152  Image(const Image& im);
153  Image(int w, int h);
154  ~Image();
155 
156  Image& operator=(const Image& im);
157 
158  void copy(const Image& im);
159  void savePNG(const char* filename) const;
160  bool isInit() const;
161  unsigned char get(int x, int y, int c) const;
162  void set(int x, int y, unsigned char r, unsigned char g, unsigned b, unsigned char a);
163  void printInfo() const;
164 
165  const SDL_Surface* surface() const;
166 
167  void draw(int x, int y, int w, int h);
168  void draw(int x, int y, int w, int h, float angle, int flip);
169 
170 protected:
171  SDL_Surface* m_surface;
172  SDL_Texture* m_texture;
173  bool* m_has_changed;
174  int* nb_instance;
175 
176  void init(int w, int h);
177  void destroy();
178 };
179 
180 
181 
182 
183 
184 class Menu
185 {
186 public:
187  Menu();
188  void change(int i, const std::string& str);
189  int select() const;
190  void setSelect(int s);
191  int caseToPixel(int c, int ymin, int ymax) const;
192  void draw(int xmin, int ymin, int xmax, int ymax);
193  void add(const std::string& str);
194  bool has_changed();
195 
196 protected:
197  std::vector<std::string> m_txt;
198  int m_select;
199  bool m_has_changed;
200  bool m_visible;
201 };
202 
203 
204 
205 typedef std::vector< std::pair<float,float> > Curve;
206 class Plot
207 {
208 public:
209  Plot();
210  void clear();
211  void setSize(const int n);
212  void add(float x, float y, int curve_n);
213  void draw(int xmin, int ymin, int xmax, int ymax, bool clearOrNot) const;
214  void draw( const Curve& cu, int xmin, int ymin, int xmax, int ymax, float fxmin, float fymin, float fxmax, float fymax) const;
215  void minMax(float& fxmin, float& fymin, float& fxmax, float& fymax, int& maxsize) const;
216 
217 protected:
218  std::vector< Curve > m_dat;
219  int m_nb_plot_max;
220 };
221 
222 
223 
225 
226 
227 
228 
229 
230 
231 //==================================================================================================
232 //==================================================================================================
233 //==================================================================================================
234 //============================= GRAPIC FUNCTIONS ===================================================
235 //==================================================================================================
236 //==================================================================================================
237 //==================================================================================================
238 
239 
240 
241 
245 inline void winInit(const char* name, int w, int h, int posx=-1, int posy=-1)
246 {
247  Grapic::currentGrapic = new Grapic();
248  Grapic::singleton(false).init(name,w,h,posx,posy);
249 }
250 
262 inline void winClear()
263 {
264  grapic::Grapic::singleton().clear();
265 }
266 
269 inline bool winHasFinished()
270 {
271  return Grapic::singleton().hasFinished();
272 }
273 
276 inline void winClearEvent()
277 {
278  grapic::Grapic::singleton().clearEvent();
279 }
280 
284 void winSetPosition(int w, int h, int ps, int py, bool fullscreen);
285 
286 
300 inline bool winDisplay()
301 {
302  return Grapic::singleton().display();
303 }
304 
307 inline void winQuit()
308 {
309  Grapic::singleton().quit();
310  if (Grapic::currentGrapic)
311  {
312  delete Grapic::currentGrapic;
313  Grapic::currentGrapic = nullptr;
314  }
315 }
316 
319 inline void savePerformanceMode(bool reduceFPS)
320 {
321  SDL_GL_SetSwapInterval(reduceFPS);
322 }
323 
326 inline float framesPerSecond()
327 {
328  return Grapic::singleton().framesPerSecond();
329 }
330 
334 inline unsigned int lastFrameTime()
335 {
336  return Grapic::singleton().lastFrameTime();
337 }
338 
341 inline void color(unsigned char _r = 255, unsigned char _g = 255, unsigned char _b = 255, unsigned char _a = 255)
342 {
343  Grapic::singleton().color( _r, _g, _b, _a );
344 }
345 
348 inline void colorf(float _r = 1.f, float _g = 1.f, float _b = 1.f, float _a = 1.f)
349 {
350  Grapic::singleton().colorf( _r, _g, _b, _a );
351 }
352 
355 inline void backgroundColor(unsigned char _r = 255, unsigned char _g = 255, unsigned char _b = 255, unsigned char _a = 255)
356 {
357  Grapic::singleton().backgroundColor( _r, _g, _b, _a);
358 }
359 
362 inline void backgroundColorf(float _r = 1.f, float _g = 1.f, float _b = 1.f, float _a = 1.f)
363 {
364  Grapic::singleton().backgroundColorf( _r, _g, _b, _a);
365 }
366 
369 void circle(int xc, int yc, int radius);
370 
373 void circleFill(int xc, int yc, int radius);
374 
377 void ellipse(int xc, int yc, int horizontal, int vertical);
378 
381 void ellipseFill(int xc, int yc, int horizontal, int vertical);
382 
385 void rectangle(int xmin, int ymin, int xmax, int ymax);
386 
389 void rectangleFill(int xmin, int ymin, int xmax, int ymax);
390 
393 inline void line(int x1, int y1, int x2, int y2)
394 {
395  Grapic& g = Grapic::singleton();
396  SDL_RenderDrawLine( g.renderer(), x1, g.inverseY(y1), x2, g.inverseY(y2));
397 }
398 
401 void put_pixel(int x, int y, unsigned char r, unsigned char g, unsigned char b, unsigned char a=255);
402 
405 inline void point(int x, int y)
406 {
407  Grapic& g = Grapic::singleton();
408  SDL_RenderDrawPoint( g.renderer(), x, g.inverseY(y));
409 }
410 
413 inline void points(int p[][2], int n)
414 {
415  Grapic& g = Grapic::singleton();
416  SDL_RenderDrawPoints( g.renderer(), ((const SDL_Point*)(p)), n);
417 }
418 
421 void grid(int xmin, int ymin, int xmax, int ymax, int nx, int ny);
422 
425 inline int irand(int rmin=0, int rmax=100)
426 {
427  return rmin + rand() % (rmax - rmin + 1);
428 }
429 
432 inline float frand(float rmin = 0.f, float rmax = 1.f)
433 {
434  float r = static_cast<float>(rand()) / RAND_MAX;
435  return rmin + r * (rmax - rmin);
436 }
437 
440 inline float elapsedTime()
441 {
442  return 0.001f * SDL_GetTicks();
443 }
444 
453 inline int isKeyPressed(int key)
454 {
455  Grapic& g = Grapic::singleton();
456  return (g.keyHasBeenPressed(key)); // || (state[key]>0) );
457 }
458 
459 
462 inline void setKeyRepeatMode(bool repeat)
463 {
464  Grapic& g = Grapic::singleton();
465  g.setKeyRepeatMode(repeat);
466 }
467 
468 
476 inline void delay(int d)
477 {
478  SDL_Delay(d);
479 }
480 
486 inline bool isMousePressed(int button)
487 {
488  return SDL_GetMouseState(nullptr, nullptr) & SDL_BUTTON(button);
489 }
490 
498 void mousePos(int& x, int& y);
499 
507 void mousePosGlobal(int& x, int& y);
508 
509 
512 inline bool winManageEvent()
513 {
514  return Grapic::singleton().manageEvent();
515 }
516 
519 inline void fontSize(int s)
520 {
521  Grapic::singleton().setFont(s);
522 }
523 
526 inline void selectFont(const char* path)
527 {
528  Grapic::singleton().setFont(Grapic::singleton().getFontSize(), path);
529 }
530 
537 void print(int x, int y, const char* txt);
538 
544 inline void print(int x, int y, int nb)
545 {
546  char txt[64];
547  sprintf(txt,"%d", nb);
548  print(x,y,txt);
549 }
550 
551 
557 inline void print(int x, int y, float nb)
558 {
559  char txt[64];
560  sprintf(txt,"%.2f", nb);
561  print(x,y,txt);
562 }
563 
566 void pressSpace(bool isPrint=true);
567 
568 
569 
570 
587 inline Image image(const char* filename, bool transparency=false, unsigned char r=255, unsigned char g=255, unsigned b=255, unsigned char a=255)
588 {
589  return Image(filename, transparency, r, g, b, a);
590 }
591 
592 
595 inline Image image(int w, int h)
596 {
597  return Image(w,h);
598 }
599 
602 Image image_copy(const Image& im);
603 
606 inline void image_savePNG(const Image& im, const char* filename)
607 {
608  im.savePNG(filename);
609 }
610 
613 inline void image_draw(Image& im, int x, int y, int w=-1, int h=-1)
614 {
615  im.draw(x,y,w,h);
616 }
617 
620 inline void image_draw(Image& im, int x, int y, int w, int h, float angle, float flip=SDL_FLIP_NONE)
621 {
622  im.draw(x,y,w,h,angle,flip);
623 }
624 
628 inline unsigned char image_get(const Image& im, int x, int y, int c=0)
629 {
630  return im.get(x,y,c);
631 }
632 
635 void image_set(Image& im, int x, int y, unsigned char r, unsigned char g, unsigned b, unsigned char a);
636 
637 
640 inline int image_width(const Image& im)
641 {
642  return im.surface()->w;
643 }
644 
645 
648 inline int image_height(const Image& im)
649 {
650  return im.surface()->h;
651 }
652 
660 inline bool image_isInit(const Image& im)
661 {
662  return im.isInit();
663 }
664 
667 inline void image_printInfo(const Image& im)
668 {
669  im.printInfo();
670 }
671 
672 
694 inline void menu_add(Menu& m, const std::string& str)
695 {
696  m.add(str);
697 }
698 
699 
701 inline void menu_change(Menu& m, int i, const std::string& str)
702 {
703  m.change(i,str);
704 }
705 
707 //
708 // This functions returns the newly selected item only once per change.
709 // Therefore, it can be used to perform 'in-loop' initialization.
710 inline int menu_has_changed(Menu& m)
711 {
712  if (m.has_changed())
713  {
714  return m.select();
715  }
716  // Invalid item
717  return -1;
718 }
719 
721 inline void menu_draw(Menu& m, int xmin=5, int ymin=5, int xmax=-1, int ymax=-1)
722 {
723  m.draw(xmin,ymin,xmax,ymax);
724 }
725 
727 inline int menu_select(const Menu& m)
728 {
729  return m.select();
730 }
731 
733 inline void menu_setSelect(Menu& m, int s)
734 {
735  m.setSelect(s);
736 }
737 
739 inline int caseToPixel(const Menu& m, int c, int ymin, int ymax)
740 {
741  return m.caseToPixel(c,ymin,ymax);
742 }
743 
746 
748 inline void plot_clear(Plot& p )
749 {
750  p.clear();
751 }
752 
754 inline void plot_setSize(Plot& p, const int n)
755 {
756  p.setSize(n);
757 }
758 
760 inline void plot_add(Plot& p, float x, float y, int curve_n=0)
761 {
762  p.add(x,y,curve_n);
763 }
764 
766 inline void plot_draw( const Plot& p, int xmin, int ymin, int xmax, int ymax, bool clearOrNot=true)
767 {
768  p.draw(xmin,ymin,xmax,ymax,clearOrNot);
769 }
770 
771 
772 
773 
777 void triangle(int x1, int y1, int x2, int y2, int x3, int y3);
778 
782 void regular_polygone(int x, int y, unsigned int apotheme, unsigned int line_number);
783 
787 void triangleFill( int x1, int y1,
788  int x2, int y2,
789  int x3, int y3);
790 
791 
795 void regular_polygonFill(int x, int y, unsigned int apotheme, unsigned int line_number);
796 
797 
802 bool isInTriangle(float px, float py, float ax, float ay, float bx, float by, float cx, float cy);
803 
804 
820 void polygonFill(int p[][2], unsigned int number);
821 
822 
833 void polygon(int p[][2], unsigned int number);
834 
835 
842 void qToQuit(bool enable);
843 
844 
845 
846 
847 
848 } // namespace
849 
850 #endif
851 
852 
853 
854 
855 
856 
857 
858 //==================================================================================================
859 //==================================================================================================
860 //==================================================================================================
861 //============================= DOCUMENTATION MAIN PAGE ============================================
862 //==================================================================================================
863 //==================================================================================================
864 //==================================================================================================
865 
void ellipse(int xc, int yc, int horizontal, int vertical)
Draw an ellipse at (xc, yc), horizontal radius and vertical radius, rotation optional (Thanks to Anas...
void triangle(int x1, int y1, int x2, int y2, int x3, int y3)
Draw a triangle from the vertices (x1, y1), (x2, y2) and (x3, y3). (Code provided by Bastien DOIGNIES...
void menu_add(Menu &m, const std::string &str)
Add a line to the menu m with the text str.
Definition: Grapic.h:694
void backgroundColor(unsigned char _r=255, unsigned char _g=255, unsigned char _b=255, unsigned char _a=255)
Change the default background color (the color used to clear the screen)
Definition: Grapic.h:355
void regular_polygone(int x, int y, unsigned int apotheme, unsigned int line_number)
Draw a regular polygon with line_numbers edges centred on (x, y). (Code provided by Bastien DOIGNIES,...
void color(unsigned char _r=255, unsigned char _g=255, unsigned char _b=255, unsigned char _a=255)
Change the default color (unsigned char values between 0 and 255)
Definition: Grapic.h:341
void plot_setSize(Plot &p, const int n)
Define the size of the stored value of the funtion (<0 means infinity)
Definition: Grapic.h:754
void mousePosGlobal(int &x, int &y)
After this function (x,y) store the mouse position.
void plot_draw(const Plot &p, int xmin, int ymin, int xmax, int ymax, bool clearOrNot=true)
Draw the curve in the rectangle (xmin,ymin,xmax,ymax); clear the rectangle if clearOrNot is true.
Definition: Grapic.h:766
int image_width(const Image &im)
return the width of the image
Definition: Grapic.h:640
void ellipseFill(int xc, int yc, int horizontal, int vertical)
Draw a filled ellipse at (xc, yc), horizontal radius and vertical radius, rotation optional (a bit lo...
unsigned int lastFrameTime()
Returns the time elapsed between the last frame in milliseconds. It can be used to sync animations wi...
Definition: Grapic.h:334
void image_draw(Image &im, int x, int y, int w=-1, int h=-1)
Draw the image at position (x,y) with width=w and height=h (if w<0 or h<0 the original size of the im...
Definition: Grapic.h:613
float elapsedTime()
return the time elapsed since the beginning of the process in second
Definition: Grapic.h:440
void setKeyRepeatMode(bool repeat)
(de)Activate the repeat mode: when the user presses continuously on the key touch is repeated....
Definition: Grapic.h:462
void print(int x, int y, const char *txt)
Print the text txt , up left corner is (x,y)
bool winDisplay()
Display the window. All drawing is hidden until this function is not called.
Definition: Grapic.h:300
int isKeyPressed(int key)
return the number of time the key 'key' has been pressed since the last call to this function.
Definition: Grapic.h:453
void rectangleFill(int xmin, int ymin, int xmax, int ymax)
Draw a filled rectangle from (xmin,ymin) to (xmax,ymax)
void point(int x, int y)
Draw a point at (x,y)
Definition: Grapic.h:405
bool isMousePressed(int button)
return true if the mouse button 'button' is pressed
Definition: Grapic.h:486
Image image_copy(const Image &im)
Return a copy of the image. It duplicates the image. It is useful since an affectation shares the sam...
void delay(int d)
Stop the program during d milliseconds.
Definition: Grapic.h:476
void circleFill(int xc, int yc, int radius)
Draw a filled circle from (xmin,ymin) to (xmax,ymax)
void winClearEvent()
Clear the event queue of the window.
Definition: Grapic.h:276
void menu_draw(Menu &m, int xmin=5, int ymin=5, int xmax=-1, int ymax=-1)
Draw the menu on the screen. See menu_add for an example of usage.
Definition: Grapic.h:721
void winSetPosition(int w, int h, int ps, int py, bool fullscreen)
Change the size (w,h), the position(ps,py) or the fullscreen on/off Set a negative parameter to let h...
void winClear()
Clear the window with the default background color.
Definition: Grapic.h:262
int image_height(const Image &im)
return the height of the image
Definition: Grapic.h:648
void winQuit()
Quit and close all things.
Definition: Grapic.h:307
int caseToPixel(const Menu &m, int c, int ymin, int ymax)
return the pixel from a line of the menu
Definition: Grapic.h:739
int irand(int rmin=0, int rmax=100)
return a random number (integer) between rmin to rmax included
Definition: Grapic.h:425
bool winManageEvent()
Manage standard event like key 'ESC', quit, etc.
Definition: Grapic.h:512
void pressSpace(bool isPrint=true)
Stop the program until key 'space'is pressed.
void circle(int xc, int yc, int radius)
Draw a circle from (xmin,ymin) to (xmax,ymax)
bool image_isInit(const Image &im)
return true if the image is initialized
Definition: Grapic.h:660
void fontSize(int s)
Change the default size of the font.
Definition: Grapic.h:519
int menu_select(const Menu &m)
return the line selected in the menu. See menu_add for an example of usage.
Definition: Grapic.h:727
void image_savePNG(const Image &im, const char *filename)
Save the image into the file: format is PNG.
Definition: Grapic.h:606
void rectangle(int xmin, int ymin, int xmax, int ymax)
Draw a rectangle from (xmin,ymin) to (xmax,ymax)
void menu_setSelect(Menu &m, int s)
modifies selected line of the menu. See menu_add for an example of usage.
Definition: Grapic.h:733
void winInit(const char *name, int w, int h, int posx=-1, int posy=-1)
Initialize the window with a size w,h and a position (posx,posy). If posx<0 or posy<0,...
Definition: Grapic.h:245
void selectFont(const char *path)
Changes the default font to the a the given path (must be a .ttf file)
Definition: Grapic.h:526
void image_printInfo(const Image &im)
Print the informations of the image im.
Definition: Grapic.h:667
void triangleFill(int x1, int y1, int x2, int y2, int x3, int y3)
Draw a filled triangle from the vertices (x1, y1), (x2, y2), (x3, y3)
void plot_clear(Plot &p)
Clear the data stored.
Definition: Grapic.h:748
void polygon(int p[][2], unsigned int number)
Draw a polygon. (Code provided by Bastien DOIGNIES, many thanks)
void colorf(float _r=1.f, float _g=1.f, float _b=1.f, float _a=1.f)
Change the default color (float values between 0.f and 1.f)
Definition: Grapic.h:348
void qToQuit(bool enable)
Permet à l'utilisateur d'activer/désactiver la fermeture de la fenêtre sur l'appui de la touche 'q'.
float framesPerSecond()
Returns the average number of frames per second.
Definition: Grapic.h:326
void plot_add(Plot &p, float x, float y, int curve_n=0)
Add a point (x,y=f(x)) to the curve number curve_n.
Definition: Grapic.h:760
void mousePos(int &x, int &y)
After this function (x,y) store the mouse position.
void savePerformanceMode(bool reduceFPS)
If set to true, limit the framerate (to monitor framerate) to save ressources on low end pcs.
Definition: Grapic.h:319
void backgroundColorf(float _r=1.f, float _g=1.f, float _b=1.f, float _a=1.f)
Change the default background color (the color used to clear the screen)
Definition: Grapic.h:362
unsigned char image_get(const Image &im, int x, int y, int c=0)
return the color component c of the pixel (x,y) of the image im. c must be 0 for the red component,...
Definition: Grapic.h:628
float frand(float rmin=0.f, float rmax=1.f)
return a random number (float) between rmin to rmax included
Definition: Grapic.h:432
Image image(const char *filename, bool transparency=false, unsigned char r=255, unsigned char g=255, unsigned b=255, unsigned char a=255)
Return an image loaded from the file filename.
Definition: Grapic.h:587
void grid(int xmin, int ymin, int xmax, int ymax, int nx, int ny)
Draw a grid from (xmin,ymin) to (xmax,ymax) with nx columns and ny rows.
bool winHasFinished()
return true if the application should be closed (because of 'ESC' or 'q' key pressed for instance)
Definition: Grapic.h:269
bool isInTriangle(float px, float py, float ax, float ay, float bx, float by, float cx, float cy)
Decide if a point (px, py) is inside the triangle (ax, ay), (bx, by), (cx, xy). (Code provided by Bas...
int menu_has_changed(Menu &m)
Check if the menu item was changed.
Definition: Grapic.h:710
void points(int p[][2], int n)
Draw an array of n points.
Definition: Grapic.h:413
void put_pixel(int x, int y, unsigned char r, unsigned char g, unsigned char b, unsigned char a=255)
Draw a pixel on (x,y) with color (r,g,b,a)
void regular_polygonFill(int x, int y, unsigned int apotheme, unsigned int line_number)
Draw a filled regular polygon with line_numbers edges centred on (x, y). (Code provided by Bastien DO...
void image_set(Image &im, int x, int y, unsigned char r, unsigned char g, unsigned b, unsigned char a)
Set the pixel (x,y) of the image im with the color c.
void menu_change(Menu &m, int i, const std::string &str)
Change the text of a line in the menu.
Definition: Grapic.h:701
void line(int x1, int y1, int x2, int y2)
Draw a line from (x1,y1) to (x2,y2)
Definition: Grapic.h:393
void polygonFill(int p[][2], unsigned int number)
Draw a simple(no edge-crossing) and without holes filled polygon.
Definition: Grapic.h:48