acidportal

- 😈 Worlds smallest Evil Portal on a LilyGo T-QT
git clone git://git.acid.vegas/acidportal.git
Log | Files | Refs | Archive | README | LICENSE

Smooth_Rounded_Rectangles.ino (1398B)

      1 // Draw random coloured smooth (anti-aliased) rounded rectangles on the TFT
      2 
      3 #include <TFT_eSPI.h>
      4 
      5 TFT_eSPI tft = TFT_eSPI();
      6 
      7 void setup(void) {
      8   tft.init();
      9   tft.fillScreen(TFT_BLACK); // Background is black
     10 }
     11 
     12 void loop() {
     13   tft.fillScreen(TFT_BLACK);
     14   tft.setCursor(0, 0);
     15 
     16   // Draw some random smooth rounded rectangles
     17   for (int i = 0; i < 20; i++)
     18   {
     19     int radius = random(60);
     20     int w = random(2 * radius, 160);
     21     int h = random(2 * radius, 160);
     22     int t = random(1, radius / 3);
     23     int x = random(tft.width() - w);
     24     int y = random(tft.height() - h);
     25 
     26     // Random colour is anti-aliased (blended) with background colour (black in this case)
     27     tft.drawSmoothRoundRect(x, y, radius, radius - t, w, h, random(0x10000), TFT_BLACK);
     28   }
     29   tft.print("Variable thickness");
     30   delay(2000);
     31 
     32   tft.fillScreen(TFT_BLACK);
     33   tft.setCursor(0, 0);
     34 
     35   // Draw some random minimum thickness smooth rounded rectangles
     36   for (int i = 0; i < 20; i++)
     37   {
     38     int radius = random(60);
     39     int w = random(2 * radius, 160);
     40     int h = random(2 * radius, 160);
     41     int t = 0;
     42     int x = random(tft.width() - w);
     43     int y = random(tft.height() - h);
     44 
     45     // Random colour is anti-aliased (blended) with background colour (black in this case)
     46     tft.drawSmoothRoundRect(x, y, radius, radius - t, w, h, random(0x10000), TFT_BLACK);
     47   }
     48   tft.print("Minimum thickness");
     49   delay(2000);
     50 }