Reputation: 4835
I am working with Processing's rotate
function.
I have a base image and then using image()
I overlay two more smaller images on top.
I want to rotate image1 by x degrees and image2 by y degrees, but rotate
only seems to be able to rotate both at the same time.
Is there a way around this? I thought of adding+rotating image1, saving the file, then adding+rotating image2 on top of the new file, but would prefer a more efficient way.
Upvotes: 1
Views: 396
Reputation: 42174
You can definitely rotate images by different amounts, without going through the extra step of saving any files.
Step 1: First, you need to translate()
to the center of the images. If they're all the same size then that's easy, otherwise you'll have to translate()
to each center before drawing each image.
Step 2: Then just rotate()
however much you want for each image.
Step 3: Finally, draw the image.
Repeat that process for each image, and it should work fine. But keep in mind that translate()
and rotate()
calls stack, so if you call rotate(10)
and then call rotate(15)
, that's like calling rotate(25)
. To avoid this, you might use the pushMatrix()
and popMatrix()
functions. As always, the Processing reference is your best friend.
If you're still stuck, please post an MCVE and we'll go from there. Good luck.
Upvotes: 2