7
-
7.1
- .
7.2
Graph , , .
7.3 Graph
7.3.1 Graph , IBM- . Graph , .
(BGI- ). , (CHR- ). .
( ):
20
CGA | Hercules |
MCGA | AT&T 400 |
EGA | 3270 PC |
VGA | IBM-8514 |
:
21
CGA.BGI | CGA, MCGA |
EGAVGA.BGI | EGA, VGA |
HERC.BGI | Hercules |
ATT.BGI | AT&T 6300 (400 ) |
PC3270.BGI | IBM 3270 PC |
IBM8514..BGI | IBM 8514 |
InitGraph , , , . CloseGraph .
Graph () . : 0,0; X , Y . , 640480 ( VGA) 639, 479, 319, 239.
. , LineTo, LineRel, OutText . , , , .
Graph 4 . 88 . (), () . . .
|
|
Graph , , , .. ( ).
SetViewPort . , .
, , .
7.3.2
22-
SolidLn | ||
DottedLn | ||
CenterLn | ||
DashedLn | ||
UserBitLn | ||
NormWidth | ||
ThickWidth |
23-
DefaultFont | 88 | |
TriplexFont | ||
SmallFont | ||
SansSerifFont | ||
GothicFont | ||
- | ||
- | Courier | |
- | Times Italic | |
- | Times Roman | |
- | Courier | |
- | ||
HorizDir | ||
VertDir | ||
UserCharSize | , | |
LeftText | ||
CenterText | ||
RightText | ||
BottomText | ||
CenterText | ||
TopText |
7.3.3
24-
Procedure Circle(X,Y:Intrger,R:Word) | R, X,Y |
Procedure ClearDevice | |
Procedure ClearViewPort | |
Procedure CloseGraph | |
Procedure GraphDefaults | |
Procedure InitGraph(var Driver, Mode: Integer; Path:String) | . Driver Mode . Driver=0 . Path . |
Procedure Line(X1,Y1,X2,Y2:Integer) | X1,Y1 X2,Y2. |
Procedure LineTo(X,Y:Integer) | X,Y |
Procedure MoveTo(X,Y:Integer) | X,Y. |
Procedure OutText(TextString: String) | . |
Procedure OutTextXY(X,Y:Integer; TextString: String) | |
Procedure PutPixel(X,Y:Integer; Color:Word) | Color X,Y. |
Procedure Rectangle(X1,Y1,X2,Y2: Integer) | , . |
Procedure SetBkColor(Color:Word) | |
Procedure SetColor(Color:Word) | , . |
Procedure SetGraphMode(Mode: Integer) | . |
Procedure SetLineStyle(LineStyle, Pattern, Thickness: Word) | . |
Procedure SetTextJustify(Horiz,Vert: Word) | , OutText OutTextXY. |
Procedure SetTextStyle(Font,Direction, CharSize: Word) | , |
Procedure SetViewPort(X1,Y1,X2,Y2: Integer; ClipOn: Boolean) | . |
|
|
7.3.4 Graph :
Unit Zad1; { }
Interface
Uses Crt, Graph;
Procedure z1;
Implementation
Procedure z1; { }
var d,ibm,i,x1,y1,x2,y2,n:integer;
s1,s2,s3,s4,s5:string;
begin
ClrScr;
d:=detect;
ibm:=ibm8514hi;
s1:=' Demonstration program';
s2:=' Interface Menu';
s3:=' By Gureev Alexey';
s4:='Borland Pascal';
s5:=' If you like it, then press any key...';
InitGraph(d,ibm,'d:\pas\pas\bgi'); { }
if graphresult<>grOK then WriteLn('error...') { }
else
begin
SetGraphMode(IBM); { }
ClearDevice; { }
SetColor(7); { }
SetLineStyle(0,0,3); { }
Rectangle(0,0,640,480); { }
SetLineStyle(1,0,1); { }
Rectangle(3,3,637,477);
SetTextStyle(7,0,3); { , }
SetColor(27);
MoveTo(30,10); { }
OutText(s1); { }
MoveTo(50,70);
SetColor(54);
SetTextStyle(4,0,6);
Delay(400); { 400 }
OutText(s2);
MoveTo(340,350);
SetTextStyle(5,0,4);
SetColor(73);
For i:=1 to Length(s3) do begin{ }
OutText(s3[i]);
delay(250);
end;
MoveTo(100,150);
SetColor(26);
SetTextStyle(8,1,4);
OutText(s4);
Delay(300);
SetTextStyle(2,0,5);
Repeat{ }
MoveTo(250,450);
For i:=1 to Length(s5) do begin
SetColor(15);
OutText(s5[i]);
delay(15);
end;
Delay(400);
MoveTo(250,450);
For i:=1 to Length(s5) do begin
SetColor(12);
OutText(s5[i]);
delay(15);
end;
Delay(400);
Until KeyPressed;
end;
readkey;
SetColor(7);
x1:=0;y1:=0;
x2:=640;y2:=480;
n:=2;
Repeat{ }
Rectangle(x1,y1,x2,y2);
x1:=x1+Round(n/2);y1:=y1+n;
x2:=x2-Round(n/2);y2:=y2-n;
until x1>240;
CloseGraph; { }
ReadKey;
end;
end.
Unit Zad2;
Interface
Uses Crt, Graph;
Procedure z2;
Implementation
var d,ibm,k,col,x1,y1,x2,y2,x3,y3,x4,y4,r,n,p1,p2,p3:integer;
Procedure z2;
begin
ClrScr;
Randomize; { }
d:=detect;
ibm:=ibm8514hi;
InitGraph(d,ibm,'d:\pas\pas\bgi'); { }
if graphresult<>grOK then WriteLn('error...') { }
else
begin
SetGraphMode(IBM); { }
|
|
ClearDevice; { }
k:=0;
Repeat
col:=Random(256);
SetLineStyle(0,0,3); { }
x1:=Random(640);x2:=Random(640);x3:=Random(640);
y1:=Random(480);y2:=Random(480);y3:=Random(480);
x4:=Random(640);y4:=Random(480);
r:=Random(100);
SetColor(col);
Line(x1,y1,x2,y2); { }
Line(x2,y2,x3,y3);
Line(x3,y3,x1,y1);
Delay(30); { 30 }
SetColor(col+1);
Rectangle(x1,y2,x4,y3); { }
Delay(30);
SetColor(col-1);
Circle(x4,y4,r); { }
Delay(30);
SetColor(0);
{ }
Line(x1,y1,x2,y2);
Line(x2,y2,x3,y3);
Line(x3,y3,x1,y1);
Rectangle(x1,y2,x4,y3);
Circle(x4,y4,r);
If k=10 then begin { }
MoveTo(150,200);
SetColor(col+2);
SetTextStyle(3,0,4);
OutText('Information Systems');
Sound(50);
Delay(100);
NoSound;
k:=0;end;
Delay(30);
k:=k+1;
until KeyPressed;
end;
readkey;
SetColor(7);
x1:=0;y1:=0;
x2:=640;y2:=480;
n:=2;
Repeat{ }
Rectangle(x1,y1,x2,y2);
x1:=x1+Round(n/2);y1:=y1+n;
x2:=x2-Round(n/2);y2:=y2-n;
until x1>240;
CloseGraph; { }
end;
end.
7.4
:
- ( ),
- ,
- ,
- : " Y =...",
- (, , Y, Y . 1).
7.5
7.5.1 , , (. 7.6).
7.5.2 -, (. 7.7).
7.5.3 -.
7.5.4 (. 7.10).
7.6
:
- , ( ) .1,
- ; , , ; () () ..
Y ( OY - ).
1 -
(.1 .2):
- , Ya - XOY ( , Ya - ); Ya ;
- (X, ) - ; < ;
- Y - ;
- ,, Y, - ( );
- ,min, ,max, Y,min, Y,m - ; GetMaxX GetMaxY:
:= GetMaxX;
YeMax:= GetMaxY;
- ,, ,, Y,, Y, - ;
,min <= , < , <= ,m,
(1)
Y,min <= Y, < Y, <= Y,m.
|
|
; , . ,, ,, Y,, Y, :
) ,
) (1),
) (1) .
2
7.7
:
1. ( = , = ) N.
h=(B-A)/N.
2. Y,min Y,m. Ymin, Ymax (, ). Ymin, Ymax , .
3. OY :
= (, - ,) / ( - ); (2)
My =(Y, - Y,) / (Y,max - Y,min) (3)
4. . (, ), (Y,min, Y,ma), : (0, Y,min), (, Y,m) (, 0), (, 0). , (. 3). Ds OY, .
5. = ; FX = f(x).
6. A=(X,FX) :
=-; (4)
Y=Y-Y,min; (5)
, =X'a * mx + ,; (6)
Y,=Y,-Y'*. (7)
, ,, Y, ; , Y, .
7. (,, Y,).
8. = + h.
9. > , .
10. FX = f(). (X, FX) (4,5,6,7).
11. Graph -. .8 - 11, .9.
12. :
" Y =...".
- , , , .
3
7.8
7.8.1 -.
50 Graph.tpu. graph.tpu, , . Graph - : CGA, MCGA, EGA, VGA, SVGA, Hercules, AT&T, 3270 PC. .BGI (Borland Graphic Interface). .CHR.
Turbo Pascal, Graph, :
program prog graph;
uses Graph, Crt,......;
var grDriv, grMod: integer,
{ }
function F(var x: real): real
begin
end;
begin
write('B XN, XK:'); { }
readln(Xn, Xk); { }
write(' : ');
readln(N);
{ Yn Yk h }
{ }
grDriv:= Detect;
InitGraph(grDriv, grMod, 'D:\TP\BGI');
{ )
{-- )
if GraphResult <> GrOK then begin
writeln('!!!');
{... .....}
delay(lOOO);
exit
end;
{ }
XNE:=...; { ;}
YNE:=...; ( ) Xke:=...; { }
Yke:=...;
:=...; { )
:=..;
{ , .)
:=n; { }
x:=x+h;
while x < xk do
begin
y:=F(x);
{ }
{(x,)}
end;
|
|
{ }
{ }
repeat
until KeyPressed;
{ )
CloseGraph
end.
7.8.2
, Graph, :
- ;
- , , ;
- ;
- "";
- , , ;
- ;
- .
:
InitGraph (var gt,gm:integer;tpf:string) - .
, gm.
gt , Graph.tpu :
const detect = 0;
CGA=1;
MCGA=2;
EGA=3;
CGA=9;
PC3270=10;
gt 0, Detect (. 7.8.1), gm. ( .BGI) tpf. ' ', InitGraph .
CloseGraph - . , InitGraph.
GraphResult - . . 0, .