void sierpinski(int posx, int posy, t_param *param) { int x; int y; int i; x = -1; while (++x < WIDTH) { y = -1; while (++y < HEIGHT) { Z_I = abs(x - posx); Z_R = abs(y - posy); i = -1; while (((int)Z_I % 3 != 1 || (int)Z_R % 3 != 1) && ++i < ITER) fract_calc(param); if (i != ITER) img_put_pixel(param, x, y, mlx_get_color_value(MLX, 0)); else img_put_pixel(param, x, y, mlx_get_color_value(MLX, 0 | i * PAL[COLOR])); } } }
void img_fill_inside(t_mlx *mlx, t_img *img, t_point *coord, unsigned long colors[2]) { unsigned int color; img_put_pixel(mlx, img, coord, colors[0]); ++coord->x; color = img_get_color(img, coord); if (coord->x <= img->size.x && color != colors[1] && color != colors[0]) img_fill_inside(mlx, img, coord, colors); coord->x -= 2; color = img_get_color(img, coord); if (coord->x >= 0 && color != colors[1] && color != colors[0]) img_fill_inside(mlx, img, coord, colors); ++coord->x; ++coord->y; color = img_get_color(img, coord); if (coord->y <= img->size.y && color != colors[1] && color != colors[0]) img_fill_inside(mlx, img, coord, colors); coord->y -= 2; color = img_get_color(img, coord); if (coord->y >= 0 && color != colors[1] && color != colors[0]) img_fill_inside(mlx, img, coord, colors); ++coord->y; }
static void brot_algo(t_env *env, int xx, int yy) { while (((env->lim->z_r * env->lim->z_r) + (env->lim->z_i * env->lim->z_i)) < 4 && (env->lim->i < env->lim->it_max)) { env->lim->tmp = env->lim->z_r; env->lim->z_r = env->lim->z_r * env->lim->z_r - env->lim->z_i * env->lim->z_i + env->lim->c_r; env->lim->z_i = 2 * env->lim->z_i * env->lim->tmp + env->lim->c_i; env->lim->i++; } if (env->lim->i == env->lim->it_max) { choose_color(env->color, (env->lim->i * 10 / env->lim->it_max), 0, 0); img_put_pixel(env, xx, yy, color_in_int(env->color)); } else { choose_color(env->color, 0, (env->lim->i * 255 * env->lim->it_max), (env->lim->i * 255 * env->lim->it_max)); img_put_pixel(env, xx, yy, color_in_int(env->color)); } }
int img_put_circle(t_mlx *mlx, t_img *img, t_point coord[2], unsigned long color) { double a; t_point p; a = 0; while (a < (2 * M_PI)) { p.x = coord[0].x + coord[1].x * cos(a); p.y = coord[0].y + coord[1].x * sin(a); img_put_pixel(mlx, img, &p, color); a += (2 * M_PI) / (8 * coord[1].x); } return (1); }
void draw_texture_col(t_env *e, t_view *v, t_line *l, int id) { t_texture *t; int pos; int y; t = &(e->t[id]); l->text_x = (int)(l->wall_x * (double)(t->wth)); if ((v->side == 0 && v->rdir.x > 0) || (v->side == 1 && v->rdir.y < 0)) l->text_x = t->wth - l->text_x - 1; y = l->start.y; while (y <= l->end.y) { l->d = (y - e->hgt) * 256 - WIN_H * 128 + l->line_h * 128; l->text_y = (l->d * t->wth / l->line_h) / 256; pos = t->sl * l->text_y + l->text_x * t->bpp / 8; l->color = get_color(v->side, t, pos); img_put_pixel(e, &(e->img), set_vect2i(l->x, y), l->color); y++; } }