Search code examples
kotlinkorge

How rotate image respecting proportions


I would like to rotate long image representing hand of a clock. I have following code:

    val hand = Image(handBitmap).apply {
        scaledHeight = 50.0
        scaledWidth = 400.0
        anchor(.0, 0.5)
        addUpdater {
            rotation =  Angle.fromDegrees( rotation.degrees + 1)
        }
    }

I expected result like on this image:

enter image description here

but I got this:

enter image description here

What should I change to achieve a hand of clock like effect?


Solution

  • The problem looked more like this:

            o
            |
    o------- -------o
            |
            o
    

    It occurs when I set scaledHeight and scaledWidth.
    Finally setting scale(1.0) helped.