-
Notifications
You must be signed in to change notification settings - Fork 22
Fix to Issue #6 #11
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
Fix to Issue #6 #11
Conversation
Since there are no examples in this repository, the checks are not successful. Please Merge #10 or add examples before merging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please always thoroughly test your code before submitting a pull request.
This sketch:
#include <ArduinoGraphics.h>
const byte canvasWidth = 12;
const byte canvasHeight = 12;
class ASCIIDrawClass : public ArduinoGraphics {
public:
ASCIIDrawClass() : ArduinoGraphics(canvasWidth, canvasHeight) {}
virtual void set(int x, int y, uint8_t r, uint8_t g, uint8_t b) {
if (x < 0 || x >= canvasWidth || y < 0 || y >= canvasHeight) {
return;
}
// the r parameter is (mis)used to set the character to draw with
_canvasBuffer[x][y] = r;
(void)g;
(void)b;
}
// display the drawing
void endDraw() {
ArduinoGraphics::endDraw();
for (byte row = 0; row < canvasHeight; row++) {
for (byte column = 0; column < canvasWidth; column++) {
// handle unset parts of buffer
if (_canvasBuffer[column][row] == 0) {
_canvasBuffer[column][row] = ' ';
}
Serial.print(_canvasBuffer[column][row]);
}
Serial.println();
}
}
private:
char _canvasBuffer[canvasWidth][canvasHeight] = {0};
};
ASCIIDrawClass ASCIIDraw;
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("ellipse");
ASCIIDraw.beginDraw();
ASCIIDraw.background('X', 0, 0);
ASCIIDraw.clear();
ASCIIDraw.stroke('*', 0, 0);
ASCIIDraw.fill('O', 0, 0);
ASCIIDraw.ellipse(6, 6, 10, 10);
ASCIIDraw.endDraw();
Serial.println("circle");
ASCIIDraw.beginDraw();
ASCIIDraw.background('X', 0, 0);
ASCIIDraw.clear();
ASCIIDraw.stroke('*', 0, 0);
ASCIIDraw.fill('O', 0, 0);
ASCIIDraw.circle(6, 6, 5);
ASCIIDraw.endDraw();
Serial.println("arc");
ASCIIDraw.beginDraw();
ASCIIDraw.background('X', 0, 0);
ASCIIDraw.clear();
ASCIIDraw.stroke('*', 0, 0);
ASCIIDraw.fill('O', 0, 0);
ASCIIDraw.arc(6, 6, 10, 10, 0, 180);
ASCIIDraw.endDraw();
}
void loop() {}
produces this output:
ellipse
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXX***XXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
circle
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
arc
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
So there are definitely some serious problems with your code.
Co-Authored-By: per1234 <[email protected]> Changed ellipse function. Removed arc function for now.
@per1234 , I apologise for the mistake in the previous pull, I have changed the ellipse function quite a bit and removed the arc function for now(i ran into a few issues with it). Please review this new commit |
|
Closing this PR due to inactivity. |
Added the ellipse, circle and elliptical arc functions and tested locally.