color gradient fonctionne
This commit is contained in:
BIN
builds/fdf.o
BIN
builds/fdf.o
Binary file not shown.
@@ -61,6 +61,7 @@ typedef struct s_fdf
|
||||
double rad_y;
|
||||
int mov_x;
|
||||
int mov_y;
|
||||
int max_z;
|
||||
int img_bpp;
|
||||
int img_sizel;
|
||||
int img_endian;
|
||||
|
||||
33
srcs/fdf.c
33
srcs/fdf.c
@@ -9,6 +9,19 @@ int keypress(int keycode, t_fdf *fdf);
|
||||
void rotation_state(t_fdf *fdf);
|
||||
int **parse_map(t_fdf *fdf);
|
||||
|
||||
void color_altitude_pixel(t_fdf *fdf, int new_x, int new_y, int z)
|
||||
{
|
||||
int color;
|
||||
|
||||
color = 0xffffff;
|
||||
if (z)
|
||||
{
|
||||
color = color ^ (((0xff * z) / fdf->max_z) << 8 );
|
||||
color = color ^ ((0xff * z) / fdf->max_z);
|
||||
}
|
||||
draw_pixel(fdf, new_x, new_y, color);
|
||||
}
|
||||
|
||||
void draw_image(t_fdf *fdf)
|
||||
{
|
||||
int i;
|
||||
@@ -34,12 +47,12 @@ void draw_image(t_fdf *fdf)
|
||||
x = i * fdf->offset;
|
||||
y = j * fdf->offset;
|
||||
z = fdf->map[j][i];
|
||||
new_x = x * cos(fdf->rad_y) + y * sin(fdf->rad_y);
|
||||
new_y = y * cos(fdf->rad_y) - x * sin(fdf->rad_y);
|
||||
new_y = new_y * cos(fdf->rad_x) - z * sin(fdf->rad_x);
|
||||
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);
|
||||
new_x += fdf->margin + fdf->mov_x;
|
||||
new_y += fdf->margin + fdf->mov_y;
|
||||
draw_pixel(fdf, new_x, new_y, 0xffffff);
|
||||
color_altitude_pixel(fdf, new_x, new_y, z);
|
||||
}
|
||||
}
|
||||
// put image on screen
|
||||
@@ -179,7 +192,17 @@ int **parse_map(t_fdf *fdf)
|
||||
while(++j < 15)
|
||||
map[i][j] = 0;
|
||||
}
|
||||
map[3][6] = 10;
|
||||
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;
|
||||
fdf->max_z = 10;
|
||||
// size map
|
||||
fdf->map_width = j;
|
||||
fdf->map_height = i;
|
||||
|
||||
Reference in New Issue
Block a user