Skip to content
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

Use line for smoother graphs #43

Open
ratatoeskr666 opened this issue Jan 30, 2022 · 1 comment
Open

Use line for smoother graphs #43

ratatoeskr666 opened this issue Jan 30, 2022 · 1 comment

Comments

@ratatoeskr666
Copy link

for ( int j = 0; j < this.currPoints; j++ )

Hi, just an quick&dirty idea, I don't know if there are any caveats using this. For me it worked:

`for ( int j = 0; j < this.currPoints; j++ )
{
float x1 = (float)(this.posX + (this.data[j][i][0]*xScale - xOffset));
float y1 = (float)(this.posY + yOffset - data[j][i][1]*yScale);

    // Skip the first 2 pixels otherwise you will see lines between first and last pixel
    if (j > 0 && x1 > this.posX + 2) {          
      float x2 = (float)(this.posX + (this.data[j-1][i][0]*xScale - xOffset));          
      float y2 = (float)(this.posY + yOffset - data[j-1][i][1]*yScale);
      this.parent.line(x1, y1, x2, y2);
    } else {
      this.parent.point(x1, y1);
    }

}`

This makes the graph rendering smoother if you wish rendering interpolation between the data points.

This is just some kind of contribution. Thank you for this outstanding library and for making it free for all of us! :)

@phdv61
Copy link

phdv61 commented Feb 5, 2022

The data buffer is a rolling buffer. So, to draw lines and smooth (interpolate) the drawing, it must be done in two halves. I suggested a mod down on this same page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants