Skip to content

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

Closed

Conversation

ashutoshshrm529
Copy link

Added the ellipse, circle and elliptical arc functions and tested locally.

@ashutoshshrm529
Copy link
Author

Since there are no examples in this repository, the checks are not successful. Please Merge #10 or add examples before merging.

Copy link
Contributor

@per1234 per1234 left a 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.
@ashutoshshrm529
Copy link
Author

@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

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@aentinger
Copy link
Contributor

Closing this PR due to inactivity.

@aentinger aentinger closed this Jun 30, 2022
@per1234 per1234 added type: enhancement Proposed improvement conclusion: declined Will not be worked on topic: code Related to content of the project itself labels Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: declined Will not be worked on topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants