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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
Program reelmovieclip;//movieclip en coordonnées mathématiques
uses Flash8Ext,Math;
{$BACKGROUND $ffffff}
const
{$FRAME_WIDTH 1000}
{$FRAME_HEIGHT 500}
{$FRAME_RATE 30}
frame_width=1000;
frame_height=500;
type
TRpoint = external class(flash.geom.Point)
constructor Create(x, y: double);
property x: double;
property y: double;
end;
TReelMovieclip=class(MovieClip)
constructor Create(Aowner:MovieClip;ANme:string;ADepth,x1,x2,y1,y2:double;width,height:Integer);
xmin,xmax:double;
ymin,ymax:double;
taillex,tailley:double;
Gx,Gy:double;
xo,yo:double;
w,h:integer;
tabmax:integer;// valeur max de l'indice de courbe
courbe:array of TRpoint;
function transform(x,y:double):TRPoint;
Procedure RMoveTo(x,y:double);
Procedure RLineTo(x,y:double);
Procedure RLine(x1,y1,x2,y2:double);
Procedure RPolyline;// pas de possibilité de mettre un array of TRpoint en paramètre
Procedure OnEnterFrame;
Procedure Paint;
end;
Type TTraceur=class(MovieClip)
graph:TReelMovieclip;
constructor create;
end;
var
traceur:TTraceur;
constructor TReelMovieclip.create(Aowner:MovieClip;ANme:string;ADepth,x1,x2,y1,y2:double;width,height:Integer);
begin
inherited Create(Aowner,'reelmovie',1);
xmin:=x1;
ymin:=y1;
xmax:=x2;
ymax:=y2;
w:=width;
h:=height;
taillex:=xmax-xmin;
tailley:=ymax-ymin;
Gx:=w/taillex;
Gy:=h/tailley;
xo:=-xmin*Gx;
yo:=ymax*Gy;
tabmax:=200;//pour arriver au bout de la graduation 10 (de -10 à 10 =>10 pts par grad)
_x:=0;
_y:=0;
paint;//Pour le dessin
end;
Function TReelMovieclip.transform(x,y:double):TRpoint;
begin
result:=TRpoint.create(xo+x*Gx,yo-y*Gy);
end;
Procedure TReelMovieclip.RMoveTo(x,y:double);
begin
moveto(xo+x*Gx,yo-y*Gy);
end;
Procedure TReelMovieclip.RLineTo(x,y:double);
begin
lineto(xo+x*Gx,yo-y*Gy);
end;
Procedure TReelMovieclip.RLine(x1,y1,x2,y2:double);
begin
RMoveto(x1,y1);
RLineto(x2,y2);
end;
Procedure TReelMovieclip.RPolyline;
var i:integer;
begin
RMoveto(courbe[0].x,courbe[0].y);
for i:=1 to tabmax do Rlineto(courbe[i].x,courbe[i].y);
end;
Procedure TReelMovieclip.paint; //on dessine ici
var i:integer;
begin
for i:=0 to tabmax do courbe[i]:=TRPoint.create(i/10-10,4*sin(2*3.14*(i/10-10)/10)); //avec coordonnées mathématiques, c'est l'intérêt
//quadrillage
lineStyle(2, $000000);
for i:=-20 to 20 do Rline(i,ymin,i,ymax);
for i:=-10 to 10 do Rline(xmin,i,xmax,i);
lineStyle(1,$1BD2FF);
for i:=-100 to 100 do Rline(xmin,i/10,xmax,i/10);
for i:=-100 to 100 do Rline(i/10,ymin,i/10,ymax);
//repère
lineStyle(2, $000000);
Rline(xmin,0,xmax,0);
Rline(0,ymin,0,ymax);
//courbe
lineStyle(3, $ff0000);
Rpolyline;
end;
Procedure TReelMovieclip.onEnterFrame;
var i:integer;
begin
end;
Constructor TTraceur.create;
begin
inherited create(nil,'traceur',1);
graph:=TReelMovieclip.create(self,'reelmovie',1,-10,10,-5,5,FRAME_WIDTH,FRAME_HEIGHT); //à définir pour le repère en x de -10 à 10 et -5;5 en y
//+dimensions du repère: _width et _height
end;
begin
Traceur:=TTraceur.Create();
end. |
Partager