Last active
May 15, 2023 18:50
-
-
Save assyrianic/ec7e63cad63e0837459a003ad0008908 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Bresenham's algorithm in simplistic C | |
void drawline(int const x0, int const y0, int const x1, int const y1) { | |
int const dx = x1 - x0; | |
int const dy = y1 - y0; | |
int p = 2 * dy - dx; | |
for( int x = x0, y = y0; x < x1; x++ ) { | |
if( p >= 0 ) { | |
putpixel(x, y, 7); | |
y++; | |
p += 2 * dy - 2 * dx; | |
} else { | |
putpixel(x, y, 7); | |
p += 2 * dy; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Struct Version.
Golang version: