.


:




:

































 

 

 

 





12

Բ ̲.

Բ

( 8)

 

 

: .
++, . .

, : . (, , ) (, , , ), . , 3840, 2400 (); 320×200.

Microsoft Visual C++ MFC 䳿 EGAVGA.BGI, , 2 VGAHI.

640×480 , 16

() , () . (0,0).

 
 


 

 

.

 

 

// ( )

conio.h :


 

 

 
Black   DarkGray   -
Blue   LightBlue   -
Green   LightGreen   -
Cyan   LightCyan   -
Red   LightRed  
Magenta   LightMagenta   -
Brown   Yellow  
LightGray   - White  
      Blink  
             

- , BLACK LIGHTGRAY.

textcolor();

, textbackground();

lowvideo() ( ), highvideo() ( ) normvideo() ( , ). :

textbackground(BROWN); // }

textcolor(WHITE); // }

textcolor(YELLOW+BLINK); // }

conio.h , textattr, . (, , , ).

() textattr, :

- , (1), (0);

- ( 0..3) :

o 0- ;

o 1- ;

o 2- ;

o 3- ;

- ( 4..6) :

o 4- ;

o 5- ;

o 6- ;

- (7-) .

 


 

12-1: ,

:

#include<graphics.h>

#include<stdlib.h>

#include<stdio.h>

#include<conio.h>

#include<math.h>

#include<dos.h>

int main ()

{

clrscr();

int gdriver=DETECT,gmode, errorcode;

int size,i;

float x,y,t;

initgraph(&gdriver, &gmode, "");

errorcode=graphresult();

if (errorcode!=grOk)

{

printf("Graphics error: %s \n",grapherrormsg(errorcode));

printf("Pres any key to halt:");

getch();

exit(1);

}

/* line(0,0,getmaxx(),getmaxy());

moveto(300,300);

ellipse(300,300,35,150,50,25);

ellipse(340,310,90,180,50,25);

ellipse(308,300,150,200,20,25);

ellipse(275,335,73,113,50,50);

getch();

linerel(25,-25);

bar3d(320,240,360,280,10,50);

size=imagesize(320,220,380,280);

int *p=new[size];

getimage(320,220,380,280,p);

putimage(520,240,p,1);

for(i=1;i,500;i+=5)

{ putimage(x,y,p,1);

t=i/180.0*M_PI;

x=100*sin(t)+320;

y=240-100*cos(t);

putimage(x,y,p,1);

delay(50);

}

getch();

 

closegraph();

delete p;*/

moveto(300,250);

linerel(30,0);

linerel(-10,10);

linerel(30,30);

linerel(-10,10);

linerel(-30,-30);

linerel(-10,10);

linerel(0,-30);

setfillstyle(2,8);

floodfill(305,255,WHITE);

getch();

return 0;

}

 
 


12-2:

:

#include<iostream.h>

#include<conio.h>

#include<stdio.h>

#include<stdlib.h>

#include<graphics.h>

#include<math.h>

#include<dos.h>

 

void main()

{

float x,y;

int xe,ye;

int gd=DETECT,gm,er;

int *p;

initgraph(&gd,&gm,"");

moveto(100,100);

linerel(30,0);

linerel(-10,10);

linerel(30,30);

linerel(-10,10);

linerel(-30,-30);

linerel(-10,10);

linerel(0,-30);

setfillstyle(2,9);

floodfill(105,105,WHITE);

int size=imagesize(100,100,150,150);

p=new[size];

getimage(100,100,150,150,p);

getch();

// putimage(250,200,p,0);

line(10,240,630,240);

line(320,10,320,470);

outtextxy(330, 0, "Y");

outtextxy(630, 250, "X");

outtextxy(310, 250, "0");

float t=0,

dt=0.01;

double r=100.0;

moveto(320,240);

sound(300);

while (t<=2*M_PI)

{

putimage(xe,ye,p,1);

x=r*pow(cos(t),2);

y=r*pow(sin(t),2);

xe=int(x+320);

ye=int(240-y);

putimage(xe,ye,p,1);

lineto(xe,ye);

t+=dt;

delay(10);

}

nosound;

getch();

closegraph();

}

 

 
 

 


12-3: , ,

:

#include<conio.h>

#include<math.h>

#include<dos.h>

#include<stdio.h>

#define ARROW_size 40

void draw_arrow (int x, int y);

int main (void)

{

int gdriver=DETECT, gmode, errorcode;

void*arrow;

int Y_dek,x_dek,x,y,maxx;

unsigned int size;

initgraph (&gdriver,&gmode,);

errorcode=graphresult();

if (errorcode!=gr0k)

{

printf(Graphics error: %s\n,grapherrormsg(errorcode));

printf( Press any key to halt:);

getch();

exit(1);

}

maxx=getmaxx();

x=0;

y=getmaxy()/5;

draw_arrow(x,y);

size=imagesize(x,y-ARROW_SIZE,x+(4*ARROW_SIZE), y+ARROW_SIZE);

arrow=malloc (size);

getimage (x,y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE, arrow);

putimage(x,y-ARROW_SIZE, arrow, XOR_put);

float t=0.0, dt=0.01;

float r=100;

x_ek, y_ek;

moveto(r*pow(cos(t),3)+320,240-r*sin(t)*cos(t)*cos(t);

while(t<=9.0)

{

putimage(x_ek-100,y_ek-45, arrow, XOR_PUT);

x_dek=r*pow(cos(t),3);

y_dek=r*sin(t)*cos(t)*cos(t);

x_ek=(x_dek+320);

y_ek=(240-y_dek);

sound(6661299*(x_ek+(-y_ek)));

lineto (x_ek; y_ek);

putimage (x_ek-100; y_ek-45; arrow, XOR_PUT);

delay (1);

t=t+dt;

}

nosound ();

getch ();

free(arrow);

closegraph ();

return 0;

}

void draw_arrow (int x, int y)

{

line(20,240,620,240);

line (329,20,320,460);

moveto (50,50);

linerel(40,-40);





:


: 2016-09-06; !; : 341 |


:

:

, .
==> ...

1862 - | 1685 -


© 2015-2024 lektsii.org - -

: 0.031 .