Skip to main content
BGuth.1
Senior
Jun 23, 2022 3:58 PM UTC
Solved

Rotate an image smoothly

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.
Osman SOYKURT
Osman SOYKURTBest answer
ST Technical Moderator
Jun 27, 2022 8:05 AM UTC

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

ST Software Developer | TouchGFX

2 replies

Osman SOYKURT
Osman SOYKURTBest answer
ST Technical Moderator
Jun 27, 2022 8:05 AM UTC

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

ST Software Developer | TouchGFX
BGuth.1
BGuth.1Author
Senior
Jun 27, 2022 3:13 PM UTC

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.