acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
Smooth_Arc.ino (1775B)
1 // Example for drawSmoothArc function. 2 // Draws smooth arcs with rounded or square smooth ends 3 4 #include <TFT_eSPI.h> // Include the graphics library 5 TFT_eSPI tft = TFT_eSPI(); // Create object "tft" 6 7 // ------------------------------------------------------------------------- 8 // Setup 9 // ------------------------------------------------------------------------- 10 void setup(void) { 11 Serial.begin(115200); 12 13 tft.init(); 14 tft.setRotation(1); 15 tft.fillScreen(TFT_BLACK); 16 } 17 18 // ------------------------------------------------------------------------- 19 // Main loop 20 // ------------------------------------------------------------------------- 21 void loop() 22 { 23 static uint32_t count = 0; 24 25 uint16_t fg_color = random(0x10000); 26 uint16_t bg_color = TFT_BLACK; // This is the background colour used for smoothing (anti-aliasing) 27 28 uint16_t x = random(tft.width()); // Position of centre of arc 29 uint16_t y = random(tft.height()); 30 31 uint8_t radius = random(20, tft.width()/4); // Outer arc radius 32 uint8_t thickness = random(1, radius / 4); // Thickness 33 uint8_t inner_radius = radius - thickness; // Calculate inner radius (can be 0 for circle segment) 34 35 // 0 degrees is at 6 o'clock position 36 // Arcs are drawn clockwise from start_angle to end_angle 37 uint16_t start_angle = random(361); // Start angle must be in range 0 to 360 38 uint16_t end_angle = random(361); // End angle must be in range 0 to 360 39 40 bool arc_end = random(2); // true = round ends, false = square ends (arc_end parameter can be omitted, ends will then be square) 41 42 tft.drawSmoothArc(x, y, radius, inner_radius, start_angle, end_angle, fg_color, bg_color, arc_end); 43 44 count++; 45 if (count < 30) delay(500); // After 15s draw as fast as possible! 46 }