diff --git a/src/Point.cpp b/src/Point.cpp index 4636b437..006d84e4 100644 --- a/src/Point.cpp +++ b/src/Point.cpp @@ -33,58 +33,27 @@ using namespace std; using namespace openshot; -// Default constructor (defaults to 1,0) -Point::Point() : interpolation(BEZIER), handle_type(AUTO) -{ - // set new coorinate - co = Coordinate(1, 0); - - // set handles - Initialize_Handles(); -} +// Default constructor +Point::Point() : Point::Point(Coordinate(1, 0), BEZIER, AUTO) {}; // Constructor which creates a single coordinate at X=1 -Point::Point(float y) : - interpolation(CONSTANT), handle_type(AUTO) { - // set new coorinate - co = Coordinate(1, y); +Point::Point(float y) : Point::Point(Coordinate(1, y), CONSTANT, AUTO) {}; - // set handles - Initialize_Handles(); -} +// Constructor which creates a Bezier curve with point at (x, y) +Point::Point(float x, float y) : Point::Point(Coordinate(x, y), BEZIER, AUTO) {}; -Point::Point(float x, float y) : - interpolation(BEZIER), handle_type(AUTO) { - // set new coorinate - co = Coordinate(x, y); +// Constructor which also creates a Point, setting X,Y, and interpolation. +Point::Point(float x, float y, InterpolationType interpolation) + : Point::Point(Coordinate(x, y), interpolation, AUTO) {}; - // set handles - Initialize_Handles(); -} -// Constructor which also creates a Point and sets the X,Y, and interpolation of the Point. -Point::Point(float x, float y, InterpolationType interpolation) : - handle_type(AUTO), interpolation(interpolation) { - // set new coorinate - co = Coordinate(x, y); +// Direct Coordinate-accepting constructors +Point::Point(const Coordinate& co) : Point::Point(co, BEZIER, AUTO) {}; - // set handles - Initialize_Handles(); -} +Point::Point(const Coordinate& co, InterpolationType interpolation) + : Point::Point(co, interpolation, AUTO) {}; -Point::Point(Coordinate co) : - co(co), interpolation(BEZIER), handle_type(AUTO) { - // set handles - Initialize_Handles(); -} - -Point::Point(Coordinate co, InterpolationType interpolation) : - co(co), interpolation(interpolation), handle_type(AUTO) { - // set handles - Initialize_Handles(); -} - -Point::Point(Coordinate co, InterpolationType interpolation, HandleType handle_type) : +Point::Point(const Coordinate& co, InterpolationType interpolation, HandleType handle_type) : co(co), interpolation(interpolation), handle_type(handle_type) { // set handles Initialize_Handles(); diff --git a/src/Point.h b/src/Point.h index 4941c558..d6ff1d87 100644 --- a/src/Point.h +++ b/src/Point.h @@ -100,13 +100,13 @@ namespace openshot Point(float x, float y, InterpolationType interpolation); /// Constructor which takes a coordinate - Point(Coordinate co); + Point(const Coordinate& co); /// Constructor which takes a coordinate and interpolation mode - Point(Coordinate co, InterpolationType interpolation); + Point(const Coordinate& co, InterpolationType interpolation); /// Constructor which takes a coordinate, interpolation mode, and handle type - Point(Coordinate co, InterpolationType interpolation, HandleType handle_type); + Point(const Coordinate& co, InterpolationType interpolation, HandleType handle_type); /// Set the left and right handles to a percent of the primary coordinate (0 to 1) /// Defaults to a smooth curve (Ease in and out)