How can I rotate the Image in Canvas?

74 views
Skip to first unread message

sagar.c...@gmail.com

unread,
Dec 27, 2018, 4:19:31 AM12/27/18
to Marvin Project
We need to rotate the image in canvas, as found some code but still not working. Rotate images are cut down,

for(var y=0; y<imageIn.getHeight(); y++){
            for(var x=0; x<imageIn.getWidth(); x++){
                var newX = (imageIn.getHeight() - 1) - y;
                var newY = x;
                imageOut.setIntColor(newX, newY, imageIn.getIntColor(x, y));
            }
        }

Can you please let me know if you will have updated version of JS?

Gabriel Ambrósio Archanjo

unread,
Dec 27, 2018, 6:05:07 AM12/27/18
to Marvin Project
Please, post a JSFiddle of your code. Create a new one here:

Sagar Patel

unread,
Jan 1, 2019, 3:39:28 AM1/1/19
to marvin-...@googlegroups.com
Yes, I have checked that and rotate function as you have given that will only works for the square images, it's not working for the rectangle image i.e. 700x525

Here is the logic,

for(var y=0; y<imageIn.getHeight(); y++){
for(var x=0; x<imageIn.getWidth(); x++){
var newX = (imageIn.getHeight() - 1) - y;
                var newY = x;
                imageOut.setIntColor(newX, newY, imageIn.getIntColor(x, y));
}
}
}
Can you please help me?

On Thu, Dec 27, 2018 at 4:35 PM Gabriel Ambrósio Archanjo <leirb...@gmail.com> wrote:
Please, post a JSFiddle of your code. Create a new one here:

--
You received this message because you are subscribed to the Google Groups "Marvin Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to marvin-projec...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages