GraphicalPrimitiveCanvas.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * GraphicalPrimitiveCanvas.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 "../gui/CIntObject.h"
  12. class GraphicalPrimitiveCanvas : public CIntObject
  13. {
  14. enum class PrimitiveType
  15. {
  16. LINE,
  17. RECTANGLE,
  18. FILLED_BOX
  19. };
  20. struct PrimitiveEntry
  21. {
  22. ColorRGBA color;
  23. Point a;
  24. Point b;
  25. PrimitiveType type;
  26. };
  27. std::vector<PrimitiveEntry> primitives;
  28. void showAll(Canvas & to) override;
  29. public:
  30. GraphicalPrimitiveCanvas(Rect position);
  31. void addLine(const Point & from, const Point & to, const ColorRGBA & color);
  32. void addBox(const Point & topLeft, const Point & size, const ColorRGBA & color);
  33. void addRectangle(const Point & topLeft, const Point & size, const ColorRGBA & color);
  34. };
  35. class TransparentFilledRectangle : public GraphicalPrimitiveCanvas
  36. {
  37. public:
  38. TransparentFilledRectangle(Rect position, ColorRGBA color);
  39. TransparentFilledRectangle(Rect position, ColorRGBA color, ColorRGBA colorLine, int width = 1);
  40. };
  41. class SimpleLine : public GraphicalPrimitiveCanvas
  42. {
  43. public:
  44. SimpleLine(Point pos1, Point pos2, ColorRGBA color);
  45. };