Browse Source

added proper functions to ColorRamp, fixes #3034

Juan Linietsky 9 years ago
parent
commit
e2e6f3ec00
2 changed files with 37 additions and 0 deletions
  1. 34 0
      scene/resources/color_ramp.cpp
  2. 3 0
      scene/resources/color_ramp.h

+ 34 - 0
scene/resources/color_ramp.cpp

@@ -26,6 +26,23 @@ ColorRamp::~ColorRamp() {
 
 
 void ColorRamp::_bind_methods() {
 void ColorRamp::_bind_methods() {
 
 
+
+
+
+
+	ObjectTypeDB::bind_method(_MD("add_point","offset","color"),&ColorRamp::add_point);
+	ObjectTypeDB::bind_method(_MD("remove_point","offset","color"),&ColorRamp::remove_point);
+
+	ObjectTypeDB::bind_method(_MD("set_offset","point","offset"),&ColorRamp::set_offset);
+	ObjectTypeDB::bind_method(_MD("get_offset","point"),&ColorRamp::get_offset);
+
+	ObjectTypeDB::bind_method(_MD("set_color","point","color"),&ColorRamp::set_color);
+	ObjectTypeDB::bind_method(_MD("get_color","point"),&ColorRamp::get_color);
+
+	ObjectTypeDB::bind_method(_MD("interpolate","offset"),&ColorRamp::get_color_at_offset);
+
+	ObjectTypeDB::bind_method(_MD("get_point_count"),&ColorRamp::get_points_count);
+
 	ObjectTypeDB::bind_method(_MD(COLOR_RAMP_SET_OFFSETS,"offsets"),&ColorRamp::set_offsets);
 	ObjectTypeDB::bind_method(_MD(COLOR_RAMP_SET_OFFSETS,"offsets"),&ColorRamp::set_offsets);
 	ObjectTypeDB::bind_method(_MD(COLOR_RAMP_GET_OFFSETS),&ColorRamp::get_offsets);
 	ObjectTypeDB::bind_method(_MD(COLOR_RAMP_GET_OFFSETS),&ColorRamp::get_offsets);
 
 
@@ -79,6 +96,23 @@ Vector<ColorRamp::Point>& ColorRamp::get_points() {
 	return points;
 	return points;
 }
 }
 
 
+void ColorRamp::add_point(float p_offset, const Color& p_color) {
+
+	Point p;
+	p.offset=p_offset;
+	p.color=p_color;
+	is_sorted=false;
+	points.push_back(p);
+
+}
+
+void ColorRamp::remove_point(int p_index) {
+
+	ERR_FAIL_INDEX(p_index,points.size());
+	ERR_FAIL_COND(points.size()<=2);
+	points.remove(p_index);
+}
+
 void ColorRamp::set_points(Vector<ColorRamp::Point>& p_points) {
 void ColorRamp::set_points(Vector<ColorRamp::Point>& p_points) {
 	points = p_points;
 	points = p_points;
 	is_sorted = false;
 	is_sorted = false;

+ 3 - 0
scene/resources/color_ramp.h

@@ -32,6 +32,9 @@ public:
 	ColorRamp();
 	ColorRamp();
 	virtual ~ColorRamp();
 	virtual ~ColorRamp();
 
 
+	void add_point(float p_offset, const Color& p_color);
+	void remove_point(int p_index);
+
 	void set_points(Vector<Point>& points);
 	void set_points(Vector<Point>& points);
 	Vector<Point>& get_points();
 	Vector<Point>& get_points();