diff --git a/draw.c b/draw/draw.c similarity index 90% rename from draw.c rename to draw/draw.c index d4be34be4912fb5950b9103a3b1cc9bec9c6981c..18e44be671e30145a271fdbd4224f738ea2d19f5 100644 --- a/draw.c +++ b/draw/draw.c @@ -9,8 +9,21 @@ * */ +#include <math.h> #include "draw.h" -#include "math.h" + +/** + * @brief Create a coordinate + * + * @param row_ Row number + * @param column_ Column number + * @return coordinates_t + */ +coordinates_t coordinates_create(int row_, int column_) +{ + coordinates_t c = {.row = row_, .column = column_}; + return c; +} /** * @brief Bresenham's line algorithme. diff --git a/draw.h b/draw/draw.h similarity index 72% rename from draw.h rename to draw/draw.h index 36be2b8b7f7f442db0b54ddee68a0decdc1bea2a..5f372073b6b1bebb80d5443e7d2a1d83d7a00861 100644 --- a/draw.h +++ b/draw/draw.h @@ -14,8 +14,23 @@ #include <stdlib.h> #include <stdio.h> -#include "utils.h" -#include "gfx/gfx.h" +#include <stdint.h> +#include "../gfx/gfx.h" + +typedef struct +{ + uint32_t row; + uint32_t column; +} coordinates_t; + +/** + * @brief Create a coordinate + * + * @param row_ Row number + * @param column_ Column number + * @return coordinates_t + */ +coordinates_t coordinates_create(int row_, int column_); /** * @brief Draw a line using the Bresenham's line algorithm diff --git a/test-draw.c b/draw/test.c similarity index 97% rename from test-draw.c rename to draw/test.c index 3dcfbeb83fb76d510c4e459f997b6c73f3a7f97f..365e491ec99a6bf1add1863a39b384e211df3ec7 100644 --- a/test-draw.c +++ b/draw/test.c @@ -9,8 +9,7 @@ * */ #include <stdlib.h> -#include "gfx/gfx.h" -#include "utils.h" +#include "../gfx/gfx.h" #include "draw.h" int main(void) { diff --git a/main.c b/main.c index f786b12d6dc7c98088d1753a31c86c926328d424..83699785be4f34c784301c9936284376e40e350f 100644 --- a/main.c +++ b/main.c @@ -2,7 +2,6 @@ #include <time.h> #include <math.h> #include "gfx/gfx.h" -#include "draw.h" int main(void) { const int WINDOW_SIZE_X = 500; diff --git a/makefile b/makefile index 69d7c606d932a91b15822924d0d9474c7dd8271f..ffedbfa822d197abcb5f6f6d3ab826de0909af19 100644 --- a/makefile +++ b/makefile @@ -10,7 +10,7 @@ BIN = bin RUN = ./$(BIN)/$(TARGET) # Get source and object -SRCS = $(filter-out test%.c, $(wildcard *.c */*.c)) +SRCS = $(filter-out $(wildcard */test.c), $(wildcard *.c */*.c)) OBJS = $(addprefix $(BIN)/, $(SRCS:.c=.o)) PHONY := $(TARGET) @@ -38,9 +38,9 @@ PHONY += clean clean: rm -rf $(BIN) -test-draw: test-draw.c - $(CC) $(CFLAGS) -o $(BIN)/$@.o -c $< $(LDFLAGS) - $(CC) $(CFLAGS) -o $(BIN)/$@ $(BIN)/$@.o $(BIN)/draw.o $(BIN)/gfx/gfx.o $(BIN)/utils.o $(LIBS) $(LDFLAGS) - ./$(BIN)/$@ +test-draw: draw/test.c + $(CC) $(CFLAGS) -o $(BIN)/draw/$@.o -c $< $(LDFLAGS) + $(CC) $(CFLAGS) -o $(BIN)/draw/$@ $(BIN)/draw/$@.o $(BIN)/draw/draw.o $(BIN)/gfx/gfx.o $(LIBS) $(LDFLAGS) + ./$(BIN)/draw/$@ .PHONY: $(PHONY) diff --git a/utils.c b/utils.c index b352979c761a1591a41b48b152a0d1735524eb6f..fc22d8aee6436e20a871dbd46159103477e9a2a8 100644 --- a/utils.c +++ b/utils.c @@ -3,12 +3,6 @@ #include "vector/vector.h" #include "utils.h" -coordinates_t coordinates_create(int row_, int column_) -{ - coordinates_t c = {.row = row_, .column = column_}; - return c; -} - // Transform a position in the univers [x0,y0]x[x1,y1] to a screen position coordinates_t position_to_coordinates(int width, int height, double x0, double x1, double y0, double y1, vector pos) { diff --git a/utils.h b/utils.h index 0881c6e8e0b333b0f83c6d54cfbb4a9a05b4e078..81f456ea5c552325d17c78222fc7bd9a7ce8a3dd 100644 --- a/utils.h +++ b/utils.h @@ -6,12 +6,7 @@ #include <stdint.h> #include "vector/vector.h" - -typedef struct -{ - uint32_t row; - uint32_t column; -} coordinates_t; +#include "draw/draw.h" typedef struct { @@ -19,8 +14,6 @@ typedef struct vector pos; } charge_t; -coordinates_t coordinates_create(int row_, int column_); - // Transform a position in the univers [x0,y0]x[x1,y1] to a screen position coordinates_t position_to_coordinates(int width, int height, double x0, double x1, double y0, double y1, vector pos);