2023-01-05 12:25:55 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
/* line_2d.cpp */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/**************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2016-12-09 01:52:40 +00:00
|
|
|
#include "line_2d.h"
|
2017-03-05 14:47:28 +00:00
|
|
|
|
2020-05-25 17:20:45 +00:00
|
|
|
#include "core/math/geometry_2d.h"
|
2020-02-21 22:26:13 +00:00
|
|
|
#include "line_builder.h"
|
2016-12-09 01:52:40 +00:00
|
|
|
|
2019-06-26 13:08:25 +00:00
|
|
|
Line2D::Line2D() {
|
2016-12-09 01:52:40 +00:00
|
|
|
}
|
|
|
|
|
2019-10-21 21:37:07 +00:00
|
|
|
#ifdef TOOLS_ENABLED
|
2017-12-27 08:28:02 +00:00
|
|
|
Rect2 Line2D::_edit_get_rect() const {
|
2020-05-14 14:41:43 +00:00
|
|
|
if (_points.size() == 0) {
|
2017-12-27 08:28:02 +00:00
|
|
|
return Rect2(0, 0, 0, 0);
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2017-12-27 08:28:02 +00:00
|
|
|
Vector2 d = Vector2(_width, _width);
|
|
|
|
Rect2 aabb = Rect2(_points[0] - d, 2 * d);
|
|
|
|
for (int i = 1; i < _points.size(); i++) {
|
|
|
|
aabb.expand_to(_points[i] - d);
|
|
|
|
aabb.expand_to(_points[i] + d);
|
|
|
|
}
|
|
|
|
return aabb;
|
|
|
|
}
|
|
|
|
|
2018-03-08 20:35:41 +00:00
|
|
|
bool Line2D::_edit_use_rect() const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-12-27 08:28:02 +00:00
|
|
|
bool Line2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
|
|
|
|
const real_t d = _width / 2 + p_tolerance;
|
2020-02-17 21:06:54 +00:00
|
|
|
const Vector2 *points = _points.ptr();
|
2017-12-27 08:28:02 +00:00
|
|
|
for (int i = 0; i < _points.size() - 1; i++) {
|
2020-05-25 17:20:45 +00:00
|
|
|
Vector2 p = Geometry2D::get_closest_point_to_segment(p_point, &points[i]);
|
2020-05-14 14:41:43 +00:00
|
|
|
if (p.distance_to(p_point) <= d) {
|
2017-12-27 08:28:02 +00:00
|
|
|
return true;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2017-12-27 08:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2019-10-21 21:37:07 +00:00
|
|
|
#endif
|
2017-12-27 08:28:02 +00:00
|
|
|
|
2020-02-17 21:06:54 +00:00
|
|
|
void Line2D::set_points(const Vector<Vector2> &p_points) {
|
2016-12-09 01:52:40 +00:00
|
|
|
_points = p_points;
|
2022-08-13 21:21:24 +00:00
|
|
|
queue_redraw();
|
2016-12-09 01:52:40 +00:00
|
|
|
}
|
|
|
|
|
2019-05-01 04:50:01 +00:00
|
|
|
void Line2D::set_width(float p_width) {
|
2020-05-14 14:41:43 +00:00
|
|
|
if (p_width < 0.0) {
|
2019-05-01 04:50:01 +00:00
|
|
|
p_width = 0.0;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2019-05-01 04:50:01 +00:00
|
|
|
_width = p_width;
|
2022-08-13 21:21:24 +00:00
|
|
|
queue_redraw();
|
2016-12-09 01:52:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
float Line2D::get_width() const {
|
|
|
|
return _width;
|
|
|
|
}
|
|
|
|
|
2019-05-01 04:50:01 +00:00
|
|
|
void Line2D::set_curve(const Ref<Curve> &p_curve) {
|
|
|
|
// Cleanup previous connection if any
|
|
|
|
if (_curve.is_valid()) {
|
2023-07-03 19:29:37 +00:00
|
|
|
_curve->disconnect_changed(callable_mp(this, &Line2D::_curve_changed));
|
2019-05-01 04:50:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_curve = p_curve;
|
|
|
|
|
|
|
|
// Connect to the curve so the line will update when it is changed
|
|
|
|
if (_curve.is_valid()) {
|
2023-07-03 19:29:37 +00:00
|
|
|
_curve->connect_changed(callable_mp(this, &Line2D::_curve_changed));
|
2019-05-01 04:50:01 +00:00
|
|
|
}
|
|
|
|
|
2022-08-13 21:21:24 +00:00
|
|
|
queue_redraw();
|
2019-05-01 04:50:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Ref<Curve> Line2D::get_curve() const {
|
|
|
|
return _curve;
|
|
|
|
}
|
|
|
|
|
2020-02-17 21:06:54 +00:00
|
|
|
Vector<Vector2> Line2D::get_points() const {
|
2016-12-09 01:52:40 +00:00
|
|
|
return _points;
|
|
|
|
}
|
|
|
|
|
2019-05-01 04:50:01 +00:00
|
|
|
void Line2D::set_point_position(int i, Vector2 p_pos) {
|
2021-02-21 12:50:11 +00:00
|
|
|
ERR_FAIL_INDEX(i, _points.size());
|
2019-05-01 04:50:01 +00:00
|
|
|
_points.set(i, p_pos);
|
2022-08-13 21:21:24 +00:00
|
|
|
queue_redraw();
|
2016-12-09 01:52:40 +00:00
|
|
|
}
|
|
|
|
|
2017-09-10 13:37:49 +00:00
|
|
|
Vector2 Line2D::get_point_position(int i) const {
|
2019-06-11 12:49:34 +00:00
|
|
|
ERR_FAIL_INDEX_V(i, _points.size(), Vector2());
|
2016-12-09 01:52:40 +00:00
|
|
|
return _points.get(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
int Line2D::get_point_count() const {
|
|
|
|
return _points.size();
|
|
|
|
}
|
|
|
|
|
2019-03-19 16:59:24 +00:00
|
|
|
void Line2D::clear_points() {
|
|
|
|
int count = _points.size();
|
|
|
|
if (count > 0) {
|
2022-02-01 18:19:13 +00:00
|
|
|
_points.clear();
|
2022-08-13 21:21:24 +00:00
|
|
|
queue_redraw();
|
2019-03-19 16:59:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-01 04:50:01 +00:00
|
|
|
void Line2D::add_point(Vector2 p_pos, int p_atpos) {
|
|
|
|
if (p_atpos < 0 || _points.size() < p_atpos) {
|
2020-02-17 21:06:54 +00:00
|
|
|
_points.push_back(p_pos);
|
2019-04-08 09:14:10 +00:00
|
|
|
} else {
|
2019-05-01 04:50:01 +00:00
|
|
|
_points.insert(p_atpos, p_pos);
|
2019-04-08 09:14:10 +00:00
|
|
|
}
|
2022-08-13 21:21:24 +00:00
|
|
|
queue_redraw();
|
2016-12-09 01:52:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Line2D::remove_point(int i) {
|
2021-07-03 22:17:03 +00:00
|
|
|
_points.remove_at(i);
|
2022-08-13 21:21:24 +00:00
|
|
|
queue_redraw();
|
2016-12-09 01:52:40 +00:00
|
|
|
}
|
|
|
|
|
2019-05-01 04:50:01 +00:00
|
|
|
void Line2D::set_default_color(Color p_color) {
|
|
|
|
_default_color = p_color;
|
2022-08-13 21:21:24 +00:00
|
|
|
queue_redraw();
|
2016-12-09 01:52:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Color Line2D::get_default_color() const {
|
|
|
|
return _default_color;
|
|
|
|
}
|
|
|
|
|
2019-05-01 04:50:01 +00:00
|
|
|
void Line2D::set_gradient(const Ref<Gradient> &p_gradient) {
|
2016-12-09 01:52:40 +00:00
|
|
|
// Cleanup previous connection if any
|
|
|
|
if (_gradient.is_valid()) {
|
2023-07-03 19:29:37 +00:00
|
|
|
_gradient->disconnect_changed(callable_mp(this, &Line2D::_gradient_changed));
|
2016-12-09 01:52:40 +00:00
|
|
|
}
|
|
|
|
|
2019-05-01 04:50:01 +00:00
|
|
|
_gradient = p_gradient;
|
2016-12-09 01:52:40 +00:00
|
|
|
|
2020-10-25 16:32:44 +00:00
|
|
|
// Connect to the gradient so the line will update when the Gradient is changed
|
2016-12-09 01:52:40 +00:00
|
|
|
if (_gradient.is_valid()) {
|
2023-07-03 19:29:37 +00:00
|
|
|
_gradient->connect_changed(callable_mp(this, &Line2D::_gradient_changed));
|
2016-12-09 01:52:40 +00:00
|
|
|
}
|
|
|
|
|
2022-08-13 21:21:24 +00:00
|
|
|
queue_redraw();
|
2016-12-09 01:52:40 +00:00
|
|
|
}
|
|
|
|
|
2017-05-29 00:46:48 +00:00
|
|
|
Ref<Gradient> Line2D::get_gradient() const {
|
2016-12-09 01:52:40 +00:00
|
|
|
return _gradient;
|
|
|
|
}
|
|
|
|
|
2019-06-11 18:43:37 +00:00
|
|
|
void Line2D::set_texture(const Ref<Texture2D> &p_texture) {
|
2019-05-01 04:50:01 +00:00
|
|
|
_texture = p_texture;
|
2022-08-13 21:21:24 +00:00
|
|
|
queue_redraw();
|
2016-12-09 01:52:40 +00:00
|
|
|
}
|
|
|
|
|
2019-06-11 18:43:37 +00:00
|
|
|
Ref<Texture2D> Line2D::get_texture() const {
|
2016-12-09 01:52:40 +00:00
|
|
|
return _texture;
|
|
|
|
}
|
|
|
|
|
2019-05-01 04:50:01 +00:00
|
|
|
void Line2D::set_texture_mode(const LineTextureMode p_mode) {
|
|
|
|
_texture_mode = p_mode;
|
2022-08-13 21:21:24 +00:00
|
|
|
queue_redraw();
|
2016-12-09 01:52:40 +00:00
|
|
|
}
|
|
|
|
|
2017-09-12 19:09:06 +00:00
|
|
|
Line2D::LineTextureMode Line2D::get_texture_mode() const {
|
2016-12-09 01:52:40 +00:00
|
|
|
return _texture_mode;
|
|
|
|
}
|
|
|
|
|
2019-05-01 04:50:01 +00:00
|
|
|
void Line2D::set_joint_mode(LineJointMode p_mode) {
|
|
|
|
_joint_mode = p_mode;
|
2022-08-13 21:21:24 +00:00
|
|
|
queue_redraw();
|
2016-12-09 01:52:40 +00:00
|
|
|
}
|
|
|
|
|
2017-09-12 19:09:06 +00:00
|
|
|
Line2D::LineJointMode Line2D::get_joint_mode() const {
|
2016-12-09 01:52:40 +00:00
|
|
|
return _joint_mode;
|
|
|
|
}
|
|
|
|
|
2019-05-01 04:50:01 +00:00
|
|
|
void Line2D::set_begin_cap_mode(LineCapMode p_mode) {
|
|
|
|
_begin_cap_mode = p_mode;
|
2022-08-13 21:21:24 +00:00
|
|
|
queue_redraw();
|
2016-12-09 01:52:40 +00:00
|
|
|
}
|
|
|
|
|
2017-09-12 19:09:06 +00:00
|
|
|
Line2D::LineCapMode Line2D::get_begin_cap_mode() const {
|
2016-12-09 01:52:40 +00:00
|
|
|
return _begin_cap_mode;
|
|
|
|
}
|
|
|
|
|
2019-05-01 04:50:01 +00:00
|
|
|
void Line2D::set_end_cap_mode(LineCapMode p_mode) {
|
|
|
|
_end_cap_mode = p_mode;
|
2022-08-13 21:21:24 +00:00
|
|
|
queue_redraw();
|
2016-12-09 01:52:40 +00:00
|
|
|
}
|
|
|
|
|
2017-09-12 19:09:06 +00:00
|
|
|
Line2D::LineCapMode Line2D::get_end_cap_mode() const {
|
2016-12-09 01:52:40 +00:00
|
|
|
return _end_cap_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Line2D::_notification(int p_what) {
|
|
|
|
switch (p_what) {
|
2022-02-15 17:06:48 +00:00
|
|
|
case NOTIFICATION_DRAW: {
|
2016-12-09 01:52:40 +00:00
|
|
|
_draw();
|
2022-02-15 17:06:48 +00:00
|
|
|
} break;
|
2016-12-09 01:52:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-01 04:50:01 +00:00
|
|
|
void Line2D::set_sharp_limit(float p_limit) {
|
2020-05-14 14:41:43 +00:00
|
|
|
if (p_limit < 0.f) {
|
2019-05-01 04:50:01 +00:00
|
|
|
p_limit = 0.f;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2019-05-01 04:50:01 +00:00
|
|
|
_sharp_limit = p_limit;
|
2022-08-13 21:21:24 +00:00
|
|
|
queue_redraw();
|
2016-12-09 01:52:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
float Line2D::get_sharp_limit() const {
|
|
|
|
return _sharp_limit;
|
|
|
|
}
|
|
|
|
|
2019-05-01 04:50:01 +00:00
|
|
|
void Line2D::set_round_precision(int p_precision) {
|
2022-02-16 23:21:00 +00:00
|
|
|
_round_precision = MAX(1, p_precision);
|
2022-08-13 21:21:24 +00:00
|
|
|
queue_redraw();
|
2016-12-09 01:52:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int Line2D::get_round_precision() const {
|
|
|
|
return _round_precision;
|
|
|
|
}
|
|
|
|
|
2019-11-24 10:00:02 +00:00
|
|
|
void Line2D::set_antialiased(bool p_antialiased) {
|
|
|
|
_antialiased = p_antialiased;
|
2022-08-13 21:21:24 +00:00
|
|
|
queue_redraw();
|
2019-11-24 10:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Line2D::get_antialiased() const {
|
|
|
|
return _antialiased;
|
|
|
|
}
|
|
|
|
|
2016-12-09 01:52:40 +00:00
|
|
|
void Line2D::_draw() {
|
2022-02-10 09:36:17 +00:00
|
|
|
int len = _points.size();
|
|
|
|
if (len <= 1 || _width == 0.f) {
|
2016-12-09 01:52:40 +00:00
|
|
|
return;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2016-12-09 01:52:40 +00:00
|
|
|
|
|
|
|
// TODO Is this really needed?
|
|
|
|
// Copy points for faster access
|
|
|
|
Vector<Vector2> points;
|
2022-02-10 09:36:17 +00:00
|
|
|
points.resize(len);
|
2016-12-09 01:52:40 +00:00
|
|
|
{
|
2020-02-17 21:06:54 +00:00
|
|
|
const Vector2 *points_read = _points.ptr();
|
2016-12-09 01:52:40 +00:00
|
|
|
for (int i = 0; i < len; ++i) {
|
2018-07-25 01:11:03 +00:00
|
|
|
points.write[i] = points_read[i];
|
2016-12-09 01:52:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO Maybe have it as member rather than copying parameters and allocating memory?
|
|
|
|
LineBuilder lb;
|
|
|
|
lb.points = points;
|
|
|
|
lb.default_color = _default_color;
|
|
|
|
lb.gradient = *_gradient;
|
|
|
|
lb.texture_mode = _texture_mode;
|
|
|
|
lb.joint_mode = _joint_mode;
|
|
|
|
lb.begin_cap_mode = _begin_cap_mode;
|
|
|
|
lb.end_cap_mode = _end_cap_mode;
|
|
|
|
lb.round_precision = _round_precision;
|
|
|
|
lb.sharp_limit = _sharp_limit;
|
|
|
|
lb.width = _width;
|
2019-05-01 04:50:01 +00:00
|
|
|
lb.curve = *_curve;
|
2016-12-09 01:52:40 +00:00
|
|
|
|
|
|
|
RID texture_rid;
|
2018-02-25 00:48:37 +00:00
|
|
|
if (_texture.is_valid()) {
|
2019-05-01 04:50:01 +00:00
|
|
|
texture_rid = _texture->get_rid();
|
2016-12-09 01:52:40 +00:00
|
|
|
|
2018-02-25 00:48:37 +00:00
|
|
|
lb.tile_aspect = _texture->get_size().aspect();
|
|
|
|
}
|
|
|
|
|
|
|
|
lb.build();
|
|
|
|
|
2020-03-27 18:21:27 +00:00
|
|
|
RS::get_singleton()->canvas_item_add_triangle_array(
|
2016-12-09 01:52:40 +00:00
|
|
|
get_canvas_item(),
|
|
|
|
lb.indices,
|
|
|
|
lb.vertices,
|
|
|
|
lb.colors,
|
2018-05-03 20:29:15 +00:00
|
|
|
lb.uvs, Vector<int>(), Vector<float>(),
|
2019-06-25 01:24:07 +00:00
|
|
|
texture_rid);
|
2016-12-09 01:52:40 +00:00
|
|
|
|
|
|
|
// DEBUG
|
|
|
|
// Draw wireframe
|
|
|
|
// if(lb.indices.size() % 3 == 0) {
|
|
|
|
// Color col(0,0,0);
|
|
|
|
// for(int i = 0; i < lb.indices.size(); i += 3) {
|
|
|
|
// int vi = lb.indices[i];
|
|
|
|
// int lbvsize = lb.vertices.size();
|
|
|
|
// Vector2 a = lb.vertices[lb.indices[i]];
|
|
|
|
// Vector2 b = lb.vertices[lb.indices[i+1]];
|
|
|
|
// Vector2 c = lb.vertices[lb.indices[i+2]];
|
|
|
|
// draw_line(a, b, col);
|
|
|
|
// draw_line(b, c, col);
|
|
|
|
// draw_line(c, a, col);
|
|
|
|
// }
|
|
|
|
// for(int i = 0; i < lb.vertices.size(); ++i) {
|
|
|
|
// Vector2 p = lb.vertices[i];
|
|
|
|
// draw_rect(Rect2(p.x-1, p.y-1, 2, 2), Color(0,0,0,0.5));
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
void Line2D::_gradient_changed() {
|
2022-08-13 21:21:24 +00:00
|
|
|
queue_redraw();
|
2016-12-09 01:52:40 +00:00
|
|
|
}
|
|
|
|
|
2019-05-01 04:50:01 +00:00
|
|
|
void Line2D::_curve_changed() {
|
2022-08-13 21:21:24 +00:00
|
|
|
queue_redraw();
|
2019-05-01 04:50:01 +00:00
|
|
|
}
|
|
|
|
|
2016-12-09 01:52:40 +00:00
|
|
|
// static
|
|
|
|
void Line2D::_bind_methods() {
|
2017-02-13 11:47:24 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_points", "points"), &Line2D::set_points);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_points"), &Line2D::get_points);
|
2016-12-09 01:52:40 +00:00
|
|
|
|
2022-08-15 14:31:23 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_point_position", "index", "position"), &Line2D::set_point_position);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_point_position", "index"), &Line2D::get_point_position);
|
2016-12-09 01:52:40 +00:00
|
|
|
|
2017-02-13 11:47:24 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("get_point_count"), &Line2D::get_point_count);
|
2016-12-09 01:52:40 +00:00
|
|
|
|
2022-08-15 14:31:23 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("add_point", "position", "index"), &Line2D::add_point, DEFVAL(-1));
|
|
|
|
ClassDB::bind_method(D_METHOD("remove_point", "index"), &Line2D::remove_point);
|
2016-12-09 01:52:40 +00:00
|
|
|
|
2019-03-19 16:59:24 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("clear_points"), &Line2D::clear_points);
|
|
|
|
|
2017-02-13 11:47:24 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_width", "width"), &Line2D::set_width);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_width"), &Line2D::get_width);
|
2016-12-09 01:52:40 +00:00
|
|
|
|
2019-05-01 04:50:01 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_curve", "curve"), &Line2D::set_curve);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_curve"), &Line2D::get_curve);
|
|
|
|
|
2017-02-13 11:47:24 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_default_color", "color"), &Line2D::set_default_color);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_default_color"), &Line2D::get_default_color);
|
2016-12-09 01:52:40 +00:00
|
|
|
|
2017-08-09 11:19:41 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_gradient", "color"), &Line2D::set_gradient);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_gradient"), &Line2D::get_gradient);
|
2016-12-09 01:52:40 +00:00
|
|
|
|
2017-08-09 11:19:41 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_texture", "texture"), &Line2D::set_texture);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_texture"), &Line2D::get_texture);
|
2016-12-09 01:52:40 +00:00
|
|
|
|
2017-02-13 11:47:24 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_texture_mode", "mode"), &Line2D::set_texture_mode);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_texture_mode"), &Line2D::get_texture_mode);
|
2016-12-09 01:52:40 +00:00
|
|
|
|
2017-02-13 11:47:24 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_joint_mode", "mode"), &Line2D::set_joint_mode);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_joint_mode"), &Line2D::get_joint_mode);
|
2016-12-09 01:52:40 +00:00
|
|
|
|
2017-02-13 11:47:24 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_begin_cap_mode", "mode"), &Line2D::set_begin_cap_mode);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_begin_cap_mode"), &Line2D::get_begin_cap_mode);
|
2016-12-09 01:52:40 +00:00
|
|
|
|
2017-02-13 11:47:24 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_end_cap_mode", "mode"), &Line2D::set_end_cap_mode);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_end_cap_mode"), &Line2D::get_end_cap_mode);
|
2016-12-09 01:52:40 +00:00
|
|
|
|
2017-02-13 11:47:24 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_sharp_limit", "limit"), &Line2D::set_sharp_limit);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_sharp_limit"), &Line2D::get_sharp_limit);
|
2016-12-09 01:52:40 +00:00
|
|
|
|
2017-02-13 11:47:24 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_round_precision", "precision"), &Line2D::set_round_precision);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_round_precision"), &Line2D::get_round_precision);
|
2016-12-09 01:52:40 +00:00
|
|
|
|
2019-11-24 10:00:02 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_antialiased", "antialiased"), &Line2D::set_antialiased);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_antialiased"), &Line2D::get_antialiased);
|
|
|
|
|
2020-02-17 21:06:54 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR2_ARRAY, "points"), "set_points", "get_points");
|
2021-12-03 00:09:19 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "width", PROPERTY_HINT_NONE, "suffix:px"), "set_width", "get_width");
|
2019-05-01 04:50:01 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "width_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_curve", "get_curve");
|
2017-02-12 00:11:37 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "default_color"), "set_default_color", "get_default_color");
|
2017-06-25 21:57:28 +00:00
|
|
|
ADD_GROUP("Fill", "");
|
2018-11-08 14:30:02 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "gradient", PROPERTY_HINT_RESOURCE_TYPE, "Gradient"), "set_gradient", "get_gradient");
|
2019-06-11 18:43:37 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture");
|
2018-11-08 14:30:02 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_mode", PROPERTY_HINT_ENUM, "None,Tile,Stretch"), "set_texture_mode", "get_texture_mode");
|
2017-06-25 21:57:28 +00:00
|
|
|
ADD_GROUP("Capping", "");
|
2018-11-08 14:30:02 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "joint_mode", PROPERTY_HINT_ENUM, "Sharp,Bevel,Round"), "set_joint_mode", "get_joint_mode");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "begin_cap_mode", PROPERTY_HINT_ENUM, "None,Box,Round"), "set_begin_cap_mode", "get_begin_cap_mode");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "end_cap_mode", PROPERTY_HINT_ENUM, "None,Box,Round"), "set_end_cap_mode", "get_end_cap_mode");
|
2017-06-25 21:57:28 +00:00
|
|
|
ADD_GROUP("Border", "");
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sharp_limit"), "set_sharp_limit", "get_sharp_limit");
|
2022-02-16 23:21:00 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "round_precision", PROPERTY_HINT_RANGE, "1,32,1"), "set_round_precision", "get_round_precision");
|
2019-11-24 10:00:02 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "antialiased"), "set_antialiased", "get_antialiased");
|
2016-12-09 01:52:40 +00:00
|
|
|
|
2017-08-20 15:45:01 +00:00
|
|
|
BIND_ENUM_CONSTANT(LINE_JOINT_SHARP);
|
|
|
|
BIND_ENUM_CONSTANT(LINE_JOINT_BEVEL);
|
|
|
|
BIND_ENUM_CONSTANT(LINE_JOINT_ROUND);
|
2016-12-09 01:52:40 +00:00
|
|
|
|
2017-08-20 15:45:01 +00:00
|
|
|
BIND_ENUM_CONSTANT(LINE_CAP_NONE);
|
|
|
|
BIND_ENUM_CONSTANT(LINE_CAP_BOX);
|
|
|
|
BIND_ENUM_CONSTANT(LINE_CAP_ROUND);
|
2016-12-09 01:52:40 +00:00
|
|
|
|
2017-08-20 15:45:01 +00:00
|
|
|
BIND_ENUM_CONSTANT(LINE_TEXTURE_NONE);
|
|
|
|
BIND_ENUM_CONSTANT(LINE_TEXTURE_TILE);
|
2018-07-16 12:31:19 +00:00
|
|
|
BIND_ENUM_CONSTANT(LINE_TEXTURE_STRETCH);
|
2016-12-09 01:52:40 +00:00
|
|
|
}
|