MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / AddPoint

Method AddPoint

src/KeyFrame.cpp:131–153  ·  view source on GitHub ↗

Add a new point on the key-frame. Each point has a primary coordinate, a left handle, and a right handle.

Source from the content-addressed store, hash-verified

129// Add a new point on the key-frame. Each point has a primary coordinate,
130// a left handle, and a right handle.
131void Keyframe::AddPoint(Point p) {
132 // candidate is not less (greater or equal) than the new point in
133 // the X coordinate.
134 std::vector<Point>::iterator candidate =
135 std::lower_bound(begin(Points), end(Points), p.co.X, IsPointBeforeX);
136 if (candidate == end(Points)) {
137 // New point X is greater than all other points' X, add to
138 // back.
139 Points.push_back(p);
140 } else if ((*candidate).co.X == p.co.X) {
141 // New point is at same X coordinate as some point, overwrite
142 // point.
143 *candidate = p;
144 } else {
145 // New point needs to be inserted before candidate; thus move
146 // candidate and all following one to the right and insert new
147 // point then where candidate was.
148 size_t const candidate_index = candidate - begin(Points);
149 Points.push_back(p); // Make space; could also be a dummy point. INVALIDATES candidate!
150 std::move_backward(begin(Points) + candidate_index, end(Points) - 1, end(Points));
151 Points[candidate_index] = p;
152 }
153}
154
155// Add a new point on the key-frame, interpolate is optional (default: BEZIER)
156void Keyframe::AddPoint(double x, double y, InterpolationType interpolate)

Callers 8

Clip.cppFile · 0.80
KeyFrame.cppFile · 0.80
Timeline.cppFile · 0.80
QtImageReader.cppFile · 0.80
Color.cppFile · 0.80
mainFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected