unit MainUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TKasat = class
StartX, StartY:Integer;
A1,B1,C1,D,x11,x22:extended;
xn1,xn2,yn1,yn2:variant;
procedure DKasat;
end;
TEllipse = class
StartX, StartY:Integer;
procedure DEllipse;
procedure Erase;
end;
TAnimation = Class
Ellipse : TEllipse;
Kasat : TKasat;
End;
TForm1 = class(TForm)
PB1: TPaintBox;
procedure FormClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure FormDbClick(Sender: TObject);
private
{ Private declarations }
OldPenMode:TPenMode;
StartX, StartY, OldX, OldY:Integer;
dragging:Boolean;
public
{ Public declarations }
end;
const
x1=0;
y1=0;
var
Form1: TForm1;
Picture : TAnimation;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
dragging:=false;
end;
procedure TEllipse.DEllipse;
begin
with Form1.PB1.Canvas do begin
Pen.Color:=clWhite;
Ellipse(StartX-140, StartY-140,StartX+140, StartY+140 );
end;
end;
Procedure TKasat.DKasat;
begin
A1:=sqr(x1)-2*x1*startx+sqr(startx)+sqr(y1)-2*y1*starty+sqr(starty);
B1:=2*sqr(140)*startx-2*sqr(140)*x1-2*sqr(x1)*startx+4*x1*sqr(startx)-2*sqr(startx)*startx-2*sqr(y1)*startx+4*y1*starty*startx-2*startx*sqr(starty);
C1:=sqr(140*140)+2*sqr(140)*x1*startx-2*sqr(140)*sqr(startx)+sqr(x1)*sqr(startx)-2*sqr(startx)*startx*x1+sqr(startx*startx)-sqr(140)*sqr(y1)+sqr(y1)*sqr(startx)+2*y1*starty*sqr(140)-2*y1*starty*sqr(startx)-sqr(140)*sqr(starty)+sqr(startx*starty);
D:=sqr(B1)-4*A1*C1;
x11:=sqrt(abs(D))-B1;
x22:=-B1-sqrt(abs(D));
xn1:=x11/(2*A1);
xn2:=x22/(2*A1);
yn1:=starty+(sqr(140)-(xn1-startx)*(x1-startx))/(y1-starty);
yn2:=starty+(sqr(140)-(xn2-startx)*(x1-startx))/(y1-starty);
with Form1.PB1.Canvas do begin
Polyline([Point(x1,y1),Point(xn1,yn1)]);
Polyline([Point(xn1,yn1),Point(xn2,yn2)]);
Polyline([Point(x1,y1),Point(xn2,yn2)]);
end;
end;
procedure TEllipse.Erase;
begin
with Form1.PB1.Canvas do begin
Brush.Color:=clBlack;
Rectangle(0, 0,800, 800 );
Pen.Color:=clBlack;
Rectangle(0, 0,800, 800 );
end;
end;
procedure TForm1.FormClick(Sender: TObject);
begin
dragging:=true;
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var a,b,t: integer;
Xn1,Xn2,Yn1,Yn2:variant;
A1,B1,C1,D,x11,x22,y11,y22,E:extended;
begin
StartX:=X;
StartY:=Y;
if dragging=false then exit;
with Picture do
begin
Ellipse.Erase;
Ellipse.DEllipse;
Kasat.DKasat;
end;
end;
procedure TForm1.FormDbClick(Sender: TObject);
begin
dragging:=false;
end;
end.