diff --git a/src/field.c b/src/field.c index acb3b4ce7f4208a3650b9d5144d7f09eeb85ae66..293f84a77cbad7ae64e8bf5fa748d039fc056983 100644 --- a/src/field.c +++ b/src/field.c @@ -40,7 +40,7 @@ bool compute_total_normalized_e(charge_t *charges, int num_charges, vec2 p, doub // starting from pos0. // Returns false if pos0 is not a valid position // (for example if pos0 is too close to a charge). -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) { +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) { vec2 pos = vec2_create(pos0.x, pos0.y); vec2 pos_sum; for (int i = 0; i < num_charges; i++) @@ -55,7 +55,7 @@ bool draw_field_line(struct gfx_context_t *ctxt, charge_t *charges, int num_char // Draw all the charges // A circle with minus sign for negative charges // A circle with a plus sign for positive charges -void draw_charges(struct gfx_context_t *context, charge_t *charges, int num_charges, double x0, double x1, double y0, double y1) { +static void draw_charges(struct gfx_context_t *context, charge_t *charges, int num_charges, double x0, double x1, double y0, double y1) { for (int i = 0; i < num_charges; i++) { coordinates_t charge_center = position_to_coordinates(WID, HEI, x0, x1, y0, y1, charges[i].pos); diff --git a/src/field.h b/src/field.h index 422593307ee637ce521141394783f07765879f88..6266ea334e67d0e42473e9f51d03d6aa9302fbdd 100644 --- a/src/field.h +++ b/src/field.h @@ -22,12 +22,12 @@ bool compute_total_normalized_e(charge_t *charges, int num_charges, vec2 p, doub // starting from pos0. // Returns false if pos0 is not a valid position // (for example if pos0 is too close to a charge). -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); +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 -void draw_charges(struct gfx_context_t *context, charge_t *charges, int num_charges, double x0, double x1, double y0, double y1); +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, diff --git a/src/main.c b/src/main.c index 652462d384358f7fa28769505edc83bb6f5b5bfe..085c65139147b65cf03da8240fd2e9e9d244be61 100644 --- a/src/main.c +++ b/src/main.c @@ -18,13 +18,8 @@ int main() { {.q=0.25, .pos=vec2_create(0.75, 0.5)}, }; struct gfx_context_t *ctxt = gfx_create("elec", WID, HEI); - - draw_charges(ctxt, charges, NCHARGES, 0.0, 1.0, 0.0, 1.0); - for (int i = 0; i < NCHARGES; ++i) { - vec2 start = vec2_normalize(vec2_create(rand(), rand())); - draw_field_line(ctxt, charges, NCHARGES, DX, start, 0.0, 1.0, 0.0, 1.0); - } + draw_everything(ctxt, charges, NCHARGES, NLINES, DX, 0.0, 1.0, 0.0, 1.0); while (gfx_keypressed() != SDLK_ESCAPE) gfx_present(ctxt); gfx_destroy(ctxt);