Skip to content

Commit 900fb33

Browse files
Added checks
1 parent 0df9701 commit 900fb33

File tree

1 file changed

+39
-33
lines changed

1 file changed

+39
-33
lines changed

src/ArduinoGraphics.cpp

+39-33
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,43 @@ void ArduinoGraphics::ellipse(int x, int y, int width, int height)
223223
set(x2, y2, _strokeR, _strokeG, _strokeB);
224224
}
225225

226-
for(int a = 0; a < j; a++)
226+
if(_fill)
227227
{
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+
228259
int x1 = x-i;
229260
int x2 = x+i;
230-
int y1 = y-a;
231-
int y2 = y+a;
261+
int y1 = y-j;
262+
int y2 = y+j;
232263

233264
if(width%2 == 0)
234265
{
@@ -240,42 +271,17 @@ void ArduinoGraphics::ellipse(int x, int y, int width, int height)
240271
y2--;
241272
}
242273

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);
267278
}
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);
273279
}
274280
}
275281

276282
void ArduinoGraphics::circle(int x, int y, int radius)
277283
{
278-
ellipse(x, y, ((radius*2)-1), ((radius*2)-1));
284+
ellipse(x, y, ((radius*2)-1), ((radius*2)-1));
279285
}
280286

281287
void ArduinoGraphics::text(const char* str, int x, int y)

0 commit comments

Comments
 (0)