line_2d.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*************************************************************************/
  2. /* line_2d.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 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 LINE2D_H
  31. #define LINE2D_H
  32. #include "node_2d.h"
  33. class Line2D : public Node2D {
  34. GDCLASS(Line2D, Node2D)
  35. public:
  36. enum LineJointMode {
  37. LINE_JOINT_SHARP = 0,
  38. LINE_JOINT_BEVEL,
  39. LINE_JOINT_ROUND
  40. };
  41. enum LineCapMode {
  42. LINE_CAP_NONE = 0,
  43. LINE_CAP_BOX,
  44. LINE_CAP_ROUND
  45. };
  46. enum LineTextureMode {
  47. LINE_TEXTURE_NONE = 0,
  48. LINE_TEXTURE_TILE
  49. // TODO STRETCH mode
  50. };
  51. Line2D();
  52. void set_points(const PoolVector<Vector2> &p_points);
  53. PoolVector<Vector2> get_points() const;
  54. void set_point_position(int i, Vector2 pos);
  55. Vector2 get_point_position(int i) const;
  56. int get_point_count() const;
  57. void add_point(Vector2 pos);
  58. void remove_point(int i);
  59. void set_width(float width);
  60. float get_width() const;
  61. void set_default_color(Color color);
  62. Color get_default_color() const;
  63. void set_gradient(const Ref<Gradient> &gradient);
  64. Ref<Gradient> get_gradient() const;
  65. void set_texture(const Ref<Texture> &texture);
  66. Ref<Texture> get_texture() const;
  67. void set_texture_mode(const LineTextureMode mode);
  68. LineTextureMode get_texture_mode() const;
  69. void set_joint_mode(LineJointMode mode);
  70. LineJointMode get_joint_mode() const;
  71. void set_begin_cap_mode(LineCapMode mode);
  72. LineCapMode get_begin_cap_mode() const;
  73. void set_end_cap_mode(LineCapMode mode);
  74. LineCapMode get_end_cap_mode() const;
  75. void set_sharp_limit(float limit);
  76. float get_sharp_limit() const;
  77. void set_round_precision(int precision);
  78. int get_round_precision() const;
  79. protected:
  80. void _notification(int p_what);
  81. void _draw();
  82. static void _bind_methods();
  83. private:
  84. void _gradient_changed();
  85. private:
  86. PoolVector<Vector2> _points;
  87. LineJointMode _joint_mode;
  88. LineCapMode _begin_cap_mode;
  89. LineCapMode _end_cap_mode;
  90. float _width;
  91. Color _default_color;
  92. Ref<Gradient> _gradient;
  93. Ref<Texture> _texture;
  94. LineTextureMode _texture_mode;
  95. float _sharp_limit;
  96. int _round_precision;
  97. };
  98. #endif // LINE2D_H