@@ -223,12 +223,43 @@ void ArduinoGraphics::ellipse(int x, int y, int width, int height)
223
223
set (x2, y2, _strokeR, _strokeG, _strokeB);
224
224
}
225
225
226
- for ( int a = 0 ; a < j; a++ )
226
+ if (_fill )
227
227
{
228
+ for (int a = 0 ; a < j; a++)
229
+ {
230
+ int x1 = x-i;
231
+ int x2 = x+i;
232
+ int y1 = y-a;
233
+ int y2 = y+a;
234
+
235
+ if (width%2 == 0 )
236
+ {
237
+ x2--;
238
+ }
239
+
240
+ if (height%2 == 0 )
241
+ {
242
+ y2--;
243
+ }
244
+
245
+ set (x1, y1 , _fillR, _fillG, _fillB);
246
+ set (x1, y2, _fillR, _fillG, _fillB);
247
+ set (x2, y1 , _fillR, _fillG, _fillB);
248
+ set (x2, y2, _fillR, _fillG, _fillB);
249
+ }
250
+ }
251
+ }
252
+
253
+ if (_stroke)
254
+ {
255
+ for (int j = 0 ; j < r2; j++)
256
+ {
257
+ int i = ceil (sqrt (1 - ((float )(j*j)/(r2*r2))) * r1);
258
+
228
259
int x1 = x-i;
229
260
int x2 = x+i;
230
- int y1 = y-a ;
231
- int y2 = y+a ;
261
+ int y1 = y-j ;
262
+ int y2 = y+j ;
232
263
233
264
if (width%2 == 0 )
234
265
{
@@ -240,42 +271,17 @@ void ArduinoGraphics::ellipse(int x, int y, int width, int height)
240
271
y2--;
241
272
}
242
273
243
- set (x1, y1 , _fillR, _fillG, _fillB);
244
- set (x1, y2, _fillR, _fillG, _fillB);
245
- set (x2, y1 , _fillR, _fillG, _fillB);
246
- set (x2, y2, _fillR, _fillG, _fillB);
247
- }
248
- }
249
-
250
- for (int j = 0 ; j < r2; j++)
251
- {
252
- int i = ceil (sqrt (1 - ((float )(j*j)/(r2*r2))) * r1);
253
-
254
- int x1 = x-i;
255
- int x2 = x+i;
256
- int y1 = y-j;
257
- int y2 = y+j;
258
-
259
- if (width%2 == 0 )
260
- {
261
- x2--;
262
- }
263
-
264
- if (height%2 == 0 )
265
- {
266
- y2--;
274
+ set (x1, y1 , _strokeR, _strokeG, _strokeB);
275
+ set (x1, y2, _strokeR, _strokeG, _strokeB);
276
+ set (x2, y1 , _strokeR, _strokeG, _strokeB);
277
+ set (x2, y2, _strokeR, _strokeG, _strokeB);
267
278
}
268
-
269
- set (x1, y1 , _strokeR, _strokeG, _strokeB);
270
- set (x1, y2, _strokeR, _strokeG, _strokeB);
271
- set (x2, y1 , _strokeR, _strokeG, _strokeB);
272
- set (x2, y2, _strokeR, _strokeG, _strokeB);
273
279
}
274
280
}
275
281
276
282
void ArduinoGraphics::circle (int x, int y, int radius)
277
283
{
278
- ellipse (x, y, ((radius*2 )-1 ), ((radius*2 )-1 ));
284
+ ellipse (x, y, ((radius*2 )-1 ), ((radius*2 )-1 ));
279
285
}
280
286
281
287
void ArduinoGraphics::text (const char * str, int x, int y)
0 commit comments