1 /*************************************************************************/ 2 /* polygon_2d.h */ 3 /*************************************************************************/ 4 /* This file is part of: */ 5 /* GODOT ENGINE */ 6 /* https://godotengine.org */ 7 /*************************************************************************/ 8 /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ 9 /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ 10 /* */ 11 /* Permission is hereby granted, free of charge, to any person obtaining */ 12 /* a copy of this software and associated documentation files (the */ 13 /* "Software"), to deal in the Software without restriction, including */ 14 /* without limitation the rights to use, copy, modify, merge, publish, */ 15 /* distribute, sublicense, and/or sell copies of the Software, and to */ 16 /* permit persons to whom the Software is furnished to do so, subject to */ 17 /* the following conditions: */ 18 /* */ 19 /* The above copyright notice and this permission notice shall be */ 20 /* included in all copies or substantial portions of the Software. */ 21 /* */ 22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ 23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ 24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ 25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ 26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ 27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ 28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 29 /*************************************************************************/ 30 #ifndef POLYGON_2D_H 31 #define POLYGON_2D_H 32 33 #include "scene/2d/node_2d.h" 34 35 class Polygon2D : public Node2D { 36 37 OBJ_TYPE(Polygon2D, Node2D); 38 39 DVector<Vector2> polygon; 40 DVector<Vector2> uv; 41 DVector<Color> vertex_colors; 42 Color color; 43 Ref<Texture> texture; 44 Size2 tex_scale; 45 Vector2 tex_ofs; 46 bool tex_tile; 47 float tex_rot; 48 bool invert; 49 float invert_border; 50 51 Vector2 offset; 52 mutable bool rect_cache_dirty; 53 mutable Rect2 item_rect; 54 55 void _set_texture_rotationd(float p_rot); 56 float _get_texture_rotationd() const; 57 58 protected: 59 void _notification(int p_what); 60 static void _bind_methods(); 61 62 public: 63 void set_polygon(const DVector<Vector2> &p_polygon); 64 DVector<Vector2> get_polygon() const; 65 66 void set_uv(const DVector<Vector2> &p_uv); 67 DVector<Vector2> get_uv() const; 68 69 void set_color(const Color &p_color); 70 Color get_color() const; 71 72 void set_vertex_colors(const DVector<Color> &p_colors); 73 DVector<Color> get_vertex_colors() const; 74 75 void set_texture(const Ref<Texture> &p_texture); 76 Ref<Texture> get_texture() const; 77 78 void set_texture_offset(const Vector2 &p_offset); 79 Vector2 get_texture_offset() const; 80 81 void set_texture_rotation(float p_rot); 82 float get_texture_rotation() const; 83 84 void set_texture_scale(const Size2 &p_scale); 85 Size2 get_texture_scale() const; 86 87 void set_invert(bool p_rot); 88 bool get_invert() const; 89 90 void set_invert_border(float p_border); 91 float get_invert_border() const; 92 93 void set_offset(const Vector2 &p_offset); 94 Vector2 get_offset() const; 95 96 //editor stuff 97 98 virtual void edit_set_pivot(const Point2 &p_pivot); 99 virtual Point2 edit_get_pivot() const; 100 virtual bool edit_has_pivot() const; 101 102 virtual Rect2 get_item_rect() const; 103 104 Polygon2D(); 105 }; 106 107 #endif // POLYGON_2D_H 108