Rotated Sprite Trace #3199
Unanswered
martyanov85
asked this question in
Q&A - Sprites
Replies: 1 comment
-
In the example given, both sprites are transparent (the same TFT_BLACK color used for painting and in push causes this, in push instruction it is treated as trasparent color), so the background is still affected. The solution is replace back.fillSprite(TFT_BLACK); with image repainting in it. Or try to change TFT_BLACK in this instuction only to something else to see the problem. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello I'm trying to display a rotating needle with a scale on an ILI9488 (320x480 px) and ESP32. The scale is an 320x320 px image. I use two sprites, one for the needle (40x240 px ) and one for the background behind the needle (240x240 px). The needle background should be transparent in order to see the scale image. The problem is that if the needle rotates there is a steady remaining trace of the needle. A the moment I have no idea how to get rid of it. Does anyone perhaps have a solution? Here is my code:
#include <TFT_eSPI.h>
#include <scala.h>
TFT_eSPI tft = TFT_eSPI();
TFT_eSprite back = TFT_eSprite(&tft);
TFT_eSprite needle = TFT_eSprite(&tft);
int16_t x_Center = 160;
int16_t y_Center = 240;
int angle = 0;
void setup() {
tft.init();
tft.fillScreen(TFT_WHITE);
tft.setSwapBytes(true);
tft.pushImage(0,80,320,320,scala);
tft.setPivot(x_Center, y_Center);
back.createSprite(240,240);
needle.createSprite(40,240);
}
void loop() {
int sensorValue = analogRead(34);
angle = map(sensorValue,0,4095,0,359);
back.fillSprite(TFT_BLACK);
needle.fillSprite(TFT_BLACK);
needle.drawWedgeLine(10, 0, 20, 120, 1, 10, TFT_RED);
needle.fillCircle(20,120,20,TFT_RED);
needle.pushRotated(&back, angle, TFT_BLACK);
back.pushSprite(40,120,TFT_BLACK);
}
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions