IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Flash Pascal Discussion :

Movieclip en coordonnées mathématiques [Flash Pascal]


Sujet :

Flash Pascal

  1. #1
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut Movieclip en coordonnées mathématiques
    Je me suis essayé à un movieclip en coordonnées mathématiques...
    Pas de soucis

    ci-joint : (un debut de méthodes de dessin)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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.
    je précise que j'ai rajouté dans Flash8ext :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
     TRpoint=external class(Object)
       property x:double;
       property y:double;
      end;
    ma question est que en gardant un movieclip statique, c.à.d sans faire évoluer _x,_y ou _rotation, est-t-il possible d'incrémenter dans le onframenter
    une variable, ici tabmax pour faire tracer la courrbe au fur et à mesure de Frame_rate ?

    J'ai fait un essai qui n'était pas concluant...c'est pour ça que j'ai un tableau de TRPoint....


    a+

  2. #2
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut ajout de deux méthodes
    rectangle+cercle :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    Procedure TReelMovieclip.Rrectangle(x1,y1,x2,y2:double);
    begin
     RMoveto(x1,y1);
     RLineTo(x2,y1);
     RLineto(x2,y2);
     RLineto(x1,y2);
     RLineto(x1,y1);
    end;
     
    Procedure TReelMovieclip.Rcircle(Cx,Cy,Radius:double); //si orthonormé
    var a,b,R:double;
    begin
      R:=radius*Gx;
      Cx:=xo+Cx*Gx;
      Cy:=yo-Cy*Gy;
      a:= R * 0.414213562;
      b:= R * 0.707106781;
      moveTo(Cx+R,Cy);
      curveTo(Cx+ R, Cy+-a, Cx+b,Cy -b);
      curveTo(Cx+ a,Cy-R,Cx,Cy -r);
      curveTo(Cx-a,Cy -R,Cx-b,Cy -b);
      curveTo(Cx-R, Cy-a,Cx-R,Cy);
      curveTo(Cx-R,Cy+a,Cx-b,Cy+b);
      curveTo(Cx-a,Cy +R,Cx,Cy+r);
      curveTo(Cx+a,Cy +R,Cx+b,Cy+b);
      curveTo(Cx+R,Cy+a,Cx+R,Cy);
    end;
    a+

  3. #3
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 445
    Points
    28 445
    Par défaut
    voici ce que je te propose:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    program Graph;
     
    uses
      Flash8;
     
    {$BACKGROUND $ffffff}
    {$FRAME_WIDTH  1000}
    {$FRAME_HEIGHT 500}
    {$FRAME_RATE     30}
     
    const  
      frame_width=1000;
      frame_height=500;
      xmin = -10;
      xmax = +10;
      ymin = - 5;
      ymax = + 5;     
      xsize= xmax - xmin;
      ysize= ymax - ymin;
      Gx   = frame_width / xsize;
      Gy   = frame_height/ ysize;
      xo   =-xmin * Gx;
      yo   = ymax * Gy;
     
    type
      RealMovie = class(MovieClip)
        procedure RLine(x1, y1, x2, y2: Double);
      end;
     
      TGraphe = class(RealMovie)
        Courbes: array[0..1] of RealMovie;
        Courbe : Integer;
        Temps  : Integer;
        Origine: Double;
        x1, y1 : Double;
        x2, y2 : Double;
        constructor Create;
        procedure GetPoint;
        procedure onEnterFrame;
      end;
     
    procedure RealMovie.RLine(x1, y1, x2, y2: Double);
    begin
      moveTo(xo+x1*Gx,yo-y1*Gy);
      lineTo(xo+x2*Gx,yo-y2*Gy);
    end;
     
    constructor TGraphe.Create;
    var
      i : Integer;
    begin
      inherited Create(nil, 'graphe', 0);
    //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);
      // les courbes
      Courbes[0] := RealMovie.Create(nil, 'courbe1', 1);
      Courbes[1] := RealMovie.Create(nil, 'courbe2', 2);
      // style de trait
      Courbes[0].lineStyle(3, $ff0000);
      // placée à droite de l'écran
      Courbes[0]._x := frame_width;
      Courbe := 0;
      Temps  := 0;
      Origine := 0;
      x2 := 0;
      y2 := 0;
      // calculer le premier point
      GetPoint;
    end;
     
    procedure TGraphe.GetPoint;
    begin
      x1 := x2;
      y1 := y2;
      x2 := Temps/10 - 10;
      y2 := 4 * sin(2 * 3.14 * (Temps/10 - 10) / 10);
    end;
     
    procedure TGraphe.onEnterFrame;
    begin  
    // point suivant
      Inc(Temps);
      GetPoint;
    // tracer sur la courbe active
      Courbes[Courbe].RLine(x1 - Origine, y1, x2 - Origine, y2);
    // faire défiler les deux courbes
      Courbes[0]._x := Courbes[0]._x - frame_width/200;
      Courbes[1]._x := Courbes[1]._x - frame_width/200;
    // si la courbe active arrive à gauche
      if (Courbes[Courbe]._x <= 0) then
      begin
      // changer de courbe active (celle-ci est pleine)
        Courbe := 1 - Courbe;
      // effacer l'ancienne qui n'est plus visible à l'écran
        Courbes[Courbe].clear;
      // redéfinir le style de trait perdu par le Clear
        Courbes[Courbe].lineStyle(3, $ff0000);
      // placer la courbe à la suite de la précédente
        Courbes[Courbe]._x := Courbes[1 - Courbe]._x + frame_width;
      // déclarer l'origine en conséquence
        Inc(Origine, 20);
      end;
    end;
     
    begin
      TGraphe.Create;
    end.
    explications:

    TGraphe dessine une bonne fois pour toute la grille qui ne bouge plus (enfin je crois)

    ensuite j'ai deux TCourbe qui servent de panneau défilant, au départ on dessine sur Courbes[0] qui commence à droite de l'écran et défile vers la gauche au fur et à mesure du tracé.
    Quand ce graphe arrive sur le bord gauche, on vient placer Courbes[1] à sa suite pour poursuivre le dessin.
    Courbes[0] continue à sortir de l'écran vers la gauche en étant remplacé au fur et à mesure par Courbes[1]
    Quand Courbes[1] arrive sur le bord gauche, on reprend sur Courbe[0] suivant le même principe.

    EDIT: pour que le quadrillage suive il suffit de le dessiner après le "Clear" sur la Courbe
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  4. #4
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut
    Déjà, je te remercie de te casser la tête avec ça .....
    T'es pas obligé...

    Ta solution en gros est de tracer la courbe et de la déplacer avec _x...
    Mon but étant de la faire tracer points par points au fur et à mesure du frame_
    rate.

    C'est pour ça que j'avais besoin d'un tableau de points avec un polyline qui évoluerait en taille d'un point à chaque passage dans le onenterframe...
    Avec polyline, la courbe s'enrichirait d'un point à chaque fois.

    le problème, c'est qu'on dessine dans un movieclip à la création une fois pour toute et on déplace celui-ci en _x, _y ,_rotation...
    l'animation consiste en un déplacement de movieclips.

    j'ai essayé dans le onenterframe d'augmenter d'un point courbe à chaque fois et de la faire tracer avec paint (RPolyline) ça ne marche pas.

    Il serait nécessaire de recréer le movieclip à chaque entrée dans onenterframe...(ce qui est impossible)

    merci encore de ton aide.


    ps: mon but étant le tracé de la cycloïde avec la roue pour un tracé qui se ferait au fur et à mesure.

  5. #5
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 072
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 072
    Points : 15 462
    Points
    15 462
    Billets dans le blog
    9
    Par défaut
    Citation Envoyé par Paul TOTH Voir le message
    voici ce que je te propose:
    Très joli exemple ! Je l'ajoute à ma collection.
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  6. #6
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 445
    Points
    28 445
    Par défaut
    Citation Envoyé par Archimède Voir le message
    Déjà, je te remercie de te casser la tête avec ça .....
    T'es pas obligé...
    je sais bien, mais j'ai un utilisateur actif sous la main et ça fait plaisir

    Citation Envoyé par Archimède Voir le message
    Ta solution en gros est de tracer la courbe et de la déplacer avec _x...
    Mon but étant de la faire tracer points par points au fur et à mesure du frame_
    rate.

    C'est pour ça que j'avais besoin d'un tableau de points avec un polyline qui évoluerait en taille d'un point à chaque passage dans le onenterframe...
    Avec polyline, la courbe s'enrichirait d'un point à chaque fois.

    le problème, c'est qu'on dessine dans un movieclip à la création une fois pour toute et on déplace celui-ci en _x, _y ,_rotation...
    l'animation consiste en un déplacement de movieclips.

    j'ai essayé dans le onenterframe d'augmenter d'un point courbe à chaque fois et de la faire tracer avec paint (RPolyline) ça ne marche pas.

    Il serait nécessaire de recréer le movieclip à chaque entrée dans onenterframe...(ce qui est impossible)

    merci encore de ton aide.


    ps: mon but étant le tracé de la cycloïde avec la roue pour un tracé qui se ferait au fur et à mesure.
    je ne comprend pas bien ce que tu veux faire...mais tout est possible, je n'ai pas réellement testé les performances des différentes approches

    1) déplacer le movieclip en ajoutant les points supplémentaires

    2) clear() du movieclip et tout redessiner

    3) détruire le movieclip et en recréer un

    par contre la première approche me semble la plus indiquée pour un traitement en temps réel puisqu'on limite le code exécuté à chaque frame.
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  7. #7
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut
    Merci..d'ailleurs, je ne comprends pas qu'il n'y ait pas plus de personnes intéressées par ton bébé...
    Moi, je trouve ça génial...ça donne un nouvel élan au codage en pascal en touchant le développement web.

    Ce que je veux... tu en as un exemple en pièce jointe que j'ai fait en delphi. clique sur trajectoire...

    avec clear..., il y a sans doute moyen...je vais faire de nouveaux essais.

    a+
    Fichiers attachés Fichiers attachés

  8. #8
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 445
    Points
    28 445
    Par défaut
    ok je comprend,

    donc oui, au moment du changement de direction tu peux faire un clear() pour effacer le tracé et le reprendre dans l'autre sens.

    pour gérer le vecteur soit tu le dessines dans un nouveau movieclip que tu clear() à chaques fois, ou que tu déplaces et l'orientes (_x, _y, _rotation).

    petite précision sur les "Parent", il est nécessaire de définir un parent uniquement quand tu veux que les déplacements d'un movieclip s'applique à ses enfants, sinon jouer sur Depth suffit (deux movieclip ne peuvent pas avoir la même profondeur sinon l'un sera invisible)
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  9. #9
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut
    Je suis désolé pour le retard ...J'étais absent et je n'avais pas de Wifi sous la main...
    J'ai travaillé sur l'utilisation de l'éditeur Flash et je suis parvenu entre autre à faire ça... :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
     
    program Graph;
     
    uses
      Flash8,Key,math;
     
    {$BACKGROUND $ffffff}
    {$FRAME_WIDTH  1000}
    {$FRAME_HEIGHT 290}
    {$FRAME_RATE 30}
     
    const  
      graph_width=1000;
      graph_height=250;
      xmin = -12;
      xmax = +12;
      ymin = - 1;
      ymax = + 5;     
      xsize= xmax - xmin;
      ysize= ymax - ymin;
      Gx   = graph_width / xsize;
      Gy   = graph_height/ ysize;
      xo   =-xmin * Gx;
      yo   = ymax * Gy;
      Pi   = 3.141592654;
      angle = Pi/180; //1° à chaque frame
      phi = pi/2;//pour le décalage des rayons
     
     
    type
     
      TRpoint = external class(flash.geom.Point)
        constructor Create(x, y: double);
        property x: double;
        property y: double;
       end;
     
       TTrackcur=class(MovieClip)
        indice:integer;
        xcur,ycur:array of Integer;
        downcur:array of Boolean;
        xmouse:array of integer;
        trackmin,trackmax: array of Integer;
        Position:array of Double;
        constructor Create(AOWNER:Movieclip;Depth,number:integer;trmin,trmax:integer;posi:Double);
        procedure doClick;
        procedure doenterframe;
        procedure domouseup;
       end;
     
     
       TTrackbar=class(MovieClip)
        cur:array of TTrackcur;
        procedure DrawTrackbar(BackColor,penColor,Width, Height: Integer);
        constructor Create(AOWNER:Movieclip;Depth,number,trmin,trmax:integer;posi:Double);
       end;
     
      TButton=class(MovieClip)
       Caption: TextField;
       constructor Create(AOWNER:Movieclip);
       procedure GetFont;
       procedure DrawButton(BackColor, TopColor, BottomColor, Width, Height: Integer);
       procedure DoClick;
      end;
     
      TLabel=class(TextField)
        LbFont   : TextFormat;
        function FloattostrF(number:Double;digit:integer):String;
        constructor Create(Parent:MovieClip; depth,left,top,width,height:integer);
      end; 
     
      RealMovie = class(MovieClip)
       Arrow: Array of 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 Rrectangle(x1,y1,x2,y2:double);
       Procedure RCircle(Cx,Cy,Radius:double);
       Procedure RCurveTo(x1,y1,x2,y2:double);
       procedure RArrow(x1,y1,x2,y2:double;col,penw:integer); //flèche
       procedure RArrow2(Fx,Fy,norme,alpha:double;col,penw:integer);//en coords polaires /alpha en °
      end;
     
      TGraphe = class(RealMovie)
        permute: Boolean;
        xcy, ycy : Double; //coords point cycloïde
        xR,yR: Double;  //coords. du centre de la roue
        theta,dtheta: Double;//angle de rotation de la roue +incrément
        Roue:RealMovie;
        button: TButton;
        ToolRayon,ToolSpeed:TLabel;
        Trackbar,Trackbar2:TTrackbar;
        constructor Create;
        procedure GetPoint;
        procedure onEnterFrame;
      end;
     
     
    var  courbe:array of TRpoint;//Je suis obligé de déclarer le tableau ici et pas dans Realmovie car roue.courbe et bien, ça ne marche pas...
         //le dimensionnement est inutile... donc je le laisse de côté.
         tabmax:integer;// dimension de courbe
         Font   : TextFormat;
         Bascule: Boolean;
         h,w:integer; //taille du trackbar
         c:array[1..2,1..2] of integer;//centre des arrondis de trackbar (dommage, on ne peut pas le déclarer en variable locale dans Drawtrackbar ! )
         radius : Double;  //rayon de la roue
         graphe:Tgraphe;
     
    // Méthodes de dessin de Realmovie
    Procedure RealMovie.RMoveTo(x,y:double);
    begin
     Moveto(xo+x*Gx,yo-y*Gy);
    end;
     
    Procedure RealMovie.RLineTo(x,y:double);
    begin
     Lineto(xo+x*Gx,yo-y*Gy);
    end;
     
    Procedure RealMovie.RLine(x1,y1,x2,y2:double);
    begin
     RMoveto(x1,y1);
     RLineto(x2,y2);
    end;
     
    Procedure RealMovie.RPolyline;
    var i:integer;
    begin
      RMoveto(courbe[0].x,courbe[0].y);
      for i:=1 to tabmax-1 do Rlineto(courbe[i].x,courbe[i].y);
    end;
     
    Procedure RealMovie.Rrectangle(x1,y1,x2,y2:double);
    begin
     RMoveto(x1,y1);
     RLineTo(x2,y1);
     RLineto(x2,y2);
     RLineto(x1,y2);
     RLineto(x1,y1);
    end;
     
    Procedure RealMovie.Rcircle(Cx,Cy,Radius:double); //si orthonormé
    var a,b: Double;
          R: Double;
    begin
      R:=radius*Gx;
      Cx:=xo+Cx*Gx;
      Cy:=yo-Cy*Gy;
      a:= R * 0.414213562;
      b:= R * 0.707106781;
      moveTo(Cx+R,Cy);
      CurveTo(Cx+ R, Cy+-a, Cx+b,Cy -b);
      CurveTo(Cx+ a,Cy-R,Cx,Cy -r);
      CurveTo(Cx-a,Cy -R,Cx-b,Cy -b);
      CurveTo(Cx-R, Cy-a,Cx-R,Cy);
      CurveTo(Cx-R,Cy+a,Cx-b,Cy+b);
      CurveTo(Cx-a,Cy +R,Cx,Cy+r);
      CurveTo(Cx+a,Cy +R,Cx+b,Cy+b);
      CurveTo(Cx+R,Cy+a,Cx+R,Cy);
    end;
     
    Procedure RealMovie.RArrow(x1,y1,x2,y2:double;col,penw:integer);//flèche
    var i:integer;
        Norme,cX,cY: double;
        ALength,AWidth:double;  //longueur et largeur de la pointe
    begin
      ALength:=10;
      AWidth:=7;
      x1:=xo+x1*Gx;
      x2:=xo+x2*Gx;
      y1:=yo-y1*Gy;
      y2:=yo-y2*Gy;                                                                                           
      Norme:=SQRT((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
      if Norme=0 then Exit;
      cX:=(x2-x1)/Norme;
      cY:=(y2-y1)/Norme;
      Arrow[0]:=TRPoint.create(x2,y2);
      Arrow[1]:=TRPoint.create(x2-cX*ALength+cY*AWidth,y2-cY*ALength-cX*AWidth);
      Arrow[2]:=TRPoint.create(x2-cX*ALength-cY*AWidth,y2-cY*ALength+cX*AWidth);
      Arrow[3]:=TRPoint.create(x2,y2);
     
      Linestyle(penw,col);
      BeginFill(col);
      Moveto(x1,y1);
      Lineto(x2,y2);
      Moveto(arrow[0].x,arrow[0].y);
      for i:=1 to 3 do lineto(arrow[i].x,arrow[i].y);
      Endfill();
    end;
     
    procedure RealMovie.RArrow2(Fx,Fy,norme,alpha:double;col,penw:integer);//Flèche en coords polaires
    var theta: Double;
        L,L1: Double;
        xf1,yf1 :Double;
        xf2,yf2 :Double;
        x,y : Double;
    begin
     alpha:=pi*alpha/180;
     
     x:=norme*cos(alpha);
     y:=norme*sin(alpha);
     if x<>0.0 then theta:=atan2(y,x) else theta:=0;
     L:=sqrt((x*x)+(y*y))/10;
     L1:=L/2;
     
     xf1:=-L*cos(theta)-L1*sin(theta);
     xf2:=-L*cos(theta)+L1*sin(theta);
     yf1:=-L*sin(theta)+L1*cos(theta);
     yf2:=-L*sin(theta)-L1*cos(theta);
     
     linestyle(penw,col);
     RLine(Fx,Fy,Fx+x,Fy+y);
     RLine(x+Fx,y+Fy,x+Fx+xf1,y+Fy+yf1);
     RLine(x+Fx,y+Fy,x+Fx+xf2,y+Fy+yf2);
    end;
     
    procedure RealMovie.RCurveto(x1,y1,x2,y2:double);
    begin
     curveto(xo+x1*Gx,yo-y1*Gy,xo+x2*Gx,yo-y2*Gy);
    end;
    //fin méthodes realmovie 
     
    constructor TGraphe.Create;
    var
      i : Integer;
    begin
      inherited Create(nil, 'graphe', 0);
      _x:=0;
      _y:=0;
      radius:=2;
    //quadrillage
      lineStyle(2, $000000);
      for i := -12 to 12 do Rline(i,ymin,i,ymax);
      for i := -1 to 5 do Rline(xmin,i,xmax,i);
      lineStyle(1,$1BD2FF);
      for i := -10 to 50 do Rline(xmin,i/10,xmax,i/10);
      for i := -120 to 120 do Rline(i/10,ymin,i/10,ymax);
      //repère
      lineStyle(2, $000000);
      Rline(xmin,0,xmax,0); //abscisse uniquement
      //*********
      Roue:=RealMovie.Create(nil, 'roue', 1);
      xR:=xmin+radius;
      yR:=radius;
      xcy:=xmin;
      ycy:=radius;
      theta:=0;
      permute:=false;
      tabmax:=1;
      dtheta:=angle;
      courbe[0]:=TRPoint.Create(xcy,ycy);
      //bouton   marche/arrêt
      Button:=TButton.Create(self);
      Button._x:=0;
      Button._y:=254;
      //le trackbar pour le rayon de la roue
      trackbar:=TTrackbar.Create(self,2,1,5,20,20); //parent;depth;n°de trackbar;min;max;position
      trackbar._x:=115;
      trackbar._y:=265;
      trackbar2:=TTrackbar.Create(self,4,2,1,4,1);
      trackbar2._x:=445;
      trackbar2._y:=265; 
      //affichage de l'évolution des trackbars
      ToolRayon:= TLabel.create(self,3,320,255,115,30);
      ToolRayon.text:='Rayon :'+ToolRayon.floattostrF(radius,1);
      ToolRayon.SetTextFormat(ToolRayon.lbFont);
      ToolSpeed:=TLabel.Create(self,5,642,255,355,30);
      ToolSpeed.text:=' vitesse angulaire (°/image) : '+ToolSpeed.floattostrF(dtheta*180/pi,2);
      ToolSpeed.SetTextFormat(ToolSpeed.lbFont);
       //trait pour simuler une toolbar
      lineStyle(1,$000000);
      moveto(0,290);
      lineto(1000,290);
    end;
     
    procedure TGraphe.GetPoint;
    begin
     if bascule then //condition marche arrêt bouton
     begin
      inc(tabmax);
      if not permute then theta:=theta+dtheta else  theta:=theta - dtheta;//on tourne d'un degré à chaque frame
     end;
      //coords centre roue
     xR:=xmin+radius+radius*theta;
     yR:=radius;
     //coords point cyclo
     xcy:=xR+radius*cos(pi-theta);
     ycy:=yR+radius*sin(pi-theta);
     courbe[tabmax-1]:=TRPoint.Create(xcy,ycy);
    end;
     
    procedure TGraphe.onEnterFrame;
    begin
      Roue.clear; //On efface
      //roue -cercle
      Roue.linestyle(3,$000000);
      Roue.RCircle(xR,yR,radius);  
      //rayons
      Roue.linestyle(3,$ff0000);
      Roue.Rline(xR,yR,xR+radius*cos(pi-theta),yR+radius*sin(pi-theta));
      Roue.linestyle(3,$000000);
      Roue.Rline(xR,yR,xR+radius*cos(pi-theta+phi),yR+radius*sin(pi-theta+phi));
      Roue.Rline(xR,yR,xR+radius*cos(pi-theta+2*phi),yR+radius*sin(pi-theta+2*phi));
      Roue.Rline(xR,yR,xR+radius*cos(pi-theta+3*phi),yR+radius*sin(pi-theta+3*phi));
      Roue.linestyle(3,$000000);
      Roue.Rline(xR,yR-0.35,xR,yR+0.35);
      Roue.Rline(xR-0.35,yR,xR+0.35,yR);  //manque with do begin end;...
      //fin rayons+roue
      if (xR<xmin+radius) or (xR>xmax-radius) then   //condition aller et retour
      Begin
        permute:= not  permute;
        tabmax:=1;
        if xR<xmin+radius then courbe[0]:=TRPoint.Create(xmin,ycy) else courbe[0]:=TRPoint.Create(xcy,ycy );
      End;  
      GetPoint; 
      roue.lineStyle(2,$0000ff); //cycloïde
      roue.Rpolyline;
    end;
     
     
     Constructor TButton.Create(AOWNER:Movieclip);
     begin
      inherited Create(AOWNER,'button',1);
      GetFont;
      Caption := TextField.Create(Self, '', 0, 0,8,100,35);
      Caption.text:='Stop';
      Caption.SetTextFormat(Font);
      DrawButton($F0F0F0,$808080,008080,100, 35);
      Bascule:=true;
      onpress:=DoClick;
     end;
     
     
     Procedure TButton.DrawButton(BackColor, TopColor, BottomColor, Width, Height: Integer);
     begin
      beginFill(BackColor);
      lineStyle(5, TopColor);
      moveTo(0, Height);
      lineTo(0, 0);
      lineTo(Width, 0);
      lineStyle(5, BottomColor);
      lineTo(Width, Height);
      lineTo(0, Height);
      endFill;
     end; 
     
     Procedure TButton.doClick;
     begin
      Bascule:=not Bascule;
      if Bascule then Caption.text:='Stop' else Caption.text:='Anime';
      Caption.SetTextFormat(Font);
     end;
     
    Procedure TButton.GetFont;
    begin
     Font := TextFormat.Create('Tahoma', 12);
     Font.Align := 'center';
     Font.Bold := True;
     Font.Color := $000000;
    end;
     
    constructor TTrackbar.Create(AOWNER:Movieclip;Depth,number,trmin,trmax:integer;posi:Double);
    begin
     inherited Create(AOWNER,'trackbar',Depth);
     DrawTrackBar($CCCBB4,$CCCBB4,175,12); 
     cur[number]:=TTrackcur.Create(self,number,number,trmin,trmax,posi);
    end;
     
     
    constructor TTrackcur.create(AOWNER:Movieclip;Depth,number:integer;trmin,trmax: integer;posi:Double);
    var  r:integer;
         a,b:Double;
    begin
      inherited Create(AOWNER,'cur',Depth);
      _x:=floor((posi-trmin)*w/(trmax-trmin));//position initiale du curseur
      _y:=0;
      indice:=number;
      xcur[number]:=6;
      ycur[number]:=6;
      r:=floor(1.35*12);
      a:= r * 0.414213562;
      b:= r * 0.707106781; 
      linestyle(1,$5F9EA0);
      beginFill($5F9EA0);
      moveTo(r+xcur[number], ycur[number]);
      curveTo( r+xcur[number],-a+ycur[number],+b+xcur[number], -b+ ycur[number]);
      curveTo( a+xcur[number],-r+ycur[number],xcur[number], -r+ ycur[number]);
      curveTo(-a+xcur[number],-r+ycur[number],-b+xcur[number], -b+ ycur[number]);
      curveTo(-r+xcur[number],-a+ycur[number],-r+xcur[number], ycur[number]);
      curveTo(-r+xcur[number],a+ycur[number],-b+xcur[number], b+ ycur[number]);
      curveTo(-a+xcur[number],r+ycur[number],xcur[number], r+ ycur[number]);
      curveTo( a+xcur[number],r+ycur[number],b+xcur[number],b+ ycur[number]);
      curveTo( r+xcur[number],a+ycur[number],r+xcur[number],ycur[number]);
      endfill();
      downcur[number]:=false;
      trackmin[number]:=trmin;
      trackmax[number]:=trmax;
      position[number]:=posi;
      onPress:=doclick;
      onEnterFrame:=doEnterFrame;
      onmouseup:=domouseup;
    end;
     
    procedure TTrackbar.DrawTrackbar(BackColor,penColor,Width, Height: Integer);
    var r: integer;//rayon des arrondis
        a,b:Double; 
        i:integer;
    begin
     h:=height;
     w:=width;
     r:=h div 2;
     c[1,1]:=r;  //coords des deux arrondis
     c[2,1]:=r;
     c[1,2]:=w-r;
     c[2,2]:=r;
     //j'ai dessiné un rectangle plein+deux disques aux extrémités. il y a plus simple avec 2 curveto aux deux extrémités et remplir...
     //je n'avais pas envie de me compliquer la vie...
     beginFill(Backcolor);
     linestyle(2,pencolor);
     moveto(r,0);
     lineto(w-r,0);
     lineto(w-r,height);
     lineto(r,height);
     endFill(); //pour la superposition
     a:= r * 0.414213562;
     b:= r * 0.707106781;
     beginFill(Backcolor);
     for i:=1 to 2 do 
      begin
       moveTo(r+c[1,i], c[2,i]);
       curveTo( r+c[1,i], -a+ c[2,i], +b+c[1,i], -b+ c[2,i]);
       curveTo( a+c[1,i], -r+ c[2,i], c[1,i], -r+ c[2,i]);
       curveTo(-a+c[1,i], -r+ c[2,i], -b+c[1,i], -b+ c[2,i]);
       curveTo(-r+c[1,i], -a+ c[2,i], -r+c[1,i], c[2,i]);
       curveTo(-r+c[1,i], +a+ c[2,i], -b+c[1,i], +b+ c[2,i]);
       curveTo(-a+c[1,i], r+ c[2,i], c[1,i], +r+ c[2,i]);
       curveTo( a+c[1,i], +r+ c[2,i], b+c[1,i], +b+ c[2,i]);
       curveTo( r+c[1,i], +a+ c[2,i], r+c[1,i], c[2,i]);
      end; 
      endfill();
    end;
     
    procedure  TTrackcur.doClick;
    begin
     downcur[indice]:=true;
     xmouse[indice]:=_xmouse; 
    end;
     
    procedure  TTrackcur.doEnterframe;
    begin
     case indice of
      1:begin
         if  (_x + _xmouse -xmouse[1]>w) or (_x + _xmouse -xmouse[1]<0)  then exit;  //pas génial pour gérer les extrémités...
         if downcur[1] then 
         begin
          _x:= _x + _xmouse -xmouse[1];
          position[1]:=_x*(trackmax[1]-trackmin[1])/w+trackmin[1];//en double
          radius:=position[1]/10;   //rayon de le roue de 0.5 à 5 (min:5-max:20)
          graphe.ToolRayon.text:='Rayon :'+graphe.ToolRayon.floattostrF(radius,1); 
          graphe.ToolRayon.SetTextFormat(graphe.ToolRayon.lbFont);
          //retour au point de départ
          tabmax:=0;
          graphe.xR:=xmin+Radius;
          graphe.theta:=0; 
         end;    
       end; 
     
     2: begin
          if  (_x + _xmouse -xmouse[2]>w) or (_x + _xmouse -xmouse[2]<0)  then exit;
          if downcur[2] then 
          begin
              _x:= _x + _xmouse -xmouse[2];  
              position[2]:=_x*(trackmax[2]-trackmin[2])/w+trackmin[2] ;
              graphe.dtheta:=position[2]*angle;
              graphe.ToolSpeed.text:=' vitesse angulaire (°/image) : '+graphe.ToolSpeed.floattostrF(graphe.dtheta*180/pi,2);
              graphe.ToolSpeed.SetTextFormat(graphe.ToolSpeed.lbFont);
          end; 
        end;
      //  ....
      //  n: begin
      //     end;   
     end;//du case
    end; 
     
    procedure  TTrackcur.doMouseUp;
    begin
     downcur[indice]:=false;
    end;
     
    constructor TLabel.Create(Parent:MovieClip; depth,left,top,width,height:integer);
    begin
     inherited Create(parent,'label',depth,left,top,width,height);
     LbFont := TextFormat.Create('Tahoma', 20);
     LbFont.Align := 'left';
     LbFont.Bold := True;
     LbFont.Color := $000000; 
    end;
     
    function TLabel.FloattostrF(number:Double;digit:integer):String;//digit:nb de chiffre après la virgule
    var int:integer;
          frac,frac1,frac2,newnumber:Double;
    begin
       int:=trunc(number);
       frac:=number-int;
       frac1:=trunc(pow(10,digit)*frac)/pow(10,digit);
       frac2:= trunc(pow(10,digit+1)*frac)/pow(10,digit+1);
       //arrondi à la décimale supérieure si >=5
       if (frac2-frac1)*pow(10,digit+1)>=5 then newnumber:=int+frac1+pow(10,-digit) else newnumber:=int+frac1;
       result:=floattostr(newnumber);
    end;
     
     
    begin
      graphe:=TGraphe.Create;
    end.
    mes questions sont les suivantes :

    Comment avoir l'équivalent du timer.enabled:=false; ...
    Avec le onEnterFrame, j'ai été obliger de m'en tirer par une pirouette en ne faisant pas évoluer theta.

    Pour les trackbars, l'événement onmousemove est peu réactif... retard entre le déplacement du curseur et celui de la souris . je l'ai donc abandonné pour l'événement onenterframe.

    Les extrémités du trackbar, je pense que ce n'est pas satisfaisant.
    Une idée peut-être pour mieux gérer les valeurs extrêmes min et max qui ne sont pas facile à atteindre...

    a+

  10. #10
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 445
    Points
    28 445
    Par défaut
    réponse rapide

    pas de Timer, enfin si je crois que ça existe mais c'est pas génial, donc le plus simple et de placer un boolean que tu testes dans onEnterFrame pour savoir s'il y a un traitement à faire ou non. if not Traitement then Exit;.

    Pour les extrémités des trackbars ce n'est pas un Exit qu'il faut faire mais borner la position if x < min then x := min else if x > max then x := max;
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  11. #11
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut
    Merci pour ta réponse... mais :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
       if  _x + _xmouse -xmouse[1]>w then _x + _xmouse -xmouse[1]=w; 
         if _x + _xmouse -xmouse[1]<0 then _x + _xmouse -xmouse[1]=0;
    ce n'est pas possible ...

    vu pour le timer...

  12. #12
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 445
    Points
    28 445
    Par défaut
    Citation Envoyé par Archimède Voir le message
    Merci pour ta réponse... mais :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
       if  _x + _xmouse -xmouse[1]>w then _x + _xmouse -xmouse[1]=w; 
         if _x + _xmouse -xmouse[1]<0 then _x + _xmouse -xmouse[1]=0;
    ce n'est pas possible ...

    vu pour le timer...
    tout à fait, mais je suis surpris qu'une équation aussi simple te pose problème

    voici un corrigé, j'en ai profité pour supprimer les "array of" de TTrackCur et TTrackBar qui ne servent à rien "indice" est conservé pour définir l'action à faire, mais il aurait également été possible de déclarer un évènement onChange à affecter dans TGraphe (pas testé)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
     
    program Graph;
     
    uses
      Flash8,Key,math;
     
    {$BACKGROUND $ffffff}
    {$FRAME_WIDTH  1000}
    {$FRAME_HEIGHT 290}
    {$FRAME_RATE 30}
     
    const  
      graph_width=1000;
      graph_height=250;
      xmin = -12;
      xmax = +12;
      ymin = - 1;
      ymax = + 5;     
      xsize= xmax - xmin;
      ysize= ymax - ymin;
      Gx   = graph_width / xsize;
      Gy   = graph_height/ ysize;
      xo   =-xmin * Gx;
      yo   = ymax * Gy;
      Pi   = 3.141592654;
      angle = Pi/180; //1° à chaque frame
      phi = pi/2;//pour le décalage des rayons
     
     
    type
     
      TRpoint = external class(flash.geom.Point)
        constructor Create(x, y: double);
        property x: double;
        property y: double;
       end;
     
       TTrackcur=class(MovieClip)
        indice:integer;
        xcur,ycur:Integer;
        downcur:Boolean;
        xmouse:integer;
        trackmin,trackmax: Integer;
        Position:Double;
        constructor Create(AOWNER:Movieclip;Depth,number:integer;trmin,trmax:integer;posi:Double);
        procedure doClick;
        procedure doenterframe;
        procedure domouseup;
       end;
     
     
       TTrackbar=class(MovieClip)
        cur:TTrackcur;
        procedure DrawTrackbar(BackColor,penColor,Width, Height: Integer);
        constructor Create(AOWNER:Movieclip;Depth,number,trmin,trmax:integer;posi:Double);
       end;
     
      TButton=class(MovieClip)
       Caption: TextField;
       constructor Create(AOWNER:Movieclip);
       procedure GetFont;
       procedure DrawButton(BackColor, TopColor, BottomColor, Width, Height: Integer);
       procedure DoClick;
      end;
     
      TLabel=class(TextField)
        LbFont   : TextFormat;
        function FloattostrF(number:Double;digit:integer):String;
        constructor Create(Parent:MovieClip; depth,left,top,width,height:integer);
      end; 
     
      RealMovie = class(MovieClip)
       Arrow: Array of 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 Rrectangle(x1,y1,x2,y2:double);
       Procedure RCircle(Cx,Cy,Radius:double);
       Procedure RCurveTo(x1,y1,x2,y2:double);
       procedure RArrow(x1,y1,x2,y2:double;col,penw:integer); //flèche
       procedure RArrow2(Fx,Fy,norme,alpha:double;col,penw:integer);//en coords polaires /alpha en °
      end;
     
      TGraphe = class(RealMovie)
        permute: Boolean;
        xcy, ycy : Double; //coords point cycloïde
        xR,yR: Double;  //coords. du centre de la roue
        theta,dtheta: Double;//angle de rotation de la roue +incrément
        Roue:RealMovie;
        button: TButton;
        ToolRayon,ToolSpeed:TLabel;
        Trackbar,Trackbar2:TTrackbar;
        constructor Create;
        procedure GetPoint;
        procedure onEnterFrame;
      end;
     
     
    var  courbe:array of TRpoint;//Je suis obligé de déclarer le tableau ici et pas dans Realmovie car roue.courbe et bien, ça ne marche pas...
         //le dimensionnement est inutile... donc je le laisse de côté.
         tabmax:integer;// dimension de courbe
         Font   : TextFormat;
         Bascule: Boolean;
         h,w:integer; //taille du trackbar
         c:array[1..2,1..2] of integer;//centre des arrondis de trackbar (dommage, on ne peut pas le déclarer en variable locale dans Drawtrackbar ! )
         radius : Double;  //rayon de la roue
         graphe:Tgraphe;
     
    // Méthodes de dessin de Realmovie
    Procedure RealMovie.RMoveTo(x,y:double);
    begin
     Moveto(xo+x*Gx,yo-y*Gy);
    end;
     
    Procedure RealMovie.RLineTo(x,y:double);
    begin
     Lineto(xo+x*Gx,yo-y*Gy);
    end;
     
    Procedure RealMovie.RLine(x1,y1,x2,y2:double);
    begin
     RMoveto(x1,y1);
     RLineto(x2,y2);
    end;
     
    Procedure RealMovie.RPolyline;
    var i:integer;
    begin
      RMoveto(courbe[0].x,courbe[0].y);
      for i:=1 to tabmax-1 do Rlineto(courbe[i].x,courbe[i].y);
    end;
     
    Procedure RealMovie.Rrectangle(x1,y1,x2,y2:double);
    begin
     RMoveto(x1,y1);
     RLineTo(x2,y1);
     RLineto(x2,y2);
     RLineto(x1,y2);
     RLineto(x1,y1);
    end;
     
    Procedure RealMovie.Rcircle(Cx,Cy,Radius:double); //si orthonormé
    var a,b: Double;
          R: Double;
    begin
      R:=radius*Gx;
      Cx:=xo+Cx*Gx;
      Cy:=yo-Cy*Gy;
      a:= R * 0.414213562;
      b:= R * 0.707106781;
      moveTo(Cx+R,Cy);
      CurveTo(Cx+ R, Cy+-a, Cx+b,Cy -b);
      CurveTo(Cx+ a,Cy-R,Cx,Cy -r);
      CurveTo(Cx-a,Cy -R,Cx-b,Cy -b);
      CurveTo(Cx-R, Cy-a,Cx-R,Cy);
      CurveTo(Cx-R,Cy+a,Cx-b,Cy+b);
      CurveTo(Cx-a,Cy +R,Cx,Cy+r);
      CurveTo(Cx+a,Cy +R,Cx+b,Cy+b);
      CurveTo(Cx+R,Cy+a,Cx+R,Cy);
    end;
     
    Procedure RealMovie.RArrow(x1,y1,x2,y2:double;col,penw:integer);//flèche
    var i:integer;
        Norme,cX,cY: double;
        ALength,AWidth:double;  //longueur et largeur de la pointe
    begin
      ALength:=10;
      AWidth:=7;
      x1:=xo+x1*Gx;
      x2:=xo+x2*Gx;
      y1:=yo-y1*Gy;
      y2:=yo-y2*Gy;                                                                                           
      Norme:=SQRT((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
      if Norme=0 then Exit;
      cX:=(x2-x1)/Norme;
      cY:=(y2-y1)/Norme;
      Arrow[0]:=TRPoint.create(x2,y2);
      Arrow[1]:=TRPoint.create(x2-cX*ALength+cY*AWidth,y2-cY*ALength-cX*AWidth);
      Arrow[2]:=TRPoint.create(x2-cX*ALength-cY*AWidth,y2-cY*ALength+cX*AWidth);
      Arrow[3]:=TRPoint.create(x2,y2);
     
      Linestyle(penw,col);
      BeginFill(col);
      Moveto(x1,y1);
      Lineto(x2,y2);
      Moveto(arrow[0].x,arrow[0].y);
      for i:=1 to 3 do lineto(arrow[i].x,arrow[i].y);
      Endfill();
    end;
     
    procedure RealMovie.RArrow2(Fx,Fy,norme,alpha:double;col,penw:integer);//Flèche en coords polaires
    var theta: Double;
        L,L1: Double;
        xf1,yf1 :Double;
        xf2,yf2 :Double;
        x,y : Double;
    begin
     alpha:=pi*alpha/180;
     
     x:=norme*cos(alpha);
     y:=norme*sin(alpha);
     if x<>0.0 then theta:=atan2(y,x) else theta:=0;
     L:=sqrt((x*x)+(y*y))/10;
     L1:=L/2;
     
     xf1:=-L*cos(theta)-L1*sin(theta);
     xf2:=-L*cos(theta)+L1*sin(theta);
     yf1:=-L*sin(theta)+L1*cos(theta);
     yf2:=-L*sin(theta)-L1*cos(theta);
     
     linestyle(penw,col);
     RLine(Fx,Fy,Fx+x,Fy+y);
     RLine(x+Fx,y+Fy,x+Fx+xf1,y+Fy+yf1);
     RLine(x+Fx,y+Fy,x+Fx+xf2,y+Fy+yf2);
    end;
     
    procedure RealMovie.RCurveto(x1,y1,x2,y2:double);
    begin
     curveto(xo+x1*Gx,yo-y1*Gy,xo+x2*Gx,yo-y2*Gy);
    end;
    //fin méthodes realmovie 
     
    constructor TGraphe.Create;
    var
      i : Integer;
    begin
      inherited Create(nil, 'graphe', 0);
      _x:=0;
      _y:=0;
      radius:=2;
    //quadrillage
      lineStyle(2, $000000);
      for i := -12 to 12 do Rline(i,ymin,i,ymax);
      for i := -1 to 5 do Rline(xmin,i,xmax,i);
      lineStyle(1,$1BD2FF);
      for i := -10 to 50 do Rline(xmin,i/10,xmax,i/10);
      for i := -120 to 120 do Rline(i/10,ymin,i/10,ymax);
      //repère
      lineStyle(2, $000000);
      Rline(xmin,0,xmax,0); //abscisse uniquement
      //*********
      Roue:=RealMovie.Create(nil, 'roue', 1);
      xR:=xmin+radius;
      yR:=radius;
      xcy:=xmin;
      ycy:=radius;
      theta:=0;
      permute:=false;
      tabmax:=1;
      dtheta:=angle;
      courbe[0]:=TRPoint.Create(xcy,ycy);
      //bouton   marche/arrêt
      Button:=TButton.Create(self);
      Button._x:=0;
      Button._y:=254;
      //le trackbar pour le rayon de la roue
      trackbar:=TTrackbar.Create(self,2,1,5,20,20); //parent;depth;n°de trackbar;min;max;position
      trackbar._x:=115;
      trackbar._y:=265;
      trackbar2:=TTrackbar.Create(self,4,2,1,4,1);
      trackbar2._x:=445;
      trackbar2._y:=265; 
      //affichage de l'évolution des trackbars
      ToolRayon:= TLabel.create(self,3,320,255,115,30);
      ToolRayon.text:='Rayon :'+ToolRayon.floattostrF(radius,1);
      ToolRayon.SetTextFormat(ToolRayon.lbFont);
      ToolSpeed:=TLabel.Create(self,5,642,255,355,30);
      ToolSpeed.text:=' vitesse angulaire (°/image) : '+ToolSpeed.floattostrF(dtheta*180/pi,2);
      ToolSpeed.SetTextFormat(ToolSpeed.lbFont);
       //trait pour simuler une toolbar
      lineStyle(1,$000000);
      moveto(0,290);
      lineto(1000,290);
    end;
     
    procedure TGraphe.GetPoint;
    begin
     if bascule then //condition marche arrêt bouton
     begin
      inc(tabmax);
      if not permute then theta:=theta+dtheta else  theta:=theta - dtheta;//on tourne d'un degré à chaque frame
     end;
      //coords centre roue
     xR:=xmin+radius+radius*theta;
     yR:=radius;
     //coords point cyclo
     xcy:=xR+radius*cos(pi-theta);
     ycy:=yR+radius*sin(pi-theta);
     courbe[tabmax-1]:=TRPoint.Create(xcy,ycy);
    end;
     
    procedure TGraphe.onEnterFrame;
    begin
      Roue.clear; //On efface
      //roue -cercle
      Roue.linestyle(3,$000000);
      Roue.RCircle(xR,yR,radius);  
      //rayons
      Roue.linestyle(3,$ff0000);
      Roue.Rline(xR,yR,xR+radius*cos(pi-theta),yR+radius*sin(pi-theta));
      Roue.linestyle(3,$000000);
      Roue.Rline(xR,yR,xR+radius*cos(pi-theta+phi),yR+radius*sin(pi-theta+phi));
      Roue.Rline(xR,yR,xR+radius*cos(pi-theta+2*phi),yR+radius*sin(pi-theta+2*phi));
      Roue.Rline(xR,yR,xR+radius*cos(pi-theta+3*phi),yR+radius*sin(pi-theta+3*phi));
      Roue.linestyle(3,$000000);
      Roue.Rline(xR,yR-0.35,xR,yR+0.35);
      Roue.Rline(xR-0.35,yR,xR+0.35,yR);  //manque with do begin end;...
      //fin rayons+roue
      if (xR<xmin+radius) or (xR>xmax-radius) then   //condition aller et retour
      Begin
        permute:= not  permute;
        tabmax:=1;
        if xR<xmin+radius then courbe[0]:=TRPoint.Create(xmin,ycy) else courbe[0]:=TRPoint.Create(xcy,ycy );
      End;  
      GetPoint; 
      roue.lineStyle(2,$0000ff); //cycloïde
      roue.Rpolyline;
    end;
     
     
     Constructor TButton.Create(AOWNER:Movieclip);
     begin
      inherited Create(AOWNER,'button',1);
      GetFont;
      Caption := TextField.Create(Self, '', 0, 0,8,100,35);
      Caption.text:='Stop';
      Caption.SetTextFormat(Font);
      DrawButton($F0F0F0,$808080,008080,100, 35);
      Bascule:=true;
      onpress:=DoClick;
     end;
     
     
     Procedure TButton.DrawButton(BackColor, TopColor, BottomColor, Width, Height: Integer);
     begin
      beginFill(BackColor);
      lineStyle(5, TopColor);
      moveTo(0, Height);
      lineTo(0, 0);
      lineTo(Width, 0);
      lineStyle(5, BottomColor);
      lineTo(Width, Height);
      lineTo(0, Height);
      endFill;
     end; 
     
     Procedure TButton.doClick;
     begin
      Bascule:=not Bascule;
      if Bascule then Caption.text:='Stop' else Caption.text:='Anime';
      Caption.SetTextFormat(Font);
     end;
     
    Procedure TButton.GetFont;
    begin
     Font := TextFormat.Create('Tahoma', 12);
     Font.Align := 'center';
     Font.Bold := True;
     Font.Color := $000000;
    end;
     
    constructor TTrackbar.Create(AOWNER:Movieclip;Depth,number,trmin,trmax:integer;posi:Double);
    begin
     inherited Create(AOWNER,'trackbar',Depth);
     DrawTrackBar($CCCBB4,$CCCBB4,175,12); 
     cur:=TTrackcur.Create(self,number,number,trmin,trmax,posi);
    end;
     
     
    constructor TTrackcur.create(AOWNER:Movieclip;Depth,number:integer;trmin,trmax: integer;posi:Double);
    var  r:integer;
         a,b:Double;
    begin
      inherited Create(AOWNER,'cur',Depth);
      _x:=floor((posi-trmin)*w/(trmax-trmin));//position initiale du curseur
      _y:=0;
      indice:=number;
      xcur:=6;
      ycur:=6;
      r:=floor(1.35*12);
      a:= r * 0.414213562;
      b:= r * 0.707106781; 
      linestyle(1,$5F9EA0);
      beginFill($5F9EA0);
      moveTo(r+xcur, ycur);
      curveTo( r+xcur,-a+ycur,+b+xcur, -b+ ycur);
      curveTo( a+xcur,-r+ycur,xcur, -r+ ycur);
      curveTo(-a+xcur,-r+ycur,-b+xcur, -b+ ycur);
      curveTo(-r+xcur,-a+ycur,-r+xcur, ycur);
      curveTo(-r+xcur,a+ycur,-b+xcur, b+ ycur);
      curveTo(-a+xcur,r+ycur,xcur, r+ ycur);
      curveTo( a+xcur,r+ycur,b+xcur,b+ ycur);
      curveTo( r+xcur,a+ycur,r+xcur,ycur);
      endfill();
      downcur:=false;
      trackmin:=trmin;
      trackmax:=trmax;
      position:=posi;
      onPress:=doclick;
      onEnterFrame:=doEnterFrame;
      onmouseup:=domouseup;
    end;
     
    procedure TTrackbar.DrawTrackbar(BackColor,penColor,Width, Height: Integer);
    var r: integer;//rayon des arrondis
        a,b:Double; 
        i:integer;
    begin
     h:=height;
     w:=width;
     r:=h div 2;
     c[1,1]:=r;  //coords des deux arrondis
     c[2,1]:=r;
     c[1,2]:=w-r;
     c[2,2]:=r;
     //j'ai dessiné un rectangle plein+deux disques aux extrémités. il y a plus simple avec 2 curveto aux deux extrémités et remplir...
     //je n'avais pas envie de me compliquer la vie...
     beginFill(Backcolor);
     linestyle(2,pencolor);
     moveto(r,0);
     lineto(w-r,0);
     lineto(w-r,height);
     lineto(r,height);
     endFill(); //pour la superposition
     a:= r * 0.414213562;
     b:= r * 0.707106781;
     beginFill(Backcolor);
     for i:=1 to 2 do 
      begin
       moveTo(r+c[1,i], c[2,i]);
       curveTo( r+c[1,i], -a+ c[2,i], +b+c[1,i], -b+ c[2,i]);
       curveTo( a+c[1,i], -r+ c[2,i], c[1,i], -r+ c[2,i]);
       curveTo(-a+c[1,i], -r+ c[2,i], -b+c[1,i], -b+ c[2,i]);
       curveTo(-r+c[1,i], -a+ c[2,i], -r+c[1,i], c[2,i]);
       curveTo(-r+c[1,i], +a+ c[2,i], -b+c[1,i], +b+ c[2,i]);
       curveTo(-a+c[1,i], r+ c[2,i], c[1,i], +r+ c[2,i]);
       curveTo( a+c[1,i], +r+ c[2,i], b+c[1,i], +b+ c[2,i]);
       curveTo( r+c[1,i], +a+ c[2,i], r+c[1,i], c[2,i]);
      end; 
      endfill();
    end;
     
    procedure  TTrackcur.doClick;
    begin
     downcur:=true;
     xmouse:=_xmouse; 
    end;
     
    procedure  TTrackcur.doEnterframe;
    var
      t: Integer;
    begin
     case indice of
      1:begin
         //if  (_x + _xmouse -xmouse>w) or (_x + _xmouse -xmouse<0)  then exit;  //pas génial pour gérer les extrémités...
         if downcur then 
         begin
          _x:= _x + _xmouse -xmouse;
          if _x < 0 then _x := 0;
          if _x > w then _x := w;
          position:=_x*(trackmax-trackmin)/w+trackmin;//en double
          radius:=position/10;   //rayon de le roue de 0.5 à 5 (min:5-max:20)
          graphe.ToolRayon.text:='Rayon :'+graphe.ToolRayon.floattostrF(radius,1); 
          graphe.ToolRayon.SetTextFormat(graphe.ToolRayon.lbFont);
          //retour au point de départ
          tabmax:=0;
          graphe.xR:=xmin+Radius;
          graphe.theta:=0; 
         end;    
       end; 
     
     2: begin
          //if  (_x + _xmouse -xmouse>w) or (_x + _xmouse -xmouse<0)  then exit;
          if downcur then 
          begin
              _x:= _x + _xmouse -xmouse;
              if _x < 0 then _x := 0;
              if _x > w then _x := w;  
              position:=_x*(trackmax-trackmin)/w+trackmin;
              graphe.dtheta:=position*angle;
              graphe.ToolSpeed.text:=' vitesse angulaire (°/image) : '+graphe.ToolSpeed.floattostrF(graphe.dtheta*180/pi,2);
              graphe.ToolSpeed.SetTextFormat(graphe.ToolSpeed.lbFont);
          end; 
        end;
      //  ....
      //  n: begin
      //     end;   
     end;//du case
    end; 
     
    procedure  TTrackcur.doMouseUp;
    begin
     downcur:=false;
    end;
     
    constructor TLabel.Create(Parent:MovieClip; depth,left,top,width,height:integer);
    begin
     inherited Create(parent,'label',depth,left,top,width,height);
     LbFont := TextFormat.Create('Tahoma', 20);
     LbFont.Align := 'left';
     LbFont.Bold := True;
     LbFont.Color := $000000; 
    end;
     
    function TLabel.FloattostrF(number:Double;digit:integer):String;//digit:nb de chiffre après la virgule
    var int:integer;
          frac,frac1,frac2,newnumber:Double;
    begin
       int:=trunc(number);
       frac:=number-int;
       frac1:=trunc(pow(10,digit)*frac)/pow(10,digit);
       frac2:= trunc(pow(10,digit+1)*frac)/pow(10,digit+1);
       //arrondi à la décimale supérieure si >=5
       if (frac2-frac1)*pow(10,digit+1)>=5 then newnumber:=int+frac1+pow(10,-digit) else newnumber:=int+frac1;
       result:=floattostr(newnumber);
    end;
     
     
    begin
      graphe:=TGraphe.Create;
    end.
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  13. #13
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut
    Ah oui, effectivement Nickel

    C'est vrai, c'est le _xmouse qui me perturbait...Je n'ai pas pensé à fixer le _x...
    C'était tout bête...) Parfois, il ne faut pas chercher à comprendre..., ça ne tourne pas toujours rond dans le ciboulot...
    Et bien maintenant, je l'ai mon trackbar

    Je vais pouvoir insérer les vecteurs vitesse...
    Je regarde tes modifs pour le curseur (c'était effectivement un peu lourd... les idées viennent quand on rencontre un obstacle et les premières solutions sont parfois peu concises et redondantes...En effet en créant deux instances de TTrackbar, c'est redondant d'ajouter un tableau qui fait double emploi...

    bon dimanche et merci encore

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 31
    Dernier message: 29/11/2008, 14h03
  2. Récuperer les coordonnées d'un vecteur
    Par kerzut dans le forum OpenGL
    Réponses: 5
    Dernier message: 15/04/2003, 11h51
  3. évaluateur de formule mathématique
    Par lyrau dans le forum Générateurs de compilateur
    Réponses: 5
    Dernier message: 28/03/2003, 22h50
  4. Coordonnées du curseur ???
    Par LE CHAKAL dans le forum Composants VCL
    Réponses: 3
    Dernier message: 27/08/2002, 17h28
  5. Implémentation des fonctions mathématiques
    Par mat.M dans le forum Mathématiques
    Réponses: 9
    Dernier message: 17/06/2002, 16h19

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo