void window::clear() { for (int x = 0; x < 128; ++x) { for (int y = 0; y < 64; ++y) { print_pixel(hdc, x, y, scale, RGB(0xFF, 0xFF, 0xFF)); } } }
void print_screen(t_base *a) { t_bunny_position pos; int i; i = -1; a->color_pixel = bunny_malloc(sizeof(t_color_pixel)); while (++i < a->pix->clipable.clip_width * a->pix->clipable.clip_height) { a->color_pixel->delt = -1; pos.x = i % a->pix->clipable.clip_width; pos.y = i / a->pix->clipable.clip_width; print_pixel(a, pos); if (a->color_pixel->delt != -1) { dist_light(a); pixel(a->pix, &pos, a->color_pixel->color); } } bunny_free(a->color_pixel); while (a->element) a->element = del_mylist(a->element); while (a->light) a->light = del_mylist(a->light); }
inline void ft_print2dline_octant7(t_2denv *e, t_2dline *line) { int diff; int x; int y; diff = line->to.y - line->from.y; x = line->from.x; y = line->from.y; while (1) { print_pixel(&e->img, x, y, line->color); if (--y < line->to.y) break ; if ((diff += 2 * (line->to.x - line->from.x)) > 0) { ++x; diff += 2 * (line->to.y - line->from.y); } } }
void print_line( int start_x, int start_y, int end_x, int end_y ){ const int width = 1; // http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm // http://homepages.enterprise.net/murphy/thickline/index.html // int i0 = 0; int i1 = 1; int i0 = - ( width / 2 ); // int i1 = 1; int i1 = width + i0; // i1 = width; int x0 = start_x; int y0 = start_y; int x1 = end_x; int y1 = end_y; int Dx = x1 - x0; int Dy = y1 - y0; int steep = (abs(Dy) >= abs(Dx)); int ox = 0, oy = 1; if( steep ){ swap(x0, y0); swap(x1, y1); // recompute Dx, Dy after swap Dx = x1 - x0; Dy = y1 - y0; swap( ox, oy ); } int xstep = 1; if( Dx < 0 ){ xstep = -1; Dx = -Dx; } int ystep = 1; if( Dy < 0 ){ ystep = -1; Dy = -Dy; } int TwoDy = 2*Dy; int TwoDyTwoDx = TwoDy - 2*Dx; // 2*Dy - 2*Dx int E = TwoDy - Dx; //2*Dy - Dx int y = y0; int xDraw, yDraw; for( int x = x0; x != x1; x += xstep ){ if (steep) { xDraw = y; yDraw = x; } else { xDraw = x; yDraw = y; } for( int i = i0; i < i1; i++ ){ print_pixel( xDraw + ox * i, yDraw + oy * i ); } // trace << xDraw << " " << yDraw; if( E > 0 ){ E += TwoDyTwoDx; //E += 2*Dy - 2*Dx; y = y + ystep; } else { E += TwoDy; //E += 2*Dy; } } }
void window::draw(int x, int y, COLORREF color) { print_pixel(hdc, x, y, scale, color); }
void window::draw(int x, int y) { print_pixel(hdc, x, y, scale, RGB(0x00, 0x00, 0x00)); }
void print_texto(char * _pantalla, int columna, int fila, char * texto, char formato){ int y = 0; while(texto[y] != 0){print_pixel(_pantalla, columna + y, fila, texto[y], formato); y++;} }
void inicializar_pantalla(){ int x; int y; char * posicion; char * stringz; char * stringw; char letra; char formato; posicion = (char *) BUFFERESTADO; //DIBUJO MAPA BUFFER ESTADO x = 0; y = 0; //PRINT TODA LA PAGINA DE BLANCO letra = 0X20; formato = C_BG_LIGHT_GREY; while(y<24){ x = 0; while(x<80){print_pixel(posicion, x, y, letra, formato); x++;} y++; } //PRINT FRANJA SUPERIOR DE NEGRO x = 0; letra = 0x20; formato = (C_FG_WHITE | C_BG_BLACK ); while(x < 80){ print_pixel(posicion, x, 0, letra, formato); x++;} //PRINT NOMBRE DE GRUPO stringz = NAMEGRUPO; y = 0; x = 0; print_texto(posicion, x, y, stringz, formato); //PRINT TABLA ERRORES stringz = " "; x = TABLAERRORES_X; y = TABLAERRORES_Y; char color; color = (C_FG_BLACK | C_BG_CYAN); while(y < TABLAERRORES_ALTO + 1){ print_texto(posicion, x, y, stringz, color); color = (C_FG_WHITE | C_BG_BLACK); y++; } x = 1; stringz = "NAVIO Z"; stringw = " "; int stringflagnum = 6;//STRINGFLAGNUM ES EL ULTIMO CARACTER DEL STRING while (x < 9){ //X es el FLAG actual stringz[stringflagnum] = ASCII_first_num + x; int pos_x = bandera_posicion_x(x); int pos_y = bandera_posicion_y(x); y = 0; //Y es el caracter actual del string print_texto(posicion,pos_x + 3 , pos_y - 1, stringz, (C_FG_BLACK | C_BG_LIGHT_GREY )); y = 0; //columna while(y < 5){print_texto(posicion, pos_x, pos_y+y, stringw, C_BG_BROWN); y++;} x++; } //PRINT TABLA INFERIOR stringz = " "; x = 2; y = 16; color = (C_FG_BLACK | C_BG_CYAN); while(y < 24){ print_texto(posicion, x, y, stringz, color); y++; } y = 16; x = 1; formato = ((C_FG_CYAN | C_BG_RED)); while(y < 24){ print_pixel(posicion, x, y, ASCII_first_num + y - 15, formato); y++; } posicion = (char *) BUFFERMAPA; x = 0; y = 256*2; // Un 1 mb divido 4kb while(x< y){ posicion[x] = 57; x++; posicion[x] = (C_FG_BLUE | C_BG_GREEN); x++; } y += ((256*2) *6); // Un 6 mb divido 4kb y += 256; // Un 6.5mb divido 4kb //y = (1920*2); while(x < y){ posicion[x] = 38; x++; posicion[x] = (C_FG_RED | C_BG_BLUE); x++; } posicion = (char *) VIDEO; x = 0; while(x<(2000*2)){ posicion[x] = 33; x++; posicion[x] = C_BG_RED ; x++; } }