Drawing a 'rotated' filled rectangle in a Picture

I have managed to draw a filled rectangle on my image as I wish.

maskPicture.Graphics.FillRect(x, y, 100, 25) 

But I want that rectangle to be ‘rotatable’. However, I don’t see a rotate method in the graphics class.
Help?

You can use an Object2D to draw rotated things.

https://documentation.xojo.com/api/graphics/object2d.html

Update: To be more specific, you would use the RectShape subclass. There’s some example code in the docs for drawing a rotated rectangle:

https://documentation.xojo.com/api/graphics/rectshape.html#rectshape-rotation

3 Likes

The rectangle you have drawn is not an object. I can paint a rectangle on my wall but that won’t be rotatable either.

Or you can rotate the graphics

g.saveState //to restore the graphic after
g.rotate … (your needed rotation)
g.fillRect… (your rotate draw without the need to change coordinate)
g.restoreState // the graphic environment is restored as before