diff --git a/src/draw.c b/src/draw.c index 41f141701bb1b44157814233204bb88227c4500c..ae3ffd92674b9ae027bb547494302a4934073d23 100644 --- a/src/draw.c +++ b/src/draw.c @@ -4,9 +4,9 @@ #include "field.h" void gfx_draw_line(struct gfx_context_t *ctxt, coordinates_t p0, coordinates_t p1, uint32_t color) { - int dx = abs(p1.column - p0.column); + int dx = abs((int)p1.column - (int)p0.column); int sx = p0.column < p1.column ? 1 : -1; - int dy = -abs(p1.row - p0.row); + int dy = -abs((int)p1.row - (int)p0.row); int sy = p0.row < p1.row ? 1 : -1; int error = dx + dy; @@ -50,7 +50,7 @@ void gfx_draw_circle(struct gfx_context_t *ctxt, coordinates c, uint32_t r, uint if(d >= 2*x){ d = d-2*x-1; x++; - }else if(d < 2 * (r-y)){ + }else if(d < 2 * ((int)r-y)){ d = d + 2*y-1; y--; }else { diff --git a/src/field.c b/src/field.c index 356c8dbd35e25aa0a2e88fcbaf51247075357be7..ec6f1e284904cc8eac72f3d81ba74502b8607c24 100644 --- a/src/field.c +++ b/src/field.c @@ -1,5 +1,6 @@ #include <stdbool.h> #include <stdlib.h> +#include <time.h> #include "draw.h" #include "field.h" @@ -41,10 +42,10 @@ double compute_delta_x(){ } bool is_in_screen(coordinates_t pos){ - if(pos.column > WID || pos.column < 0) + if(pos.column > WID) return false; - if(pos.row > HEI || pos.row < 0) + if(pos.row > HEI) return false; return true; diff --git a/src/field.h b/src/field.h index 6266ea334e67d0e42473e9f51d03d6aa9302fbdd..34dd513faace05dfc54467a53db72bb155645ddb 100644 --- a/src/field.h +++ b/src/field.h @@ -18,17 +18,6 @@ bool compute_e(charge_t c, vec2 p, double eps, vec2 *e); // Return false if for some qiP, norm(qiP) < eps bool compute_total_normalized_e(charge_t *charges, int num_charges, vec2 p, double eps, vec2 *e); -// Compute and then draw all the points belonging to a field line, -// starting from pos0. -// Returns false if pos0 is not a valid position -// (for example if pos0 is too close to a charge). -static bool draw_field_line(struct gfx_context_t *ctxt, charge_t *charges, int num_charges, double dx, vec2 pos0, double x0, double x1, double y0, double y1); - -// Draw all the charges -// A circle with minus sign for negative charges -// A circle with a plus sign for positive charges -static void draw_charges(struct gfx_context_t *context, charge_t *charges, int num_charges, double x0, double x1, double y0, double y1); - void draw_everything( struct gfx_context_t *ctxt, charge_t *charges,