couleurs marchent avec mise a l'echelle
This commit is contained in:
BIN
builds/fdf.o
BIN
builds/fdf.o
Binary file not shown.
@@ -47,6 +47,7 @@ typedef struct s_fdf
|
||||
int **map;
|
||||
int offset;
|
||||
int margin;
|
||||
int altitude;
|
||||
int win_size_x;
|
||||
int win_size_y;
|
||||
int img_size_x;
|
||||
|
||||
13
srcs/fdf.c
13
srcs/fdf.c
@@ -14,10 +14,12 @@ void color_altitude_pixel(t_fdf *fdf, int new_x, int new_y, int z)
|
||||
int color;
|
||||
|
||||
color = 0xffffff;
|
||||
z = z / fdf->altitude;
|
||||
if (z)
|
||||
{
|
||||
color = color ^ (((0xff * z) / fdf->max_z) << 8 );
|
||||
color = color ^ ((0xff * z) / fdf->max_z);
|
||||
color = color ^ (((0xff / fdf->max_z) * z) << 8 );
|
||||
color = color ^ ((0xff / fdf->max_z) * z);
|
||||
ft_printf("0xff:%i z:%i (0xff / max_z):%i ((0xff / max_z) * z):%i\n", 0xff, z, (0xff / fdf->max_z), ((0xff / fdf->max_z) * z));
|
||||
}
|
||||
draw_pixel(fdf, new_x, new_y, color);
|
||||
}
|
||||
@@ -46,7 +48,7 @@ void draw_image(t_fdf *fdf)
|
||||
|
||||
x = i * fdf->offset - (fdf->map_size_x / 2);
|
||||
y = j * fdf->offset - (fdf->map_size_y / 2);
|
||||
z = fdf->map[j][i];
|
||||
z = fdf->map[j][i] * fdf->altitude;
|
||||
new_x = x * cos(fdf->rad_x) + y * sin(fdf->rad_x);
|
||||
new_y = y * cos(fdf->rad_x) - x * sin(fdf->rad_x);
|
||||
new_y = new_y * cos(fdf->rad_y) - -z * sin(fdf->rad_y);
|
||||
@@ -148,9 +150,10 @@ t_fdf *init_fdf(void)
|
||||
t_fdf *fdf;
|
||||
|
||||
fdf = malloc(sizeof(t_fdf));
|
||||
// map offset and margin
|
||||
fdf->offset = 10;
|
||||
// map offset, margin, and altitude factor
|
||||
fdf->offset = 50;
|
||||
fdf->margin = 50;
|
||||
fdf->altitude = 3;
|
||||
// parse map
|
||||
fdf->map = parse_map(fdf);
|
||||
// size window
|
||||
|
||||
Reference in New Issue
Block a user