1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-16 14:00:40 +00:00

Add interpolation modes to Gradient

- Linear, Constant, and Cubic interpolation modes
- Partial backport of #53321
This commit is contained in:
FireForge
2022-05-12 12:51:56 -05:00
parent 288370609c
commit f17c5fa7bd
6 changed files with 110 additions and 41 deletions

View File

@@ -45,6 +45,8 @@ void GradientEditor::_gradient_changed() {
editing = true;
Vector<Gradient::Point> points = gradient->get_points();
set_points(points);
set_interpolation_mode(gradient->get_interpolation_mode());
update();
editing = false;
}
@@ -54,8 +56,10 @@ void GradientEditor::_ramp_changed() {
undo_redo->create_action(TTR("Gradient Edited"), UndoRedo::MERGE_ENDS);
undo_redo->add_do_method(gradient.ptr(), "set_offsets", get_offsets());
undo_redo->add_do_method(gradient.ptr(), "set_colors", get_colors());
undo_redo->add_do_method(gradient.ptr(), "set_interpolation_mode", get_interpolation_mode());
undo_redo->add_undo_method(gradient.ptr(), "set_offsets", gradient->get_offsets());
undo_redo->add_undo_method(gradient.ptr(), "set_colors", gradient->get_colors());
undo_redo->add_undo_method(gradient.ptr(), "set_interpolation_mode", gradient->get_interpolation_mode());
undo_redo->commit_action();
editing = false;
}
@@ -70,6 +74,7 @@ void GradientEditor::set_gradient(const Ref<Gradient> &p_gradient) {
connect("ramp_changed", this, "_ramp_changed");
gradient->connect("changed", this, "_gradient_changed");
set_points(gradient->get_points());
set_interpolation_mode(gradient->get_interpolation_mode());
}
GradientEditor::GradientEditor() {