In the mousePressed() method, the mouseX and mouseY are divided respectively by width and height. All these are values provided by Processing, and are integers. However, in order to obtain a ratio, they would have to be floats. At this time, they are cast as floats so that the calculation works:
float ratioX = float(mouseX) / float(width);
float ratioY = float(mouseY) / float(height);
Investigate if there is a better way to obtain that ratio.
https://processing.org/reference/width.html
https://processing.org/reference/height.html
https://processing.org/reference/mouseX.html
https://processing.org/reference/mouseY.html
In the
mousePressed()method, themouseXandmouseYare divided respectively bywidthandheight. All these are values provided by Processing, and are integers. However, in order to obtain a ratio, they would have to be floats. At this time, they are cast as floats so that the calculation works:Investigate if there is a better way to obtain that ratio.
https://processing.org/reference/width.html
https://processing.org/reference/height.html
https://processing.org/reference/mouseX.html
https://processing.org/reference/mouseY.html