//borlacon.cpp //подпрограммы рисования для консольных функций Borland #include "borlaCon.h" char fill_char; //cимвол заполнения //--------------------------------------------------------- void init_graphics() { textcolor(WHITE); //текст белый по черному textbackground(BLACK); fill_char = '\xDB'; // заполнение по умолчанию clrscr(); } //--------------------------------------------------------- void set_color(color foreground, color background) { textcolor( static_cast(foreground) ); textbackground( static_cast(background) ); } //--------------------------------------------------------- void set_cursor_pos(int x, int y) { gotoxy(x, y); } //--------------------------------------------------------- void clear_screen() { clrscr(); } //--------------------------------------------------------- void wait(int milliseconds) { Sleep(milliseconds); } //--------------------------------------------------------- void clear_line() // очистка до конца строки { // 80 пробелов //.....1234567890123456789012345678901234567890 //.....0........1.........2.........3.........4 cputs(" "); cputs(" "); } //конец clreol() //--------------------------------------------------------- void draw_rectangle(int left, int top, int right, int bottom) { int j; char temp[80]; int width = right - left + 1; for(j=0; j(radius); for(theta=0; theta<=pi/2; theta+=increment) //четверть //круга { xF = radius * cos(theta); xN = static_cast(xF * 2 / 1); //пикселы не //квадратные yN = static_cast(radius * sin(theta) + 0.5); x = xC-xN; while(x <= xC+xN) //заполнить две гориз. линии { //по одной на каждую полуокружность set_cursor_pos(x, yC-yN); putch(fill_char);//верх set_cursor_pos(x++, yC+yN); putch(fill_char);//низ } } //конец for } //конец circle() //--------------------------------------------------------- void draw_line(int x1, int y1, int x2, int y2) { int w, z, t, w1, w2, z1, z2; double xDelta=x1-x2, yDelta=y1-y2, slope; bool isMoreHoriz; if( fabs(xDelta) > fabs(yDelta) ) //еще горизонтальная { isMoreHoriz = true; slope = yDelta / xDelta; w1=x1; z1=y1; w2=x2, z2=y2; //w=x, z=y } else //еще вертикальная { isMoreHoriz = false; slope = xDelta / yDelta; w1=y1; z1=x1; w2=y2, z2=x2; //w=y, z=x } if(w1 > w2) //если за w { t=w1; w1=w2; w2=t; // поменять (w1,z1) t=z1; z1=z2; z2=t; // на (w2,z2) } for(w=w1; w<=w2; w++) { z = static_cast(z1 + slope * (w-w1)); if( !(w==80 && z==25)) //запретить прокрутку на 80,25 { if(isMoreHoriz) set_cursor_pos(w, z); else set_cursor_pos(z, w); putch(fill_char); } } } //--------------------------------------------------------- void draw_pyramid(int x1, int y1, int height) { int x, y; for(y=y1; y