acidportal- 😈 Worlds smallest Evil Portal on a LilyGo T-QT |
git clone git://git.acid.vegas/acidportal.git |
Log | Files | Refs | Archive | README | LICENSE |
Draw_Arc.ino (2078B)
1 // Example for drawArc function. This is intended for arc based meters. 2 // (See arcMeter example) 3 4 // Draws arcs without smooth ends, suitable for dynamically changing arc 5 // angles to avoid residual anti-alias pixels at the arc segment joints. 6 7 // The sides of the arc can optionally be smooth or not. Smooth arcs have 8 // a much better appearance, especially at small sizes. 9 10 #include <TFT_eSPI.h> // Include the graphics library 11 TFT_eSPI tft = TFT_eSPI(); // Create object "tft" 12 13 // ------------------------------------------------------------------------- 14 // Setup 15 // ------------------------------------------------------------------------- 16 void setup(void) { 17 Serial.begin(115200); 18 19 tft.init(); 20 tft.setRotation(1); 21 tft.fillScreen(TFT_BLACK); 22 } 23 24 // ------------------------------------------------------------------------- 25 // Main loop 26 // ------------------------------------------------------------------------- 27 void loop() 28 { 29 static uint32_t count = 0; 30 31 uint16_t fg_color = random(0x10000); 32 uint16_t bg_color = TFT_BLACK; // This is the background colour used for smoothing (anti-aliasing) 33 34 uint16_t x = random(tft.width()); // Position of centre of arc 35 uint16_t y = random(tft.height()); 36 37 uint8_t radius = random(20, tft.width() / 4); // Outer arc radius 38 uint8_t thickness = random(1, radius / 4); // Thickness 39 uint8_t inner_radius = radius - thickness; // Calculate inner radius (can be 0 for circle segment) 40 41 // 0 degrees is at 6 o'clock position 42 // Arcs are drawn clockwise from start_angle to end_angle 43 // Start angle can be greater than end angle, the arc will then be drawn through 0 degrees 44 uint16_t start_angle = random(361); // Start angle must be in range 0 to 360 45 uint16_t end_angle = random(361); // End angle must be in range 0 to 360 46 47 bool smooth = random(2); // true = smooth sides, false = no smooth sides 48 49 tft.drawArc(x, y, radius, inner_radius, start_angle, end_angle, fg_color, bg_color, smooth); 50 51 count++; 52 if (count < 30) delay(500); // After 15s draw as fast as possible! 53 }