I’m trying to draw a rectangle on the canvas with the center at the touch point. I’m using the following code:
canvas.drawRect((point.x + 15), (point.y + 15),(point.x + 15),(point.y + 15), paint);
But it doesn’t work.
But when I use,
canvas.drawRect(point.x , point.y ,(point.x + 30),(point.y + 30), paint);
amazingly,it works. But the only harm is it is not centered at the touch coordinates.The top left of the rectangle coincides with the touch coordinates.
Where am I going wrong?
Your x,y pairs are both
You want the first pair to be