diff options
| author | Anhgelus Morhtuuzh <anhgelus@anhgelus.world> | 2025-01-31 15:39:30 +0100 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <anhgelus@anhgelus.world> | 2025-01-31 15:39:30 +0100 |
| commit | d7c69934248f3fab4988c0d37c11feba25d653b8 (patch) | |
| tree | 6c396257cb21374e13a26b8f78c05353806220bc /semestre 2/informatique/tme/semaine2/12_droite_points.c | |
| parent | ed631f52ee7af474625e37c6855c7c55903317fc (diff) | |
Ajout du début du deuxième semestre
Diffstat (limited to 'semestre 2/informatique/tme/semaine2/12_droite_points.c')
| -rw-r--r-- | semestre 2/informatique/tme/semaine2/12_droite_points.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/semestre 2/informatique/tme/semaine2/12_droite_points.c b/semestre 2/informatique/tme/semaine2/12_droite_points.c new file mode 100644 index 0000000..a202e24 --- /dev/null +++ b/semestre 2/informatique/tme/semaine2/12_droite_points.c @@ -0,0 +1,34 @@ +#include <cini.h> +#define WIDTH 400 +#define HEIGHT 400 + +int position(int a, int b, int x, int y){ + // t(z) = az+b + // y(x) = alpha x + beta + int straight_line_y = a*x+b; + if (straight_line_y > y) return 1; + if (straight_line_y < y) return -1; + return 0; +} + +void affiche(int a, int b, int width, int height){ + for (int x = 0; x < width; x++){ + for (int y = 0; y < height; y++){ + int pos = position(a, b, x, y); + char* color; + if (pos == 1) color = "red"; + else if (pos == -1) color = "blue"; + else color = "black"; + CINI_draw_pixel(x, y, color); + } + } +} + +int main(){ + CINI_open_window(WIDTH, HEIGHT, "Hello"); + CINI_fill_window("white"); + affiche(1, 0, WIDTH, HEIGHT); + CINI_loop(); + return 0; +} + |
