Add a new point on the key-frame. Each point has a primary coordinate, a left handle, and a right handle.
| 129 | // Add a new point on the key-frame. Each point has a primary coordinate, |
| 130 | // a left handle, and a right handle. |
| 131 | void 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) |
| 156 | void Keyframe::AddPoint(double x, double y, InterpolationType interpolate) |
no outgoing calls
no test coverage detected