-
Notifications
You must be signed in to change notification settings - Fork 22
ellipse and circle implementation #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,6 +124,51 @@ void ArduinoGraphics::noStroke() | |
_stroke = false; | ||
} | ||
|
||
void ArduinoGraphics::ellipse(int x, int y, int width, int height) | ||
{ | ||
if (!_stroke && !_fill) { | ||
return; | ||
} | ||
|
||
float theta; | ||
int r1 = width / 2; | ||
int r2 = height / 2; | ||
for (int angle = 0; angle < 360; angle += 1) { | ||
theta = angle * 3.14 / 180; | ||
int xi = r1 * cos(theta); | ||
int yi = r2 * sin(theta); | ||
if (_stroke) { | ||
// stroke | ||
set(x + xi, y - yi, _strokeR, _strokeG, _strokeB); | ||
} else if (_fill) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are treating fill as an alternative stroke. The fill should fill the inside of the ellipse, so it needs to be done in addition to the stroke. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry still not fixed. I notice another bug with fill. |
||
// fill | ||
set(x + xi, y - yi, _fillR, _fillG, _fillB); | ||
} | ||
} | ||
} | ||
|
||
void ArduinoGraphics::circle(int x, int y, int radius) | ||
{ | ||
//ellipse(x, y, 2 * radius, 2 * radius); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you decide not to functionalize the shared code? I see from this comment that you started out to do that at one point. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just for reducing the number of function calling. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll leave that choice up to you and whoever does the final review on this, but I would request that you remove the commented out code, since it doesn't serve any purpose. |
||
if (!_stroke && !_fill) { | ||
return; | ||
} | ||
|
||
float theta; | ||
for (int angle = 0; angle < 360; angle += 1) { | ||
theta = angle * 3.14 / 180; | ||
int xi = radius * cos(theta); | ||
int yi = radius * sin(theta); | ||
if (_stroke) { | ||
// stroke | ||
set(x + xi, y - yi, _strokeR, _strokeG, _strokeB); | ||
} else if (_fill) { | ||
// fill | ||
set(x + xi, y - yi, _fillR, _fillG, _fillB); | ||
} | ||
} | ||
} | ||
|
||
void ArduinoGraphics::line(int x1, int y1, int x2, int y2) | ||
{ | ||
if (!_stroke) { | ||
|
Uh oh!
There was an error while loading. Please reload this page.