Canvas.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Canvas.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "Geometries.h"
  12. struct SDL_Color;
  13. struct SDL_Surface;
  14. class IImage;
  15. enum EFonts : int;
  16. /// Class that represents surface for drawing on
  17. class Canvas
  18. {
  19. SDL_Surface * surface;
  20. Canvas & operator = (Canvas & other) = delete;
  21. public:
  22. /// constructs canvas using existing surface. Caller maintains ownership on the surface
  23. Canvas(SDL_Surface * surface);
  24. /// copy contructor
  25. Canvas(Canvas & other);
  26. /// constructs canvas of specified size
  27. Canvas(const Point & size);
  28. ~Canvas();
  29. /// renders image onto this canvas at specified position
  30. void draw(std::shared_ptr<IImage> image, const Point & pos);
  31. /// renders section of image bounded by sourceRect at specified position
  32. void draw(std::shared_ptr<IImage> image, const Point & pos, const Rect & sourceRect);
  33. /// renders another canvas onto this canvas
  34. void draw(Canvas & image, const Point & pos);
  35. /// renders continuous, 1-pixel wide line with color gradient
  36. void drawLine(const Point & from, const Point & dest, const SDL_Color & colorFrom, const SDL_Color & colorDest);
  37. /// renders single line of text with specified parameters
  38. void drawText(const Point & position, const EFonts & font, const SDL_Color & colorDest, ETextAlignment alignment, const std::string & text );
  39. /// renders multiple lines of text with specified parameters
  40. void drawText(const Point & position, const EFonts & font, const SDL_Color & colorDest, ETextAlignment alignment, const std::vector<std::string> & text );
  41. };