From d7c69934248f3fab4988c0d37c11feba25d653b8 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Fri, 31 Jan 2025 15:39:30 +0100 Subject: =?UTF-8?q?Ajout=20du=20d=C3=A9but=20du=20deuxi=C3=A8me=20semestre?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../informatique/tme/semaine2/12_droite_points.c | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 semestre 2/informatique/tme/semaine2/12_droite_points.c (limited to 'semestre 2/informatique/tme/semaine2/12_droite_points.c') 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 +#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; +} + -- cgit v1.2.3