void angle_minimap(t_wolf *wolf) { t_bunny_position pos_one[2]; t_bunny_position pos_two[2]; t_color color; double radius; color.full = RED; pos_one[0].x = 5 * 20 + 10; pos_one[0].y = 5 * 20 + 10; pos_two[0].x = 5 * 20 + 10; pos_two[0].y = 5 * 20 + 10; radius = 0; radius = left_ray(wolf, radius); pos_one[1].x = pos_one[0].x + cos(radius * M_PI / 180) * 30; pos_one[1].y = pos_one[0].y + sin(radius * M_PI / 180) * 30; tekline(wolf->rendu, pos_one, &color); radius = right_ray(radius); pos_two[1].x = pos_two[0].x + cos(radius * M_PI / 180) * 30; pos_two[1].y = pos_two[0].y + sin(radius * M_PI / 180) * 30; tekline(wolf->rendu, pos_two, &color); pos_two[0].x = pos_one[1].x; pos_two[0].y = pos_one[1].y; tekline(wolf->rendu, pos_two, &color); }
void pos_poly(t_form *form, t_bunny_pixelarray *pix) { t_obj *tmp; t_bunny_position pos[2]; t_color col[2]; tmp = form->objs; while (tmp != NULL) { set_pos(pos, &tmp->a, &tmp->b, col); add_pos(pos, form); tekline(pix, pos, col); set_pos(pos, &tmp->b, &tmp->c, col); add_pos(pos, form); tekline(pix, pos, col); set_pos(pos, &tmp->c, &tmp->a, col); add_pos(pos, form); tekline(pix, pos, col); tmp = tmp->next; } }
int carre(t_carre base, t_bunny_pixelarray *pix, unsigned int color, int test) { t_bunny_position *carre; int angle; if (test == 1) return(0); angle = 0; carre = malloc(sizeof(t_bunny_position) * 2); carre[0].x = base.origin.x; carre[0].y = base.origin.y; carre[1].x = base.x; carre[1].y = base.origin.y; tekline(pix, carre, color); carre[0].x = base.origin.x; carre[0].y = base.origin.y; carre[1].x = base.origin.x + angle; carre[1].y = base.y; tekline(pix, carre, color); carre[0].x = base.origin.x + angle; carre[0].y = base.y; carre[1].x = base.x + angle; carre[1].y = base.y; tekline(pix, carre, color); carre[0].x = base.x; carre[0].y = base.origin.y; carre[1].x = base.x + angle; carre[1].y = base.y; tekline(pix, carre, color); }
void draw_final_line(void *_data) { t_data *data; t_bunny_position *pos; data = _data; if ((pos = bunny_malloc(sizeof(t_bunny_position *) * 2)) == NULL) return ; pos[0].x = data->line.init_pos.x; pos[0].y = data->line.init_pos.y; pos[1].x = data->line.final_pos.x; pos[1].y = data->line.final_pos.y; tekline(data->crs.calc->pix, pos, &data->tools.color); data->line.pass = -1; data->tools.line_act = 0; }
void show_all_links(t_visu *visu) { t_link *tmp; t_bunny_position pos[2]; t_bunny_position posxy; tmp = visu->link; while (tmp) { posxy = get_first_position(visu, tmp->s1); pos[0].x = posxy.x; pos[0].y = posxy.y; posxy = get_first_position(visu, tmp->s2); pos[1].x = posxy.x; pos[1].y = posxy.y; tekline(visu->pix, pos, WHITE); tmp = tmp->next; } }
void lightning_color(t_bunny_pixelarray *pix, t_bunny_position *pos, unsigned int color, size_t npos) { size_t cur_pos; t_bunny_position tab[2]; cur_pos = 1; while (cur_pos < npos) { tab->x = (pos + cur_pos - 1)->x; tab->y = (pos + cur_pos - 1)->y; (tab + 1)->x = (pos + cur_pos)->x; (tab + 1)->y = (pos + cur_pos)->y; tekline(pix, tab, color); cur_pos += 1; } }
void pencil_draw(t_lapin *lapin, t_bunny_position *pos_fin, unsigned int colore) { t_bunny_position pos_line[2]; t_color color; color.full = colore; if (lapin->pos_mouse_tmp.x == 0 && lapin->pos_mouse_tmp.y == 0) { lapin->pos_mouse_tmp.x = pos_fin->x; lapin->pos_mouse_tmp.y = pos_fin->y; } pos_line[0].x = lapin->pos_mouse_tmp.x; pos_line[0].y = lapin->pos_mouse_tmp.y; pos_line[1].x = pos_fin->x; pos_line[1].y = pos_fin->y; tekline(lapin->pixelarray_2, pos_line, &color, lapin->size); lapin->pos_mouse_tmp.x = pos_fin->x; lapin->pos_mouse_tmp.y = pos_fin->y; }
int main(int ac, char **av) { t_bunny_window *win; t_bunny_pixelarray *img; t_bunny_position pos; t_bunny_position pos_tab[8]; t_bunny_position pos_tab_line[2]; int x[8]; int y[8]; int z[8]; int i; i = 0; /* ** Window starting */ win = bunny_start(WIN_WIDTH, WIN_HEIGHT, 0, "__AMAZING_3D__"); /* ** Img initializing */ img = bunny_new_pixelarray(WIN_WIDTH, WIN_HEIGHT); img->clipable.clip_x_position = 0; img->clipable.clip_y_position = 0; img->clipable.clip_height = WIN_HEIGHT; img->clipable.clip_width = WIN_WIDTH; pos.y = 0; while (pos.y < WIN_HEIGHT) { pos.x = 0; while (pos.x < WIN_WIDTH) { tekpixel(img, pos, BLACK); pos.x += 1; } pos.y += 1; } /* ** INITIALISATIONS */ /* A */ x[0] = 300; y[0] = 0; z[0] = -300; /* B */ x[1] = 900; y[1] = 0; z[1] = -300; /* C */ x[2] = 900; y[2] = 0; z[2] = -800; /* D */ x[3] = 300; y[3] = 0; z[3] = -800; /* E */ x[4] = 300; y[4] = 200; z[4] = -300; /* F */ x[5] = 900; y[5] = 200; z[5] = -300; /* G */ x[6] = 900; y[6] = 200; z[6] = -800; /* H */ x[7] = 300; y[7] = 200; z[7] = -800; /* ** CONVERSION -> PARALLEL */ tekllproject(pos_tab + 0, x[0], y[0], z[0]); tekllproject(pos_tab + 1, x[1], y[1], z[1]); tekllproject(pos_tab + 2, x[2], y[2], z[2]); tekllproject(pos_tab + 3, x[3], y[3], z[3]); tekllproject(pos_tab + 4, x[4], y[4], z[4]); tekllproject(pos_tab + 5, x[5], y[5], z[5]); tekllproject(pos_tab + 6, x[6], y[6], z[6]); tekllproject(pos_tab + 7, x[7], y[7], z[7]); /* ** LINES !!!! */ pos_tab_line[0] = pos_tab[0]; pos_tab_line[1] = pos_tab[1]; tekline(img, pos_tab_line, WHITE); pos_tab_line[0] = pos_tab[1]; pos_tab_line[1] = pos_tab[2]; tekline(img, pos_tab_line, WHITE); pos_tab_line[0] = pos_tab[2]; pos_tab_line[1] = pos_tab[3]; tekline(img, pos_tab_line, WHITE); pos_tab_line[0] = pos_tab[3]; pos_tab_line[1] = pos_tab[0]; tekline(img, pos_tab_line, WHITE); pos_tab_line[0] = pos_tab[4]; pos_tab_line[1] = pos_tab[5]; tekline(img, pos_tab_line, WHITE); pos_tab_line[0] = pos_tab[5]; pos_tab_line[1] = pos_tab[6]; tekline(img, pos_tab_line, WHITE); pos_tab_line[0] = pos_tab[6]; pos_tab_line[1] = pos_tab[7]; tekline(img, pos_tab_line, WHITE); pos_tab_line[0] = pos_tab[7]; pos_tab_line[1] = pos_tab[4]; tekline(img, pos_tab_line, WHITE); pos_tab_line[0] = pos_tab[0]; pos_tab_line[1] = pos_tab[4]; tekline(img, pos_tab_line, WHITE); pos_tab_line[0] = pos_tab[1]; pos_tab_line[1] = pos_tab[5]; tekline(img, pos_tab_line, WHITE); pos_tab_line[0] = pos_tab[2]; pos_tab_line[1] = pos_tab[6]; tekline(img, pos_tab_line, WHITE); pos_tab_line[0] = pos_tab[3]; pos_tab_line[1] = pos_tab[7]; tekline(img, pos_tab_line, WHITE); /* ** Drawing img on win->buffer */ pos.x = 0; pos.y = 0; bunny_blit(&win->buffer, &img->clipable, &pos); /* ** Finally showing our hard work */ bunny_display(win); bunny_loop(win, 42, NULL); bunny_delete_clipable(&(img->clipable)); bunny_stop(win); return (0); }