Bonjour.
Je dois faire une rosace en C.
Pour cela j'utilise la minilibx:
theta sert a convertir l'angle en radian.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 #include "mlx.h" #include <stdlib.h> #include "my.h" #define PI 3.14159 #include <math.h> int gere_key(int keycode, void *param) { param = 0; if (keycode == 65307) exit(1); return (0); } int option1() { void *mlx_ptr; void *win_ptr; int x; int y; int clr; int nb; double theta; int r; int angle; nb = 1000; mlx_ptr = mlx_init(); win_ptr = mlx_new_window(mlx_ptr, 500, 500, "option1"); angle = 0; clr = 0xFF0000; while (nb--) { theta = PI * angle / 180; r = cos(3.5 * theta); x = 250 + r * cos(theta) * 1000; y = 250 + r * sin(theta) * 1000; r = r * 1000; mlx_pixel_put(mlx_ptr, win_ptr, x, y, clr); angle++; if (angle == 361) angle = 0; } mlx_key_hook(win_ptr, gere_key, 0); mlx_loop(mlx_ptr); return (0); }
Seulement au lieu d'avoir une rosace j'ai juste un point au milieu de ma fenetre et je ne comprend pas pourquoi.
Partager