Skip to main content

Point.shiftFractionTowards()

The Point.shiftFractionTowards() method returns a new Point that is shifted towards the target by a fraction of the distance between this point and the target.

This method accepts values larger than 1 to go beyond the target point, or negative values to shift the point in the opposite direction.

Signature

Point point.shiftFractionTowards(Point target, float fraction)

Point.shiftFractionTowards() example

Point A Point B Point C is point A shifted 50%in the direction of point B

An example of the Point.shiftFractionTowards() method

Notes

If you need to move a point by a specific distance instead of a percentage, use Point.shiftTowards() or Point.shiftOutwards() instead.