z des lignes fonctionne

This commit is contained in:
hugogogo
2021-07-22 19:41:35 +02:00
parent 25d3c943d8
commit 34e2e5576f
3 changed files with 21 additions and 17 deletions

Binary file not shown.

BIN
fdf

Binary file not shown.

View File

@@ -16,7 +16,7 @@ void draw_lines(t_fdf *fdf, int *start, int *end)
{
int dx;
int dy;
int dz;
int z;
int i;
int j;
@@ -24,21 +24,20 @@ void draw_lines(t_fdf *fdf, int *start, int *end)
{
dx = end[0] - start[0];
dy = end[1] - start[1];
//dz = end[2] - start[2];
i = 0;
j = 0;
z = start[2];
while (i <= dx && j <= dy)
{
draw_color_pixel(fdf, start[0] + i, start[1] + j, start[2]);
if (j < i * dy / dx)
if ((dx + dy) && (i + j))
z = start[2] + (end[2] - start[2]) * (i + j) / (dx + dy);
draw_color_pixel(fdf, start[0] + i, start[1] + j, z);
if (!dx || j < i * dy / dx)
j++;
else
i++;
}
}
(void)dx;
(void)dy;
(void)dz;
}
// point[0], point[1], point[2] -> new x, new y, new z
@@ -244,16 +243,21 @@ int **parse_map(t_fdf *fdf)
while(++j < 15)
map[i][j] = 0;
}
map[0][0] = 1;
map[1][0] = 2;
map[2][0] = 3;
map[3][0] = 4;
map[4][0] = 5;
map[5][0] = 6;
map[6][0] = 7;
map[7][0] = 8;
map[8][0] = 9;
map[9][0] = 10;
map[9][0] = 1;
map[9][1] = 2;
map[9][2] = 3;
map[9][3] = 4;
map[9][4] = 5;
map[9][5] = 6;
map[9][6] = 7;
map[9][7] = 8;
map[9][8] = 9;
map[9][9] = 10;
map[9][10] = 2;
map[9][11] = 5;
map[9][12] = 8;
map[9][13] = 3;
map[9][14] = 6;
fdf->max_z = 10;
// size map
fdf->map_width = j;