Now conforms with style conventions

Also reworded a comment to sound more... fomal.
This commit is contained in:
Alexander Buhl 2021-07-23 23:00:35 +02:00 committed by GitHub
parent 83d0974525
commit aa9a59bd6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2416,19 +2416,19 @@ void ImageDrawPixelV(Image *dst, Vector2 position, Color color)
}
// Draw line within an image
void ImageDrawLine (Image *dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color){
void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color)
{
// Using Bresenham's algorithm as described in
// Drawing Lines with Pixels - Joshua Scott - March 2012
// https://classic.csunplugged.org/wp-content/uploads/2014/12/Lines.pdf
int changeInX = (endPosX - startPosX);
int abs_changeInX = changeInX < 0 ? -changeInX : changeInX;
int abs_changeInX = (changeInX < 0)? -changeInX : changeInX;
int changeInY = (endPosY - startPosY);
int abs_changeInY = changeInY < 0 ? -changeInY : changeInY;
int abs_changeInY = (changeInY < 0)? -changeInY : changeInY;
int startU, startV, endU, V_step; // Substitutions, either U = X, V = Y or vice versa. See loop at end of function
//int endV; // We never need this, i didn't just forget about it! :D
// For understanding I left it in below, too.
//int endV; // This is not needed, but to aid understanding it is left in the code below.
int A, B, P; // See linked paper above. Explained down in the main loop.
@ -2459,7 +2459,7 @@ void ImageDrawLine (Image *dst, int startPosX, int startPosY, int endPosX, int e
changeInY = -changeInY;
}
V_step = changeInY < 0 ? -1 : 1;
V_step = (changeInY < 0)? -1 : 1;
ImageDrawPixel(dst, startU, startV, color); // At this point they are correctly ordered...
}
@ -2488,7 +2488,7 @@ void ImageDrawLine (Image *dst, int startPosX, int startPosY, int endPosX, int e
changeInY = -changeInY;
}
V_step = changeInX < 0 ? -1 : 1;
V_step = (changeInX < 0)? -1 : 1;
ImageDrawPixel(dst, startV, startU, color); // ... but need to be reversed here. Repeated in the main loop below.
}