Rotate Image

Just starting out? Need help? Post your questions and find answers here.
magg
Posts: 6
Joined: Wed Mar 15, 2023 6:57 pm

Rotate Image

Post by magg »

How can I draw an image with rotation?

I'm trying to use StartDrawing(SpriteOutput(0)) as in game coding call render to texture, so I could transform this texture whenever I want.
But sadly I cannot draw a sprite in another sprite output. I try to drawImage in it, but draw image has no rotation.

This is very limited for game. It is nice if we can do anything in SpriteOutput like on openscreen
Andy
Posts: 46
Joined: Sat Feb 15, 2020 5:19 pm
Location: Larnaca, Cyprus
Contact:

Re: Rotate Image

Post by Andy »

You can already rotate a sprite with

Code: Select all

RotateSprite(#Sprite, Angle.f, Mode)
This is very limited for game. It is nice if we can do anything in SpriteOutput like on openscreen
Openscreen and the sprite commands are designed for speed/games.
Spiderbasic has inline javascript so maybe you can modify this to do what you need.

Code: Select all

function drawRotated(context, image, imageX, imageY, degrees) {
    context.save();
  	context.translate(imageX, imageY);
    context.rotate(0.017453292519943295 * degrees);  // 0.017453292519943295 == Math.PI / 180
    context.drawImage(image, -0.5 * image.width, -0.5 * image.width);
    context.restore();
}
Post Reply