Commit 0ea7556c authored by nicolas.albanesi's avatar nicolas.albanesi
Browse files

Added the skeleton for plot line

parent 39f693ee
......@@ -25,8 +25,18 @@
#define COLOR_WHITE 0x00FFFFFF
#define COLOR_YELLOW 0x00FFFF00
typedef struct
{
uint32_t row;
uint32_t column;
} coordinates_t;
void GFX_ClearScreen(SDL_Renderer* ren, uint32_t color);
void GFX_DrawPixel(SDL_Renderer* ren, int x, int y, uint32_t color, int alpha);
void GFX_DrawLine(SDL_Renderer* ren, coordinates_t p0, coordinates_t p1, uint32_t color);
void GFX_DrawCircle(SDL_Renderer* ren, coordinates_t c, uint32_t r, uint32_t color);
#endif
\ No newline at end of file
#include "../includes/gfx.h"
/**
* @brief Fills the screen with one color
*
* @param ren
* @param color
*/
void GFX_ClearScreen(SDL_Renderer* ren, uint32_t color)
{
SDL_SetRenderDrawColor(ren, COLOR_GET_R(color), COLOR_GET_G(color), COLOR_GET_B(color), 255);
SDL_RenderClear(ren);
}
/**
* @brief Draw a pixel on the screen
*
* @param ren
* @param x
* @param y
* @param color
* @param alpha
*/
void GFX_DrawPixel(SDL_Renderer* ren, int x, int y, uint32_t color, int alpha)
{
SDL_SetRenderDrawColor(ren, COLOR_GET_R(color), COLOR_GET_G(color), COLOR_GET_B(color), alpha);
SDL_RenderDrawPoint(ren, x, y);
}
\ No newline at end of file
}
/**
* @brief Draw a line on the screen
*
* @param ren
* @param p0
* @param p1
* @param color
*/
void GFX_DrawLine(SDL_Renderer* ren, coordinates_t p0, coordinates_t p1, uint32_t color)
{
}
/**
* @brief Draw a circle on the screen
*
* @param ren
* @param c coord of the center of the circle
* @param r radius of the circle
* @param color
*/
void GFX_DrawCircle(SDL_Renderer* ren, coordinates_t c, uint32_t r, uint32_t color)
{
}
// plotLineLow(x0, y0, x1, y1)
// dx = x1 - x0
// dy = y1 - y0
// yi = 1
// if dy < 0
// yi = -1
// dy = -dy
// end if
// D = (2 * dy) - dx
// y = y0
// for x from x0 to x1
// plot(x, y)
// if D > 0
// y = y + yi
// D = D + (2 * (dy - dx))
// else
// D = D + 2*dy
// end if
void plot_line_low(coordinates_t p0, coordinates_t p1)
{
}
// plotLineHigh(x0, y0, x1, y1)
// dx = x1 - x0
// dy = y1 - y0
// xi = 1
// if dx < 0
// xi = -1
// dx = -dx
// end if
// D = (2 * dx) - dy
// x = x0
// for y from y0 to y1
// plot(x, y)
// if D > 0
// x = x + xi
// D = D + (2 * (dx - dy))
// else
// D = D + 2*dx
// end if
void plot_line_high(coordinates_t p0, coordinates_t p1)
{
}
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