acidportal- 😈 Worlds smallest Evil Portal on a LilyGo T-QT |
git clone git://git.acid.vegas/acidportal.git |
Log | Files | Refs | Archive | README | LICENSE |
Colour_Wheel.ino (1777B)
1 // Arc drawing example - draw a colour wheel 2 3 #include <TFT_eSPI.h> // Include the graphics library 4 TFT_eSPI tft = TFT_eSPI(); // Create object "tft" 5 6 uint16_t colors[12]; 7 8 // ------------------------------------------------------------------------- 9 // Setup 10 // ------------------------------------------------------------------------- 11 void setup(void) { 12 Serial.begin(115200); 13 tft.init(); 14 tft.fillScreen(TFT_BLACK); 15 16 // Create the outer ring colours 17 for (uint8_t c = 0; c < 2; c++) { 18 colors[c + 10] = tft.alphaBlend(128 + c * 127, TFT_RED, TFT_MAGENTA); 19 colors[c + 8] = tft.alphaBlend(128 + c * 127, TFT_MAGENTA, TFT_BLUE); 20 colors[c + 6] = tft.alphaBlend(128 + c * 127, TFT_BLUE, TFT_GREEN); 21 colors[c + 4] = tft.alphaBlend(128 + c * 127, TFT_GREEN, TFT_YELLOW); 22 colors[c + 2] = tft.alphaBlend(128 + c * 127, TFT_YELLOW, TFT_ORANGE); 23 colors[c + 0] = tft.alphaBlend(128 + c * 127, TFT_ORANGE, TFT_RED); 24 } 25 } 26 27 // ------------------------------------------------------------------------- 28 // Main loop 29 // ------------------------------------------------------------------------- 30 void loop() { 31 uint16_t rDelta = (tft.width() - 1) / 10; 32 uint16_t x = tft.width() / 2; 33 uint16_t y = tft.height() / 2; 34 bool smooth = true; 35 36 // Draw rings as a series of arcs, increasingly blend colour with white towards middle 37 for (uint16_t i = 5; i > 0; i--) { 38 for (uint16_t angle = 0; angle <= 330; angle += 30) { 39 uint16_t radius = i * rDelta; 40 uint16_t wheelColor = tft.alphaBlend((i * 255.0)/5.0, colors[angle / 30], TFT_WHITE); 41 tft.drawArc(x, y, radius, radius - rDelta, angle, angle + 30, wheelColor, TFT_BLACK, smooth); 42 } 43 smooth = false; // Only outer ring is smooth 44 } 45 46 while (1) delay(100); 47 }