-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdraw.c
More file actions
68 lines (60 loc) · 2.08 KB
/
draw.c
File metadata and controls
68 lines (60 loc) · 2.08 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* draw.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aait-ihi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/09 14:37:55 by aait-ihi #+# #+# */
/* Updated: 2019/11/26 02:24:29 by aait-ihi ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
void put_pixel(t_img *img, int x, int y, t_argb color)
{
int i;
if (x >= 0 && x < WIN_WIDTH - MENU_WIDTH && y >= 0 && y < WIN_HIEGHT)
{
i = (x * img->bpp / 8) + (y * img->size_line);
img->data[i] = color.b;
img->data[++i] = color.g;
img->data[++i] = color.r;
}
}
void render(t_fractol *fractol)
{
mlx_put_image_to_window(fractol->mlx_ptr,
fractol->win_ptr,
fractol->img.ptr,
MENU_WIDTH, 0);
}
void draw_rectangle(t_point p1, t_point p2, int color, t_fractol *fractol)
{
int i;
while (p1.y < p2.y)
{
i = p1.x;
while (i < p2.x)
{
mlx_pixel_put(&fractol->mlx_ptr, fractol->win_ptr, i, p1.y, color);
i++;
}
p1.y++;
}
}
void draw_menu(t_fractol *fractol)
{
t_point p1;
t_point p2;
int i;
i = 0;
p1 = (t_point){0, 0};
p2 = (t_point){300, 700};
draw_rectangle(p1, p2, MENU_COLOR, fractol);
PUT_STRING(fractol, START_X_MENU, Y_COLOR_TITLE, WHITE, T1);
PUT_STRING(fractol, START_X_MENU, Y_FRACTAL_CHANGE, WHITE, T2);
PUT_STRING(fractol, START_X_MENU, Y_ITERATION, WHITE, T3);
PUT_STRING(fractol, START_X_MENU, Y_CHANGE_COLOR, WHITE, T4);
PUT_STRING(fractol, START_X_MENU, Y_RESET, WHITE, T5);
PUT_STRING(fractol, START_X_MENU, Y_MOVE, WHITE, T6);
}