@@ -350,33 +350,31 @@ void Adafruit_GFX::drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
350
350
@brief Draw an ellipse outline
351
351
@param x0 Center-point x coordinate
352
352
@param y0 Center-point y coordinate
353
- @param rw Horizontal width of ellipse
354
- @param rh Vertical height of ellipse
353
+ @param rw Horizontal radius of ellipse
354
+ @param rh Vertical radius of ellipse
355
355
@param color 16-bit 5-6-5 Color to draw with
356
356
*/
357
357
/* *************************************************************************/
358
358
void Adafruit_GFX::drawEllipse (int16_t x0, int16_t y0, int16_t rw, int16_t rh,
359
- uint16_t color) {
359
+ uint16_t color) {
360
360
#if defined(ESP8266)
361
361
yield ();
362
362
#endif
363
363
// Bresenham's ellipse algorithm
364
-
365
364
int16_t x = 0 , y = rh;
366
365
int32_t rw2 = rw * rw, rh2 = rh * rh;
367
366
int32_t twoRw2 = 2 * rw2, twoRh2 = 2 * rh2;
368
367
369
- int32_t decision = rh2 - (rw2 * rh) + (rw2/ 4 );
368
+ int32_t decision = rh2 - (rw2 * rh) + (rw2 / 4 );
370
369
371
370
startWrite ();
372
371
373
- // region 1
372
+ // region 1
374
373
while ((twoRh2 * x) < (twoRw2 * y)) {
375
374
writePixel (x0 + x, y0 + y, color);
376
375
writePixel (x0 - x, y0 + y, color);
377
376
writePixel (x0 + x, y0 - y, color);
378
377
writePixel (x0 - x, y0 - y, color);
379
-
380
378
x++;
381
379
if (decision < 0 ) {
382
380
decision += rh2 + (twoRh2 * x);
@@ -386,14 +384,14 @@ void Adafruit_GFX::drawEllipse(int16_t x0, int16_t y0, int16_t rw, int16_t rh,
386
384
}
387
385
}
388
386
389
- // region 2
390
- decision = ((rh2 * (2 * x + 1 ) * (2 * x + 1 )) >> 2 ) + (rw2 * (y - 1 ) * (y - 1 )) - (rw2 * rh2);
387
+ // region 2
388
+ decision = ((rh2 * (2 * x + 1 ) * (2 * x + 1 )) >> 2 ) +
389
+ (rw2 * (y - 1 ) * (y - 1 )) - (rw2 * rh2);
391
390
while (y >= 0 ) {
392
391
writePixel (x0 + x, y0 + y, color);
393
392
writePixel (x0 - x, y0 + y, color);
394
393
writePixel (x0 + x, y0 - y, color);
395
394
writePixel (x0 - x, y0 - y, color);
396
-
397
395
y--;
398
396
if (decision > 0 ) {
399
397
decision += rw2 - (twoRw2 * y);
@@ -411,31 +409,30 @@ void Adafruit_GFX::drawEllipse(int16_t x0, int16_t y0, int16_t rw, int16_t rh,
411
409
@brief Draw an ellipse with filled colour
412
410
@param x0 Center-point x coordinate
413
411
@param y0 Center-point y coordinate
414
- @param rw Horizontal width of ellipse
415
- @param rh Vertical height of ellipse
412
+ @param rw Horizontal radius of ellipse
413
+ @param rh Vertical radius of ellipse
416
414
@param color 16-bit 5-6-5 Color to draw with
417
415
*/
418
416
/* *************************************************************************/
419
417
void Adafruit_GFX::fillEllipse (int16_t x0, int16_t y0, int16_t rw, int16_t rh,
420
- uint16_t color) {
418
+ uint16_t color) {
421
419
#if defined(ESP8266)
422
420
yield ();
423
421
#endif
424
422
// Bresenham's ellipse algorithm
425
-
426
423
int16_t x = 0 , y = rh;
427
424
int32_t rw2 = rw * rw, rh2 = rh * rh;
428
425
int32_t twoRw2 = 2 * rw2, twoRh2 = 2 * rh2;
429
426
430
- int32_t decision = rh2 - (rw2 * rh) + (rw2/ 4 );
427
+ int32_t decision = rh2 - (rw2 * rh) + (rw2 / 4 );
431
428
432
429
startWrite ();
433
430
434
- // region 1
431
+ // region 1
435
432
while ((twoRh2 * x) < (twoRw2 * y)) {
436
433
drawFastHLine (x0 - x, y0 + y, 2 * x + 1 , color);
437
434
drawFastHLine (x0 - x, y0 - y, 2 * x + 1 , color);
438
-
435
+
439
436
x++;
440
437
if (decision < 0 ) {
441
438
decision += rh2 + (twoRh2 * x);
@@ -445,13 +442,13 @@ void Adafruit_GFX::fillEllipse(int16_t x0, int16_t y0, int16_t rw, int16_t rh,
445
442
}
446
443
}
447
444
448
- // region 2
449
- decision = ((rh2 * (2 * x + 1 ) * (2 * x + 1 )) >> 2 ) + (rw2 * (y - 1 ) * (y - 1 )) - (rw2 * rh2);
445
+ // region 2
446
+ decision = ((rh2 * (2 * x + 1 ) * (2 * x + 1 )) >> 2 ) +
447
+ (rw2 * (y - 1 ) * (y - 1 )) - (rw2 * rh2);
450
448
while (y >= 0 ) {
451
-
452
449
drawFastHLine (x0 - x, y0 + y, 2 * x + 1 , color);
453
450
drawFastHLine (x0 - x, y0 - y, 2 * x + 1 , color);
454
-
451
+
455
452
y--;
456
453
if (decision > 0 ) {
457
454
decision += rw2 - (twoRw2 * y);
0 commit comments