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

Why not use the more universal Bresenham? #138

Open
jiannanya opened this issue Jan 17, 2024 · 0 comments
Open

Why not use the more universal Bresenham? #138

jiannanya opened this issue Jan 17, 2024 · 0 comments

Comments

@jiannanya
Copy link

Hi there, I know the original one is correct, but why not use the more universal Bresenham like blow ?

code like:

void bresenhamLine(int x1, int y1, int x2, int y2)
{
    int x, y, dx, dy, p;
    x = x1;
    y = y1;
    dx = x2 - x1;
    dy = y2 - y1;

    p = 2*dy - dx;
    for(; x <= x2; x++){
        SetPixel(x,y);
        if(p>0){
            y++
            p+=2*(dy-dx);
         } else{
            p+=2*dy;
         }
    }
} 
Repository owner deleted a comment from DouYuexi Feb 20, 2024
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

1 participant