-
Notifications
You must be signed in to change notification settings - Fork 0
/
vertical.c
56 lines (52 loc) · 1.51 KB
/
vertical.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* horizontal.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ghery <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/04/12 14:50:12 by ghery #+# #+# */
/* Updated: 2016/04/14 16:48:16 by ghery ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
static void init(t_param *p)
{
p->YC = p->YC + 1;
p->l.xb = find_x(p);
p->l.yb = find_y(p);
p->YC = p->YC - 1;
p->l.xa = find_x(p);
p->l.ya = find_y(p);
}
void vertical_line(t_param *p)
{
int dx;
int dy;
init(p);
dx = p->l.xb - p->l.xa;
dy = p->l.yb - p->l.ya;
if (dx > 0)
{
DXS(p, dx, dy);
}
else if (dx < 0)
{
DXI(p, dx, dy);
}
else
{
if (dy > 0)
while (p->l.ya != p->l.yb)
{
mlx_pixel_put(p->mlx, p->win, p->l.xa, p->l.ya, color(p));
p->l.ya += 1;
}
else
while (p->l.ya != p->l.yb)
{
mlx_pixel_put(p->mlx, p->win, p->l.xa, p->l.ya, color(p));
p->l.ya -= 1;
}
}
}