@@ -184,6 +184,38 @@ void ArduinoGraphics::rect(int x, int y, int width, int height)
184
184
}
185
185
}
186
186
187
+ void ArduinoGraphics::ellipse (int x, int y, int width, int height)
188
+ {
189
+ if (!_stroke && !_fill) {
190
+ return ;
191
+ }
192
+
193
+ int x1 = x;
194
+ int y1 = y;
195
+ int r1 = (width/2 );
196
+ int r2 = (height/2 );
197
+ int x2 = x1 + r1 - 1 ;
198
+
199
+ for (x = x1; x <= x2; x++) {
200
+ y2 = y1 + sqrt ((1 - ((x * x)/(r1 * r1)))) * r2;
201
+ for (y = y1 ; y <= y2; y++) {
202
+ if ((y == y2) && _stroke) {
203
+ // stroke
204
+ set (x, y, _strokeR, _strokeG, _strokeB); // current point
205
+ set (x - (((x - x1) * 2 )), y, _strokeR, _strokeG, _strokeB); // second reflection
206
+ set (x, y - (((y - y1 ) * 2 )), _strokeR, _strokeG, _strokeB); // third reflection
207
+ set (x - (((x - x1) * 2 )), y - (((y - y1 ) * 2 )), _strokeR, _strokeG, _strokeB); // fourth reflection
208
+ } else if (_fill) {
209
+ // fill
210
+ set (x, y, _fillR, _fillG, _fillB); // current point
211
+ set (x - (((x - x1) * 2 )), y, _fillR, _fillG, _fillB); // second reflection
212
+ set (x, y - (((y - y1 ) * 2 )), _fillR, _fillG, _fillB); // third reflection
213
+ set (x - (((x - x1) * 2 )), y - (((y - y1 ) * 2 )), _fillR, _fillG, _fillB); // fourth reflection
214
+ }
215
+ }
216
+ }
217
+ }
218
+
187
219
void ArduinoGraphics::text (const char * str, int x, int y)
188
220
{
189
221
if (!_font || !_stroke) {
@@ -365,7 +397,7 @@ void ArduinoGraphics::beginText(int x, int y, uint8_t r, uint8_t g, uint8_t b)
365
397
366
398
_textR = r;
367
399
_textG = g;
368
- _textB = b;
400
+ _textB = b;
369
401
}
370
402
371
403
void ArduinoGraphics::beginText (int x, int y, uint32_t color)
@@ -482,7 +514,7 @@ void ArduinoGraphics::lineHigh(int x1, int y1, int x2, int y2)
482
514
xi = -1 ;
483
515
dx = -dx;
484
516
}
485
-
517
+
486
518
int D = 2 * dx - dy;
487
519
int x = x1;
488
520
0 commit comments