cancel
Showing results for 
Search instead for 
Did you mean: 

Rotate an image smoothly

BGuth.1
Senior

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Osman SOYKURT
ST Employee

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 SOYKURT
ST Software Developer | TouchGFX

View solution in original post

2 REPLIES 2
Osman SOYKURT
ST Employee

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 SOYKURT
ST Software Developer | TouchGFX

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.