mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-23 04:16:50 +01:00
PaintCurve2D property setup.
This commit is contained in:
parent
94f412a352
commit
6148df90ef
@ -40,21 +40,24 @@
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
Rect2 PaintCurve2D::_edit_get_rect() const {
|
||||
//if (rect_cache_dirty) {
|
||||
if (!curve.is_valid() || curve->get_point_count() == 0) {
|
||||
return Rect2(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
Rect2 aabb = Rect2(curve->get_point_position(0), Vector2(0, 0));
|
||||
item_rect = Rect2(curve->get_point_position(0), Vector2(0, 0));
|
||||
|
||||
for (int i = 0; i < curve->get_point_count(); i++) {
|
||||
for (int j = 0; j <= 8; j++) {
|
||||
real_t frac = j / 8.0;
|
||||
Vector2 p = curve->interpolate(i, frac);
|
||||
aabb.expand_to(p);
|
||||
item_rect.expand_to(p);
|
||||
}
|
||||
}
|
||||
// rect_cache_dirty = false;
|
||||
//}
|
||||
|
||||
return aabb;
|
||||
return item_rect;
|
||||
}
|
||||
|
||||
bool PaintCurve2D::_edit_use_rect() const {
|
||||
@ -91,33 +94,24 @@ void PaintCurve2D::_notification(int p_what) {
|
||||
if (p_what == NOTIFICATION_DRAW && curve.is_valid()) {
|
||||
//draw the curve!!
|
||||
|
||||
if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_navigation_hint()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (curve->get_point_count() < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
const float line_width = 2 * EDSCALE;
|
||||
#else
|
||||
const float line_width = 2;
|
||||
#endif
|
||||
const Color color = Color(1.0, 1.0, 1.0, 1.0);
|
||||
if (_outline_enabled) {
|
||||
_cached_draw_pts.resize(curve->get_point_count() * 8);
|
||||
int count = 0;
|
||||
|
||||
_cached_draw_pts.resize(curve->get_point_count() * 8);
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < curve->get_point_count(); i++) {
|
||||
for (int j = 0; j < 8; j++) {
|
||||
real_t frac = j * (1.0 / 8.0);
|
||||
Vector2 p = curve->interpolate(i, frac);
|
||||
_cached_draw_pts.set(count++, p);
|
||||
for (int i = 0; i < curve->get_point_count(); i++) {
|
||||
for (int j = 0; j < 8; j++) {
|
||||
real_t frac = j * (1.0 / 8.0);
|
||||
Vector2 p = curve->interpolate(i, frac);
|
||||
_cached_draw_pts.set(count++, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
draw_polyline(_cached_draw_pts, color, line_width, true);
|
||||
draw_polyline(_cached_draw_pts, _outline_color, _outline_width, _outline_antialiased);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,15 +145,280 @@ Ref<Curve2D> PaintCurve2D::get_curve() const {
|
||||
return curve;
|
||||
}
|
||||
|
||||
void PaintCurve2D::set_offset(const Vector2 &p_offset) {
|
||||
offset = p_offset;
|
||||
rect_cache_dirty = true;
|
||||
update();
|
||||
_change_notify("offset");
|
||||
}
|
||||
|
||||
Vector2 PaintCurve2D::get_offset() const {
|
||||
return offset;
|
||||
}
|
||||
|
||||
void PaintCurve2D::fill_set_enabled(bool p_enabled) {
|
||||
_fill_enabled = p_enabled;
|
||||
update();
|
||||
}
|
||||
bool PaintCurve2D::fill_get_enabled() const {
|
||||
return _fill_enabled;
|
||||
}
|
||||
|
||||
void PaintCurve2D::fill_set_color(const Color &p_color) {
|
||||
_fill_color = p_color;
|
||||
update();
|
||||
}
|
||||
Color PaintCurve2D::fill_get_color() const {
|
||||
return _fill_color;
|
||||
}
|
||||
|
||||
void PaintCurve2D::fill_set_texture(const Ref<Texture> &p_texture) {
|
||||
_fill_texture = p_texture;
|
||||
|
||||
update();
|
||||
}
|
||||
Ref<Texture> PaintCurve2D::fill_get_texture() const {
|
||||
return _fill_texture;
|
||||
}
|
||||
|
||||
void PaintCurve2D::fill_set_texture_offset(const Vector2 &p_offset) {
|
||||
_fill_tex_ofs = p_offset;
|
||||
update();
|
||||
}
|
||||
Vector2 PaintCurve2D::fill_get_texture_offset() const {
|
||||
return _fill_tex_ofs;
|
||||
}
|
||||
|
||||
void PaintCurve2D::fill_set_texture_rotation(float p_rot) {
|
||||
_fill_tex_rot = p_rot;
|
||||
update();
|
||||
}
|
||||
float PaintCurve2D::fill_get_texture_rotation() const {
|
||||
return _fill_tex_rot;
|
||||
}
|
||||
|
||||
void PaintCurve2D::fill_set_texture_rotation_degrees(float p_rot) {
|
||||
fill_set_texture_rotation(Math::deg2rad(p_rot));
|
||||
}
|
||||
float PaintCurve2D::fill_get_texture_rotation_degrees() const {
|
||||
return Math::rad2deg(fill_get_texture_rotation());
|
||||
}
|
||||
|
||||
void PaintCurve2D::fill_set_texture_scale(const Size2 &p_scale) {
|
||||
_fill_tex_scale = p_scale;
|
||||
update();
|
||||
}
|
||||
Size2 PaintCurve2D::fill_get_texture_scale() const {
|
||||
return _fill_tex_scale;
|
||||
}
|
||||
|
||||
void PaintCurve2D::fill_set_invert(bool p_invert) {
|
||||
_fill_invert = p_invert;
|
||||
update();
|
||||
}
|
||||
bool PaintCurve2D::fill_get_invert() const {
|
||||
return _fill_invert;
|
||||
}
|
||||
|
||||
void PaintCurve2D::fill_set_antialiased(bool p_antialiased) {
|
||||
_fill_antialiased = p_antialiased;
|
||||
update();
|
||||
}
|
||||
bool PaintCurve2D::fill_get_antialiased() const {
|
||||
return _fill_antialiased;
|
||||
}
|
||||
|
||||
void PaintCurve2D::fill_set_invert_border(float p_invert_border) {
|
||||
_fill_invert_border = p_invert_border;
|
||||
update();
|
||||
}
|
||||
float PaintCurve2D::fill_get_invert_border() const {
|
||||
return _fill_invert_border;
|
||||
}
|
||||
|
||||
void PaintCurve2D::outline_set_enabled(bool p_enabled) {
|
||||
_outline_enabled = p_enabled;
|
||||
update();
|
||||
}
|
||||
bool PaintCurve2D::outline_get_enabled() const {
|
||||
return _outline_enabled;
|
||||
}
|
||||
|
||||
void PaintCurve2D::outline_set_width(int p_width) {
|
||||
_outline_width = p_width;
|
||||
update();
|
||||
}
|
||||
int PaintCurve2D::outline_get_width() const {
|
||||
return _outline_width;
|
||||
}
|
||||
|
||||
void PaintCurve2D::outline_set_color(const Color &p_color) {
|
||||
_outline_color = p_color;
|
||||
update();
|
||||
}
|
||||
Color PaintCurve2D::outline_get_color() const {
|
||||
return _outline_color;
|
||||
}
|
||||
|
||||
void PaintCurve2D::outline_set_texture(const Ref<Texture> &p_texture) {
|
||||
_outline_texture = p_texture;
|
||||
|
||||
update();
|
||||
}
|
||||
Ref<Texture> PaintCurve2D::outline_get_texture() const {
|
||||
return _outline_texture;
|
||||
}
|
||||
|
||||
void PaintCurve2D::outline_set_texture_offset(const Vector2 &p_offset) {
|
||||
_outline_tex_ofs = p_offset;
|
||||
update();
|
||||
}
|
||||
Vector2 PaintCurve2D::outline_get_texture_offset() const {
|
||||
return _outline_tex_ofs;
|
||||
}
|
||||
|
||||
void PaintCurve2D::outline_set_texture_rotation(float p_rot) {
|
||||
_outline_tex_rot = p_rot;
|
||||
update();
|
||||
}
|
||||
float PaintCurve2D::outline_get_texture_rotation() const {
|
||||
return _outline_tex_rot;
|
||||
}
|
||||
|
||||
void PaintCurve2D::outline_set_texture_rotation_degrees(float p_rot) {
|
||||
outline_set_texture_rotation(Math::deg2rad(p_rot));
|
||||
}
|
||||
float PaintCurve2D::outline_get_texture_rotation_degrees() const {
|
||||
return Math::rad2deg(outline_get_texture_rotation());
|
||||
}
|
||||
|
||||
void PaintCurve2D::outline_set_texture_scale(const Size2 &p_scale) {
|
||||
_outline_tex_scale = p_scale;
|
||||
update();
|
||||
}
|
||||
Size2 PaintCurve2D::outline_get_texture_scale() const {
|
||||
return _outline_tex_scale;
|
||||
}
|
||||
|
||||
void PaintCurve2D::outline_set_antialiased(bool p_antialiased) {
|
||||
_outline_antialiased = p_antialiased;
|
||||
update();
|
||||
}
|
||||
bool PaintCurve2D::outline_get_antialiased() const {
|
||||
return _outline_antialiased;
|
||||
}
|
||||
|
||||
void PaintCurve2D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_curve", "curve"), &PaintCurve2D::set_curve);
|
||||
ClassDB::bind_method(D_METHOD("get_curve"), &PaintCurve2D::get_curve);
|
||||
ClassDB::bind_method(D_METHOD("_curve_changed"), &PaintCurve2D::_curve_changed);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_offset", "offset"), &PaintCurve2D::set_offset);
|
||||
ClassDB::bind_method(D_METHOD("get_offset"), &PaintCurve2D::get_offset);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("fill_set_enabled", "enabled"), &PaintCurve2D::fill_set_enabled);
|
||||
ClassDB::bind_method(D_METHOD("fill_get_enabled"), &PaintCurve2D::fill_get_enabled);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("fill_set_color", "color"), &PaintCurve2D::fill_set_color);
|
||||
ClassDB::bind_method(D_METHOD("fill_get_color"), &PaintCurve2D::fill_get_color);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("fill_set_texture", "texture"), &PaintCurve2D::fill_set_texture);
|
||||
ClassDB::bind_method(D_METHOD("fill_get_texture"), &PaintCurve2D::fill_get_texture);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("fill_set_texture_offset", "texture_offset"), &PaintCurve2D::fill_set_texture_offset);
|
||||
ClassDB::bind_method(D_METHOD("fill_get_texture_offset"), &PaintCurve2D::fill_get_texture_offset);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("fill_set_texture_rotation", "texture_rotation"), &PaintCurve2D::fill_set_texture_rotation);
|
||||
ClassDB::bind_method(D_METHOD("fill_get_texture_rotation"), &PaintCurve2D::fill_get_texture_rotation);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("fill_set_texture_rotation_degrees", "texture_rotation"), &PaintCurve2D::fill_set_texture_rotation_degrees);
|
||||
ClassDB::bind_method(D_METHOD("fill_get_texture_rotation_degrees"), &PaintCurve2D::fill_get_texture_rotation_degrees);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("fill_set_texture_scale", "texture_scale"), &PaintCurve2D::fill_set_texture_scale);
|
||||
ClassDB::bind_method(D_METHOD("fill_get_texture_scale"), &PaintCurve2D::fill_get_texture_scale);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("fill_set_invert", "invert"), &PaintCurve2D::fill_set_invert);
|
||||
ClassDB::bind_method(D_METHOD("fill_get_invert"), &PaintCurve2D::fill_get_invert);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("fill_set_antialiased", "antialiased"), &PaintCurve2D::fill_set_antialiased);
|
||||
ClassDB::bind_method(D_METHOD("fill_get_antialiased"), &PaintCurve2D::fill_get_antialiased);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("fill_set_invert_border", "invert_border"), &PaintCurve2D::fill_set_invert_border);
|
||||
ClassDB::bind_method(D_METHOD("fill_get_invert_border"), &PaintCurve2D::fill_get_invert_border);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("outline_set_enabled", "enabled"), &PaintCurve2D::outline_set_enabled);
|
||||
ClassDB::bind_method(D_METHOD("outline_get_enabled"), &PaintCurve2D::outline_get_enabled);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("outline_set_width", "width"), &PaintCurve2D::outline_set_width);
|
||||
ClassDB::bind_method(D_METHOD("outline_get_width"), &PaintCurve2D::outline_get_width);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("outline_set_color", "color"), &PaintCurve2D::outline_set_color);
|
||||
ClassDB::bind_method(D_METHOD("outline_get_color"), &PaintCurve2D::outline_get_color);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("outline_set_texture", "texture"), &PaintCurve2D::outline_set_texture);
|
||||
ClassDB::bind_method(D_METHOD("outline_get_texture"), &PaintCurve2D::outline_get_texture);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("outline_set_texture_offset", "texture_offset"), &PaintCurve2D::outline_set_texture_offset);
|
||||
ClassDB::bind_method(D_METHOD("outline_get_texture_offset"), &PaintCurve2D::outline_get_texture_offset);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("outline_set_texture_rotation", "texture_rotation"), &PaintCurve2D::outline_set_texture_rotation);
|
||||
ClassDB::bind_method(D_METHOD("outline_get_texture_rotation"), &PaintCurve2D::outline_get_texture_rotation);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("outline_set_texture_rotation_degrees", "texture_rotation"), &PaintCurve2D::outline_set_texture_rotation_degrees);
|
||||
ClassDB::bind_method(D_METHOD("outline_get_texture_rotation_degrees"), &PaintCurve2D::outline_get_texture_rotation_degrees);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("outline_set_texture_scale", "texture_scale"), &PaintCurve2D::outline_set_texture_scale);
|
||||
ClassDB::bind_method(D_METHOD("outline_get_texture_scale"), &PaintCurve2D::outline_get_texture_scale);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("outline_set_antialiased", "antialiased"), &PaintCurve2D::outline_set_antialiased);
|
||||
ClassDB::bind_method(D_METHOD("outline_get_antialiased"), &PaintCurve2D::outline_get_antialiased);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve2D"), "set_curve", "get_curve");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset");
|
||||
|
||||
ADD_GROUP("Fill", "fill_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fill_enabled"), "fill_set_enabled", "fill_get_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "fill_color"), "fill_set_color", "fill_get_color");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "fill_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "fill_set_texture", "fill_get_texture");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "fill_texture_offset"), "fill_set_texture_offset", "fill_get_texture_offset");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "fill_texture_scale", PROPERTY_HINT_LINK), "fill_set_texture_scale", "fill_get_texture_scale");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "fill_texture_rotation_degrees", PROPERTY_HINT_RANGE, "-360,360,0.1,or_lesser,or_greater"), "fill_set_texture_rotation_degrees", "fill_get_texture_rotation_degrees");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "fill_texture_rotation", PROPERTY_HINT_NONE, "", 0), "fill_set_texture_rotation", "fill_get_texture_rotation");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fill_invert_enable"), "fill_set_invert", "fill_get_invert");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "fill_invert_border", PROPERTY_HINT_RANGE, "0.1,16384,0.1"), "fill_set_invert_border", "fill_get_invert_border");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fill_antialiased"), "fill_set_antialiased", "fill_get_antialiased");
|
||||
|
||||
ADD_GROUP("Outline", "outline_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "outline_enabled"), "outline_set_enabled", "outline_get_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "outline_color"), "outline_set_color", "outline_get_color");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "outline_width"), "outline_set_width", "outline_get_width");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "outline_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "outline_set_texture", "outline_get_texture");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "outline_texture_offset"), "outline_set_texture_offset", "outline_get_texture_offset");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "outline_texture_scale", PROPERTY_HINT_LINK), "outline_set_texture_scale", "outline_get_texture_scale");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "outline_texture_rotation_degrees", PROPERTY_HINT_RANGE, "-360,360,0.1,or_lesser,or_greater"), "outline_set_texture_rotation_degrees", "outline_get_texture_rotation_degrees");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "outline_texture_rotation", PROPERTY_HINT_NONE, "", 0), "outline_set_texture_rotation", "outline_get_texture_rotation");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "outline_antialiased"), "outline_set_antialiased", "outline_get_antialiased");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_curve_changed"), &PaintCurve2D::_curve_changed);
|
||||
}
|
||||
|
||||
PaintCurve2D::PaintCurve2D() {
|
||||
set_curve(Ref<Curve2D>(memnew(Curve2D))); //create one by default
|
||||
set_self_modulate(Color(0.5, 0.6, 1.0, 0.7));
|
||||
//set_self_modulate(Color(0.5, 0.6, 1.0, 0.7));
|
||||
|
||||
_fill_enabled = true;
|
||||
_fill_color = Color(1, 1, 1);
|
||||
_fill_tex_tile = false;
|
||||
_fill_tex_rot = 0;
|
||||
_fill_invert = false;
|
||||
_fill_invert_border = 0;
|
||||
_fill_antialiased = false;
|
||||
|
||||
_outline_enabled = true;
|
||||
//_outline_color = Color(0.5, 0.6, 1.0, 0.7);
|
||||
_outline_width = 2;
|
||||
_outline_tex_tile = false;
|
||||
_outline_tex_rot = 0;
|
||||
_outline_antialiased = true;
|
||||
|
||||
rect_cache_dirty = true;
|
||||
}
|
||||
|
@ -38,15 +38,6 @@ class Curve2D;
|
||||
class PaintCurve2D : public PaintNode {
|
||||
GDCLASS(PaintCurve2D, PaintNode);
|
||||
|
||||
Ref<Curve2D> curve;
|
||||
Vector<Vector2> _cached_draw_pts;
|
||||
|
||||
void _curve_changed();
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
#ifdef TOOLS_ENABLED
|
||||
virtual Rect2 _edit_get_rect() const;
|
||||
@ -57,7 +48,146 @@ public:
|
||||
void set_curve(const Ref<Curve2D> &p_curve);
|
||||
Ref<Curve2D> get_curve() const;
|
||||
|
||||
void set_offset(const Vector2 &p_offset);
|
||||
Vector2 get_offset() const;
|
||||
|
||||
void fill_set_enabled(bool p_enabled);
|
||||
bool fill_get_enabled() const;
|
||||
|
||||
void fill_set_color(const Color &p_color);
|
||||
Color fill_get_color() const;
|
||||
|
||||
void fill_set_texture(const Ref<Texture> &p_texture);
|
||||
Ref<Texture> fill_get_texture() const;
|
||||
|
||||
void fill_set_texture_offset(const Vector2 &p_offset);
|
||||
Vector2 fill_get_texture_offset() const;
|
||||
|
||||
void fill_set_texture_rotation(float p_rot);
|
||||
float fill_get_texture_rotation() const;
|
||||
|
||||
void fill_set_texture_rotation_degrees(float p_rot);
|
||||
float fill_get_texture_rotation_degrees() const;
|
||||
|
||||
void fill_set_texture_scale(const Size2 &p_scale);
|
||||
Size2 fill_get_texture_scale() const;
|
||||
|
||||
void fill_set_invert(bool p_invert);
|
||||
bool fill_get_invert() const;
|
||||
|
||||
void fill_set_antialiased(bool p_antialiased);
|
||||
bool fill_get_antialiased() const;
|
||||
|
||||
void fill_set_invert_border(float p_invert_border);
|
||||
float fill_get_invert_border() const;
|
||||
|
||||
void outline_set_enabled(bool p_enabled);
|
||||
bool outline_get_enabled() const;
|
||||
|
||||
void outline_set_width(int p_width);
|
||||
int outline_get_width() const;
|
||||
|
||||
void outline_set_color(const Color &p_color);
|
||||
Color outline_get_color() const;
|
||||
|
||||
void outline_set_texture(const Ref<Texture> &p_texture);
|
||||
Ref<Texture> outline_get_texture() const;
|
||||
|
||||
void outline_set_texture_offset(const Vector2 &p_offset);
|
||||
Vector2 outline_get_texture_offset() const;
|
||||
|
||||
void outline_set_texture_rotation(float p_rot);
|
||||
float outline_get_texture_rotation() const;
|
||||
|
||||
void outline_set_texture_rotation_degrees(float p_rot);
|
||||
float outline_get_texture_rotation_degrees() const;
|
||||
|
||||
void outline_set_texture_scale(const Size2 &p_scale);
|
||||
Size2 outline_get_texture_scale() const;
|
||||
|
||||
void outline_set_antialiased(bool p_antialiased);
|
||||
bool outline_get_antialiased() const;
|
||||
|
||||
PaintCurve2D();
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
static void _bind_methods();
|
||||
|
||||
protected:
|
||||
bool _fill_enabled;
|
||||
Color _fill_color;
|
||||
Ref<Texture> _fill_texture;
|
||||
Size2 _fill_tex_scale;
|
||||
Vector2 _fill_tex_ofs;
|
||||
bool _fill_tex_tile;
|
||||
float _fill_tex_rot;
|
||||
bool _fill_invert;
|
||||
float _fill_invert_border;
|
||||
bool _fill_antialiased;
|
||||
|
||||
bool _outline_enabled;
|
||||
Color _outline_color;
|
||||
int _outline_width;
|
||||
Ref<Texture> _outline_texture;
|
||||
Size2 _outline_tex_scale;
|
||||
Vector2 _outline_tex_ofs;
|
||||
bool _outline_tex_tile;
|
||||
float _outline_tex_rot;
|
||||
bool _outline_antialiased;
|
||||
|
||||
Vector2 offset;
|
||||
mutable bool rect_cache_dirty;
|
||||
mutable Rect2 item_rect;
|
||||
Ref<Image> _rendered_image;
|
||||
|
||||
Ref<Curve2D> curve;
|
||||
Vector<Vector2> _cached_draw_pts;
|
||||
|
||||
void _curve_changed();
|
||||
|
||||
protected:
|
||||
struct Slope {
|
||||
Vector2 position_current;
|
||||
Vector2 position_step;
|
||||
|
||||
Vector2 uv_current;
|
||||
Vector2 uv_step;
|
||||
|
||||
Color color_current;
|
||||
Color color_step;
|
||||
|
||||
_FORCE_INLINE_ void setup_position(Vector2 begin, Vector2 end, float num_steps) {
|
||||
float inv_step = 1.0 / num_steps;
|
||||
position_step = (end - begin) * Vector2(inv_step, inv_step);
|
||||
position_current = begin;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void setup_color(Color begin, Color end, float num_steps) {
|
||||
float inv_step = 1.0 / num_steps;
|
||||
color_step = (end - begin) * Color(inv_step, inv_step, inv_step);
|
||||
color_current = begin;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void setup_uv(Vector2 begin, Vector2 end, float num_steps) {
|
||||
float inv_step = 1.0 / num_steps;
|
||||
uv_step = (end - begin) * Vector2(inv_step, inv_step);
|
||||
uv_current = begin;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void advance() {
|
||||
position_current += position_step;
|
||||
color_current += color_step;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void advance_color() {
|
||||
color_current += color_step;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void advance_uv() {
|
||||
uv_current += uv_step;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
#endif // PATH_2D_H
|
||||
|
Loading…
Reference in New Issue
Block a user