Page 1 of 1

Rotate Image

Posted: Sat Apr 01, 2023 8:27 am
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

Re: Rotate Image

Posted: Sun Apr 02, 2023 2:08 pm
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();
}