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
| unit UTraceur;
interface
uses graphics,Types;
type
TGrapheur=Class(TBitmap)
private
xo,yo:integer;
public
constructor create(largeur,hauteur:integer);
procedure tracerepere(xopourcentage,yopourcentage,epaisseur:integer;axex,axey:string;couleur:Tcolor);
Procedure tracecourbe(x,y:extended;maxx,maxy:integer);
end;
implementation
constructor TGrapheur.create(largeur,hauteur:integer);
begin
inherited create;
height:=hauteur;
width:=largeur;
end;
procedure TGrapheur.tracerepere(xopourcentage,yopourcentage,epaisseur:integer;axex,axey:String;couleur:Tcolor);
begin
xo:=round(xopourcentage/100*Width);
yo:=round(yopourcentage/100*height);
with canvas do begin
pen.width:=epaisseur;
pen.color:=couleur;
moveto(round(0.05*Width),yo);
lineto(round(0.95*Width),yo);
moveto(round(0.95*Width),yo);
lineto(round(0.95*Width-width div 30),Round(yo-width div 80));
moveto(round(0.95*Width),yo);
lineto(round(0.95*Width-width div 30),Round(yo+width div 80));
moveto(xo,width div 30);
lineto(xo,height-width div 30);
moveto(xo,width div 30);
lineto(xo-width div 80,2*width div 30);
moveto(xo,width div 30);
lineto(xo+width div 80,2*width div 30);
Font.Size:=width div 40;
Textout(width-width div 10,yo+width div 80,axex);
Textout(xo+width div 40,width div 30,axey);
end;
end;
Procedure TGrapheur.tracecourbe(x,y:extended;maxx,maxy:integer);
var GX,GY:integer;
begin
GX:=Round((width/Maxx)*x+xo);
GY:=Round((-width/maxx)*y+yo);
with canvas do begin
moveto(-width div 100+GX,GY);
lineto(width div 100+GX,GY);
moveto(GX,GY-width div 100);
lineto(GX,GY+width div 100);
end;
end;
end. |
Partager