1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
Type TCourbe = record
Couleur : TColor;
Width : Integer;
Visible : Boolean;
ListPoint : Array of TPoint
End;
type
TForm1 = class(TForm)
private
{ Déclarations privées }
public
{ Déclarations publiques }
permition2,permition3 : Boolean;
Tableau : Array Of TCourbe;
Procedure AffichageCourbe(Canvas : TCanvas);
Procedure AddCourbe(tailpt:integer;coulpt:Tcolor;tmax : integer);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
Procedure TForm1.AddCourbe(tailpt:integer;coulpt:Tcolor;tmax,c,r,h,waxe : integer; Umax : Extended; Origine : Tpoint);
Var i,j : Integer;
u: extended;
begin
setlength(Tableau,High(Tableau)+2);
j := high(Tableau);
setlength(Tableau[j].ListPoint,10*tmax); //On enregistre le nombre de point pour cette courbe
Tableau[J].Couleur := coulpt; //On enregistre la couleur de la courbe
Tableau[J].Width := tailpt; //.... le taille des point de la courbe
Tableau[J].Visible := True; //Par defaut on l'affichera lors de l'appel a la procedure d'affichage
u:=0;
for i := 0 to high(Tableau[J].ListPoint) do
begin
if permition2 then u:=Umax*(1-exp(-i/(1e4*R*C)));
if permition3 then u:=Umax*exp(-i/(1e4*R*C));
Tableau[j].ListPoint[I]:=point(round(origine.x+(waxe*(i+1)/(10*tmax))),round(origine.y-4*h*u/50));
end;
permition2:=false;
permition3:=false;
AffichageCourbe(Form1.Canvas);
end;
Procedure TForm1.AffichageCourbe(Canvas : TCanvas);
Var i,j : Integer;
begin
For j := 0 to High(Tableau) Do
Begin
If Tableau[j].Visible Then //On verifie que la courbe doit etre affichée
begin
with canvas do
begin
pen.Width:=Tableau[J].Width;
pen.Color:=Tableau[J].Couleur;
end;
//On trace la courbe point par point
For i := 0 To High(Tableau[J].ListPoint) Do canvas.polyline(Tableau[J].ListPoint[I]);
end;
end;
end;
end. |
Partager