Skip to main content
BGuth.1
Senior
June 23, 2022
Solved

Rotate an image smoothly

  • June 23, 2022
  • 1 reply
  • 1698 views

I am trying to create a busy circle (such as the one that shows up when a web page is loading). Instead of circle I would like to use a custom image. I used TextureMapper for this. But I don't get continuous and smooth rotation of image. Image makes one rotation, slows down and stops and then restarts. I am attaching the sample project I was using. Also, image appearance distorts as it makes the rotation. Please advice.

Also, please advice if there is a different way to do this.

This topic has been closed for replies.
Best answer by Osman SOYKURT

Hello BGuth.1,

About your rotation you can use the handleTickEvent function and then you can set the Z angle of your TextureMapper at each tick. Something like this :

void MainView::handleTickEvent() {
 textureMapperImage.setZAngle(textureMapperImage.getZAngle() + 0.03);
 textureMapperImage.invalidate();
}

You can get inspiration from the project I put in attachment.

/Osman

1 reply

Osman SOYKURT
Osman SOYKURTBest answer
Technical Moderator
June 27, 2022

Hello BGuth.1,

About your rotation you can use the handleTickEvent function and then you can set the Z angle of your TextureMapper at each tick. Something like this :

void MainView::handleTickEvent() {
 textureMapperImage.setZAngle(textureMapperImage.getZAngle() + 0.03);
 textureMapperImage.invalidate();
}

You can get inspiration from the project I put in attachment.

/Osman

Osman SOYKURTST Software Developer | TouchGFX
BGuth.1
BGuth.1Author
Senior
June 27, 2022

Thank you @Osman SOYKURT​ . I had to use textureMapperImage.updateZAngle() in my version i.e. 4.16.1. But it worked. Thanks for the help.