This is a very simplified program showing my problem. I need to draw to an image that is rotated. I can’t use any of processing’s line or point functions because of different type brushes in the real program. I have to draw directly to the pixel data. This program plots 4 black pixels under the mouse when its pressed. It works fine on the image that isn’t rotated, but I need to know how to translate the x and y position so it works when the image is rotated. Here’s the simple program:
I got it I found the answer here : https://homepages.inf.ed.ac.uk/rbf/HIPR2/rotate.htm
The description is a little off. The angle needs to be in radians and not degrees and for it to work for my needs, I had to find the values of the negative angle.
But this is the translation for the mouse coordinates:
I looked at screenX() and screenY() but they gave me the opposite of what I need. It would be as if above, I used rotation instead of -rotation. Thanks for the reply.
mx = (int)modelX(mouseX,mouseY,0);
my = (int)modelY(mouseX,mouseY,0);
Still doesn’t work. It gives me the opposite of what I need to draw on the pixel data under the mouse pointer. Play with that second sketch I posted ( the one that works). Try screenX()/modelX() etc. and see if you can get it it to paint under the mouse pointer. It would make clearer code. I just can’t get it to work.
Sorry, I can say as I don’t used version 2. You can try and tell us. You can also check the source code. It is not too dense and you should be able to pin point the transformation there easily, which it should be close to what you have if it is not the same. I just suggest using that library as it is taking care of the transformation for you. However, you can just use what you already have if it is working for you.