Commit b35c0e2f authored by nicolas.albanesi's avatar nicolas.albanesi
Browse files

Added plot_line-

parent 0ea7556c
......@@ -27,8 +27,8 @@
typedef struct
{
uint32_t row;
uint32_t column;
uint32_t x;
uint32_t y;
} coordinates_t;
......
......@@ -72,9 +72,35 @@ void GFX_DrawCircle(SDL_Renderer* ren, coordinates_t c, uint32_t r, uint32_t col
// else
// D = D + 2*dy
// end if
void plot_line_low(coordinates_t p0, coordinates_t p1)
void plot_line_low(SDL_Renderer* ren, coordinates_t p0, coordinates_t p1)
{
int32_t dx = p1.x - p0.x;
int32_t dy = p1.y - p0.y;
int32_t yi = 1;
if (dy > 0)
{
yi = -1;
dy = -dy;
}
int32_t D = (2 * dy) - dx;
uint32_t y = p0.y;
for (uint32_t x = p0.x; x < p1.x; x++)
{
GFX_DrawPixel(ren, x, y, COLOR_RED, 1);
if (D > 0)
{
y += yi;
D = D + (2 * (dy - dx));
}
else
{
D = D + 2 * dy;
}
}
}
// plotLineHigh(x0, y0, x1, y1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment