0
Вариант 17 TP13.PAS Code Program TP13; Uses CRT, GRAPH, TP13M; var p: TPoint; c: TEllipse; s: TPoly; u:real; GraphDriver, GraphMode: integer; Begin GraphMode := 0; GraphDriver := 0; InitGraph(GraphDriver, GraphMode, '');
p.init(200, 130); c.init(200, 200, 100,50); s.init(200, 200,'TP13.txt');
p.show; c.show; s.show;
Randomize;
repeat delay(5000); u:=u+(random(10)-5)/70; s.move(sin(u),cos(u)); p.move(sin(u),cos(u)); c.move(sin(u),cos(u)); until keypressed;
CloseGraph; end. TP13M.PAS Code unit TP13M; Interface Uses Crt, Graph; Type TLocation = object x, y: real; constructor init(a, b: real); destructor done; end; TPoint = object(Tlocation) Procedure Show; virtual; Procedure Hide; Procedure Move(a, b: real); end; TEllipse = object(Tpoint) rx,ry:integer; constructor init(a, b:real; c, d: integer); Procedure Show; virtual; end; TPoly = object(Tpoint) m:array[1..100] of real; p:array[1..100] of integer; n:integer; constructor init(a, b:real; name: string); Procedure Move(a, b: real); Procedure Show; virtual; end; Implementation {======} constructor Tlocation.init(a, b: real); Begin x := a; y := b; end; destructor Tlocation.done; Begin end; {======} Procedure Tpoint.Show; Begin PutPixel(Trunc(x), Trunc(y), GetColor); end; Procedure Tpoint.Hide; var p: integer; Begin p := GetColor; SetColor(GetBkColor); Show; SetColor(p); end; Procedure Tpoint.Move(a, b: real); Begin Hide; x := x + a; y := y + b; Show; end; {======} constructor TEllipse.init(a, b:real; c, d: integer); Begin TLocation.init(a, b); rx := c; ry := d; end; Procedure TEllipse.Show; Begin Ellipse(Trunc(x), Trunc(y),0,360, rx,ry); end; {======} constructor TPoly.init(a, b:real; name:string); var F:text; Begin TLocation.init(a, b); Assign(F, name); Reset(F); n:=0; While Not EOF(F) Do Begin n:=n+1; Read(F, m[n]); End; n:= n Div 2 ; close(F); Move(0,0); end; Procedure TPoly.Move(a, b: real); var i:integer; Begin Hide; x := x + a; y := y + b; for i:=1 to n do begin p[i*2-1]:=Trunc(m[i*2-1]+x); p[i*2]:=Trunc(m[i*2]+y); end; Show; end; Procedure TPoly.Show; Begin DrawPoly(n, p); end; end. TP13.txt Code -40 0 40 0 -15 40 0 -30 15 40 -40 0
|
|