stick with the colors
This commit is contained in:
Binary file not shown.
BIN
builds/fdf.o
BIN
builds/fdf.o
Binary file not shown.
Binary file not shown.
BIN
builds/modifs.o
BIN
builds/modifs.o
Binary file not shown.
BIN
builds/parse.o
BIN
builds/parse.o
Binary file not shown.
@@ -76,6 +76,11 @@ int **parse_map(t_fdf *fdf, int fd);
|
||||
// color for altitude
|
||||
# define COLOR_START 0xffffff
|
||||
# define COLOR_END 0x00d700
|
||||
// R,G,B colors
|
||||
// ex for col = 0x236ad0
|
||||
# define COLOR_R(col) ((col & 0xff0000) >> 16) // output 23
|
||||
# define COLOR_G(col) ((col & 0x00ff00) >> 8) // output 6a
|
||||
# define COLOR_B(col) (col & 0x0000ff) // output d0
|
||||
|
||||
# define ESCAPE 65307
|
||||
# define UP 65362
|
||||
|
||||
2
libft
2
libft
Submodule libft updated: f32d4bbc96...603303a21b
@@ -39,13 +39,27 @@ void draw_grid(t_fdf *fdf, int i, int j)
|
||||
draw_lines(fdf, point_start, point_end);
|
||||
free(point_start);
|
||||
free(point_end);
|
||||
|
||||
/*
|
||||
const char c = 'w';
|
||||
const int n = 23;
|
||||
const char *s = "hello";
|
||||
ft_putchar(c); ft_putchar_fd(',',1);
|
||||
ft_putchar_fd(c, 1); ft_putchar_fd('\n',1);
|
||||
ft_putnbr(n); ft_putchar_fd(',',1);
|
||||
ft_putnbr_fd(n, 1); ft_putchar_fd('\n',1);
|
||||
ft_putstr(s); ft_putchar_fd(',',1);
|
||||
ft_putstr_fd(s, 1); ft_putchar_fd('\n',1);
|
||||
ft_putnbrbase(n, "01"); ft_putchar_fd(',',1);
|
||||
ft_putnbrbase_fd(n, "01", 1); ft_putchar_fd('\n',1);
|
||||
ft_putchar_fd('\n',1);
|
||||
*/
|
||||
}
|
||||
|
||||
// return the position of the point X
|
||||
// return the position of the point p
|
||||
// in percentage of the total height of the map :
|
||||
// z_min---start---point---end----z_max
|
||||
// 0%--------s%-----P-------e%-----100%
|
||||
// 0%--------s%-----p-------e%-----100%
|
||||
// line: -------------
|
||||
// ex. . . . . . ---e
|
||||
// --- .
|
||||
@@ -117,7 +131,15 @@ void draw_lines(t_fdf *fdf, int *start, int *end)
|
||||
int dy;
|
||||
int i;
|
||||
int j;
|
||||
int z;
|
||||
int percent;
|
||||
|
||||
/*
|
||||
int color_r, color_g, color_b;
|
||||
color_r = rand() % 0xff + 1;
|
||||
color_g = rand() % 0xff + 1;
|
||||
color_b = rand() % 0xff + 1;
|
||||
int color = (color_r << 16) + (color_g << 8) + color_b;
|
||||
*/
|
||||
|
||||
if (end)
|
||||
{
|
||||
@@ -134,28 +156,60 @@ ft_putnbr_fd(fdf->min_z,1);
|
||||
ft_putchar_fd(',',1);
|
||||
ft_putnbr_fd(fdf->max_z,1);
|
||||
ft_putchar_fd(')',1);
|
||||
*/
|
||||
|
||||
ft_putstr("\ndraw line\n");
|
||||
*/
|
||||
i = 0;
|
||||
j = 0;
|
||||
while (ft_abs(i) <= ft_abs(dx) && ft_abs(j) <= ft_abs(dy))
|
||||
{
|
||||
z = color_percent(fdf, start, end, ft_abs(i) + ft_abs(j), ft_abs(dx) + ft_abs(dy));
|
||||
draw_color_pixel(fdf, start[0] + i, start[1] + j, z);
|
||||
percent = color_percent(fdf, start, end, ft_abs(i) + ft_abs(j), ft_abs(dx) + ft_abs(dy));
|
||||
draw_color_pixel(fdf, start[0] + i, start[1] + j, percent);
|
||||
//draw_color_pixel(fdf, start[0] + i, start[1] + j, color);
|
||||
if (!ft_abs(dx) || ft_abs(j) < ft_abs(i * dy / dx))
|
||||
j += ft_sign(dy);
|
||||
else
|
||||
i += ft_sign(dx);
|
||||
}
|
||||
}
|
||||
/*
|
||||
ft_putstr("\nEND line\n");
|
||||
*/
|
||||
}
|
||||
|
||||
void draw_color_pixel(t_fdf *fdf, int new_x, int new_y, int z)
|
||||
int get_primary_color(char primar, int percent)
|
||||
{
|
||||
int start_color;
|
||||
int end_color;
|
||||
int new_primary_color;
|
||||
int offset;
|
||||
|
||||
if ((primar == 'r') | (primar == 'R'))
|
||||
offset = 16;
|
||||
else if ((primar == 'g') | (primar == 'G'))
|
||||
offset = 8;
|
||||
else if ((primar == 'b') | (primar == 'B'))
|
||||
offset = 0;
|
||||
|
||||
start_color = (COLOR_START & (0x000000ff << offset)) >> offset;
|
||||
end_color = (COLOR_END & (0x000000ff << offset)) >> offset;
|
||||
|
||||
new_primary_color = (end_color - start_color) * percent / 100;
|
||||
new_primary_color = start_color + new_primary_color;
|
||||
return (new_primary_color);
|
||||
}
|
||||
|
||||
void draw_color_pixel(t_fdf *fdf, int new_x, int new_y, int percent)
|
||||
{
|
||||
int color_r;
|
||||
int color_g;
|
||||
int color_b;
|
||||
int color;
|
||||
|
||||
color = COLOR_START;
|
||||
/*
|
||||
color = COLOR_START;
|
||||
color = 0x236ad0;
|
||||
|
||||
int color_start;
|
||||
int color_end;
|
||||
|
||||
@@ -165,10 +219,59 @@ void draw_color_pixel(t_fdf *fdf, int new_x, int new_y, int z)
|
||||
int color_g;
|
||||
int color_b;
|
||||
|
||||
// color masks
|
||||
# define R_MASK 0xff0000
|
||||
# define G_MASK 0x00ff00
|
||||
# define B_MASK 0x0000ff
|
||||
|
||||
start: 245 0 | 0 | ? 0 ?=0 | ? 50 ?=70 | ? 30 ?=42 |
|
||||
end : 105 100 | 105-245=-140 | 140 100 | 140 100 | 140 100 |
|
||||
|
||||
start: 245 0 | 0 | ? 0 ?=0 | ? 50 ?=-70 | ? 30 ?=-42 |
|
||||
end : 105 100 | 105-245=-140 | -140 100 | -140 100 | -140 100 |
|
||||
|
||||
start: 105 0 | 0 | ? 0 ?=0 | ? 50 ?=70 | ? 30 ?=42 |
|
||||
end : 245 100 | 245-105=140 | 140 100 | 140 100 | 140 100 |
|
||||
|
||||
(end - start) * percent / 100
|
||||
|
||||
|
||||
ft_putchar('[');
|
||||
ft_putnbrbase(COLOR_START, "0123456789abcdef");
|
||||
ft_putchar(',');
|
||||
ft_putnbrbase(COLOR_END, "0123456789abcdef");
|
||||
ft_putchar(',');
|
||||
ft_putnbrbase(get_primary_color('r', percent), "0123456789abcdef");
|
||||
ft_putchar(',');
|
||||
ft_putnbrbase(get_primary_color('g', percent), "0123456789abcdef");
|
||||
ft_putchar(',');
|
||||
ft_putnbrbase(get_primary_color('b', percent), "0123456789abcdef");
|
||||
ft_putchar(',');
|
||||
ft_putnbrbase((get_primary_color('r', percent)<<16) + (get_primary_color('g', percent)<<8) + get_primary_color('b', percent), "0123456789abcdef");
|
||||
ft_putchar(']');
|
||||
*/
|
||||
|
||||
/*
|
||||
*/
|
||||
color_r = get_primary_color('r', percent);
|
||||
color_g = get_primary_color('g', percent);
|
||||
color_b = get_primary_color('b', percent);
|
||||
color = (color_r << 16) + (color_g << 8) + color_b;
|
||||
|
||||
/*
|
||||
ft_putchar('[');
|
||||
ft_putnbr(percent);
|
||||
ft_putchar(',');
|
||||
ft_putnbrbase(color, "0123456789abcdef");
|
||||
ft_putchar(']');
|
||||
*/
|
||||
|
||||
/*
|
||||
01 10 01 01
|
||||
00 11 11 11
|
||||
-----------
|
||||
00 10 01 01
|
||||
*/
|
||||
color = color ^ (((0xff / fdf->z_amplitude) * (z - fdf->min_z)) << 16);
|
||||
color = color ^ (((0xff / fdf->z_amplitude) * (z - fdf->min_z)) << 8);
|
||||
color = color ^ (((0xff / fdf->z_amplitude) * (z - fdf->min_z)) << 0);
|
||||
|
||||
/*
|
||||
int color;
|
||||
|
||||
Reference in New Issue
Block a user