MCPcopy Create free account
hub / github.com/andrewreeman/SpectralSuite / clipX

Method clipX

shared/components/ControlPointComponent.cpp:201–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199}
200
201int ControlPointComponent::clipX(int newX, int pointIndex) {
202 if(pointIndex == 0) {
203 return points.getFirst().getX();
204 }
205
206 if(pointIndex == points.size() -1) {
207 return points.getLast().getX();
208 }
209
210 auto pointBefore = points.getReference(pointIndex - 1);
211 auto pointAfter = points.getReference(pointIndex + 1);
212
213 static int threshold = 5;
214 if(newX < (pointBefore.getX() + threshold)) {
215 return points.getReference(pointIndex).getX();
216 }
217
218 if(newX > (pointAfter.getX() - threshold)) {
219 return points.getReference(pointIndex).getX();
220 }
221
222 return newX;
223}
224
225int ControlPointComponent::clipY(int newY, int) {
226 auto padding = 0;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected