aboutsummaryrefslogtreecommitdiff
path: root/scene/resources/color_ramp.cpp
diff options
context:
space:
mode:
authorRémi Verschelde2017-03-05 16:44:50 +0100
committerRémi Verschelde2017-03-05 16:44:50 +0100
commit5dbf1809c6e3e905b94b8764e99491e608122261 (patch)
tree5e5a5360db15d86d59ec8c6e4f7eb511388c5a9a /scene/resources/color_ramp.cpp
parent45438e9918d421b244bfd7776a30e67dc7f2d3e3 (diff)
downloadgodot-5dbf180.tar.gz
godot-5dbf180.tar.zst
godot-5dbf180.zip
A Whole New World (clang-format edition)
I can show you the code Pretty, with proper whitespace Tell me, coder, now when did You last write readable code? I can open your eyes Make you see your bad indent Force you to respect the style The core devs agreed upon A whole new world A new fantastic code format A de facto standard With some sugar Enforced with clang-format A whole new world A dazzling style we all dreamed of And when we read it through It's crystal clear That now we're in a whole new world of code
Diffstat (limited to 'scene/resources/color_ramp.cpp')
-rw-r--r--scene/resources/color_ramp.cpp86
1 files changed, 38 insertions, 48 deletions
diff --git a/scene/resources/color_ramp.cpp b/scene/resources/color_ramp.cpp
index b14ba4c8e..2c20ad527 100644
--- a/scene/resources/color_ramp.cpp
+++ b/scene/resources/color_ramp.cpp
@@ -38,51 +38,45 @@
ColorRamp::ColorRamp() {
//Set initial color ramp transition from black to white
points.resize(2);
- points[0].color = Color(0,0,0,1);
+ points[0].color = Color(0, 0, 0, 1);
points[0].offset = 0;
- points[1].color = Color(1,1,1,1);
+ points[1].color = Color(1, 1, 1, 1);
points[1].offset = 1;
is_sorted = true;
}
ColorRamp::~ColorRamp() {
-
}
void ColorRamp::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("add_point", "offset", "color"), &ColorRamp::add_point);
+ ClassDB::bind_method(D_METHOD("remove_point", "offset", "color"), &ColorRamp::remove_point);
+ ClassDB::bind_method(D_METHOD("set_offset", "point", "offset"), &ColorRamp::set_offset);
+ ClassDB::bind_method(D_METHOD("get_offset", "point"), &ColorRamp::get_offset);
+ ClassDB::bind_method(D_METHOD("set_color", "point", "color"), &ColorRamp::set_color);
+ ClassDB::bind_method(D_METHOD("get_color", "point"), &ColorRamp::get_color);
+ ClassDB::bind_method(D_METHOD("interpolate", "offset"), &ColorRamp::get_color_at_offset);
- ClassDB::bind_method(D_METHOD("add_point","offset","color"),&ColorRamp::add_point);
- ClassDB::bind_method(D_METHOD("remove_point","offset","color"),&ColorRamp::remove_point);
-
- ClassDB::bind_method(D_METHOD("set_offset","point","offset"),&ColorRamp::set_offset);
- ClassDB::bind_method(D_METHOD("get_offset","point"),&ColorRamp::get_offset);
-
- ClassDB::bind_method(D_METHOD("set_color","point","color"),&ColorRamp::set_color);
- ClassDB::bind_method(D_METHOD("get_color","point"),&ColorRamp::get_color);
+ ClassDB::bind_method(D_METHOD("get_point_count"), &ColorRamp::get_points_count);
- ClassDB::bind_method(D_METHOD("interpolate","offset"),&ColorRamp::get_color_at_offset);
+ ClassDB::bind_method(D_METHOD(COLOR_RAMP_SET_OFFSETS, "offsets"), &ColorRamp::set_offsets);
+ ClassDB::bind_method(D_METHOD(COLOR_RAMP_GET_OFFSETS), &ColorRamp::get_offsets);
- ClassDB::bind_method(D_METHOD("get_point_count"),&ColorRamp::get_points_count);
+ ClassDB::bind_method(D_METHOD(COLOR_RAMP_SET_COLORS, "colors"), &ColorRamp::set_colors);
+ ClassDB::bind_method(D_METHOD(COLOR_RAMP_GET_COLORS), &ColorRamp::get_colors);
- ClassDB::bind_method(D_METHOD(COLOR_RAMP_SET_OFFSETS,"offsets"),&ColorRamp::set_offsets);
- ClassDB::bind_method(D_METHOD(COLOR_RAMP_GET_OFFSETS),&ColorRamp::get_offsets);
-
- ClassDB::bind_method(D_METHOD(COLOR_RAMP_SET_COLORS,"colors"),&ColorRamp::set_colors);
- ClassDB::bind_method(D_METHOD(COLOR_RAMP_GET_COLORS),&ColorRamp::get_colors);
-
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"offsets"),COLOR_RAMP_SET_OFFSETS,COLOR_RAMP_GET_OFFSETS) ;
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"colors"),COLOR_RAMP_SET_COLORS,COLOR_RAMP_GET_COLORS) ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "offsets"), COLOR_RAMP_SET_OFFSETS, COLOR_RAMP_GET_OFFSETS);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "colors"), COLOR_RAMP_SET_COLORS, COLOR_RAMP_GET_COLORS);
}
Vector<float> ColorRamp::get_offsets() const {
Vector<float> offsets;
offsets.resize(points.size());
- for(int i = 0; i < points.size(); i++)
- {
+ for (int i = 0; i < points.size(); i++) {
offsets[i] = points[i].offset;
}
return offsets;
@@ -91,44 +85,41 @@ Vector<float> ColorRamp::get_offsets() const {
Vector<Color> ColorRamp::get_colors() const {
Vector<Color> colors;
colors.resize(points.size());
- for(int i = 0; i < points.size(); i++)
- {
+ for (int i = 0; i < points.size(); i++) {
colors[i] = points[i].color;
}
return colors;
}
-void ColorRamp::set_offsets(const Vector<float>& p_offsets) {
+void ColorRamp::set_offsets(const Vector<float> &p_offsets) {
points.resize(p_offsets.size());
- for(int i = 0; i < points.size(); i++)
- {
+ for (int i = 0; i < points.size(); i++) {
points[i].offset = p_offsets[i];
}
is_sorted = false;
emit_signal(CoreStringNames::get_singleton()->changed);
}
-void ColorRamp::set_colors(const Vector<Color>& p_colors) {
- if(points.size()<p_colors.size())
+void ColorRamp::set_colors(const Vector<Color> &p_colors) {
+ if (points.size() < p_colors.size())
is_sorted = false;
points.resize(p_colors.size());
- for(int i = 0; i < points.size(); i++)
- {
+ for (int i = 0; i < points.size(); i++) {
points[i].color = p_colors[i];
}
emit_signal(CoreStringNames::get_singleton()->changed);
}
-Vector<ColorRamp::Point>& ColorRamp::get_points() {
+Vector<ColorRamp::Point> &ColorRamp::get_points() {
return points;
}
-void ColorRamp::add_point(float p_offset, const Color& p_color) {
+void ColorRamp::add_point(float p_offset, const Color &p_color) {
Point p;
- p.offset=p_offset;
- p.color=p_color;
- is_sorted=false;
+ p.offset = p_offset;
+ p.color = p_color;
+ is_sorted = false;
points.push_back(p);
emit_signal(CoreStringNames::get_singleton()->changed);
@@ -136,20 +127,20 @@ void ColorRamp::add_point(float p_offset, const Color& p_color) {
void ColorRamp::remove_point(int p_index) {
- ERR_FAIL_INDEX(p_index,points.size());
- ERR_FAIL_COND(points.size()<=2);
+ ERR_FAIL_INDEX(p_index, points.size());
+ ERR_FAIL_COND(points.size() <= 2);
points.remove(p_index);
emit_signal(CoreStringNames::get_singleton()->changed);
}
-void ColorRamp::set_points(Vector<ColorRamp::Point>& p_points) {
+void ColorRamp::set_points(Vector<ColorRamp::Point> &p_points) {
points = p_points;
is_sorted = false;
emit_signal(CoreStringNames::get_singleton()->changed);
}
void ColorRamp::set_offset(int pos, const float offset) {
- if(points.size() <= pos)
+ if (points.size() <= pos)
points.resize(pos + 1);
points[pos].offset = offset;
is_sorted = false;
@@ -157,14 +148,13 @@ void ColorRamp::set_offset(int pos, const float offset) {
}
float ColorRamp::get_offset(int pos) const {
- if(points.size() > pos)
+ if (points.size() > pos)
return points[pos].offset;
- return 0; //TODO: Maybe throw some error instead?
+ return 0; //TODO: Maybe throw some error instead?
}
-void ColorRamp::set_color(int pos, const Color& color) {
- if(points.size() <= pos)
- {
+void ColorRamp::set_color(int pos, const Color &color) {
+ if (points.size() <= pos) {
points.resize(pos + 1);
is_sorted = false;
}
@@ -173,9 +163,9 @@ void ColorRamp::set_color(int pos, const Color& color) {
}
Color ColorRamp::get_color(int pos) const {
- if(points.size() > pos)
+ if (points.size() > pos)
return points[pos].color;
- return Color(0,0,0,1); //TODO: Maybe throw some error instead?
+ return Color(0, 0, 0, 1); //TODO: Maybe throw some error instead?
}
int ColorRamp::get_points_count() const {