polygon_2d.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef POLYGON_2D_H
  2. #define POLYGON_2D_H
  3. #include "scene/2d/node_2d.h"
  4. class Polygon2D : public Node2D {
  5. OBJ_TYPE(Polygon2D,Node2D);
  6. DVector<Vector2> polygon;
  7. DVector<Vector2> uv;
  8. Color color;
  9. Ref<Texture> texture;
  10. Vector2 tex_scale;
  11. Vector2 tex_ofs;
  12. bool tex_tile;
  13. float tex_rot;
  14. bool invert;
  15. float invert_border;
  16. Vector2 offset;
  17. mutable bool rect_cache_dirty;
  18. mutable Rect2 item_rect;
  19. void _set_texture_rotationd(float p_rot);
  20. float _get_texture_rotationd() const;
  21. protected:
  22. void _notification(int p_what);
  23. static void _bind_methods();
  24. public:
  25. void set_polygon(const DVector<Vector2>& p_polygon);
  26. DVector<Vector2> get_polygon() const;
  27. void set_uv(const DVector<Vector2>& p_uv);
  28. DVector<Vector2> get_uv() const;
  29. void set_color(const Color& p_color);
  30. Color get_color() const;
  31. void set_texture(const Ref<Texture>& p_texture);
  32. Ref<Texture> get_texture() const;
  33. void set_texture_offset(const Vector2& p_offset);
  34. Vector2 get_texture_offset() const;
  35. void set_texture_rotation(float p_rot);
  36. float get_texture_rotation() const;
  37. void set_texture_scale(const Vector2& p_scale);
  38. Vector2 get_texture_scale() const;
  39. void set_invert(bool p_rot);
  40. bool get_invert() const;
  41. void set_invert_border(float p_border);
  42. float get_invert_border() const;
  43. void set_offset(const Vector2& p_offset);
  44. Vector2 get_offset() const;
  45. //editor stuff
  46. virtual void edit_set_pivot(const Point2& p_pivot);
  47. virtual Point2 edit_get_pivot() const;
  48. virtual bool edit_has_pivot() const;
  49. virtual Rect2 get_item_rect() const;
  50. Polygon2D();
  51. };
  52. #endif // POLYGON_2D_H