reviewpana.blogg.se

How to customize cursor processing
How to customize cursor processing






how to customize cursor processing

Compute the distance between the ball and the cursorįloat distanceFromMouse = repulsionForce.mag() PVector repulsionForce = PVector.sub(ballLocation, mouseLocation) The force is the difference between the two locations PVector mouseLocation = new PVector(mouseX, mouseY) In Processing, you would do : // A position is also a vector This force depends on the distance d from the ball to the mouse since we want them to be more pushed away as soon as they are close to the mouseĪ force can be represented as a vector, here represented at the origin of the ball. The idea is to apply a force on the Ball that is in the opposite direction compared to the mouse cursor. If you don’t really know how they work, you can check this tutorial on the Processing website : Since we are doing some geometry here, you need to think with vectors.








How to customize cursor processing