thatguy64 Posted September 17, 2015 Share Posted September 17, 2015 I'm making a mode 7 game in java script but I ran into a problem, to turn the perspective I must rotate the image before I draw it. I have tried using the ctx.rotate() function but I don't know how to do this before I draw the image so I can save it as an image object rotated and re-draw it. Quote Link to comment Share on other sites More sharing options...
rich Posted September 17, 2015 Share Posted September 17, 2015 You can't use just rotate to get that effect as contexts don't rotate in 3D. You could try with skew. Quote Link to comment Share on other sites More sharing options...
thatguy64 Posted September 17, 2015 Author Share Posted September 17, 2015 I know, I need to rotate it before I skew it Quote Link to comment Share on other sites More sharing options...
rich Posted September 17, 2015 Share Posted September 17, 2015 It can't be done in 2D with a single image. It needs slicing and then you transform each slice 'away' from the camera, using varying scales and skews as you go. It can be done in CSS with a single call on a single image however. But not in Canvas (without using WebGL of course). Quote Link to comment Share on other sites More sharing options...
thatguy64 Posted September 17, 2015 Author Share Posted September 17, 2015 I'm sorry i'm having a hard time conveying my question all I need to do is rotate the image, then take the rotated image and put it into a function I've written which skews it.I just need to know how to rotate it then take the rotated image and put it into a image object. Quote Link to comment Share on other sites More sharing options...
rich Posted September 17, 2015 Share Posted September 17, 2015 ctx.rotate is how you rotate a canvas. Could your function not also work from a canvas object? Then you could surely rotate it and run it through your function in a single step, without having to generate an image object from a canvas in-between. Quote Link to comment Share on other sites More sharing options...
thatguy64 Posted September 17, 2015 Author Share Posted September 17, 2015 Thank you it worked but there is now a weird blank spot where the map is not drawing Quote Link to comment Share on other sites More sharing options...
GBeebe Posted September 18, 2015 Share Posted September 18, 2015 That is weird. You're not setting any clipping regions, are you? Quote Link to comment Share on other sites More sharing options...
thatguy64 Posted September 20, 2015 Author Share Posted September 20, 2015 what do you mean by clipping region? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.