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 :

Comment faire un point [Flash Pascal]


Sujet :

Flash Pascal

  1. #1
    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 Comment faire un point
    Bonjour !

    Je voudrais savoir comment faire un point, autrement dit changer la couleur d'un "pixel" donné.

    A défaut d'une autre idée, j'ai essayé la combinaison
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    moveTo(a,b);
    lineTo(a,b);
    mais ça ne donne rien.

    Je voudrais, par exemple, tracer une droite à partir de son équation cartésienne.

    En Basic, c'est l'affaire d'une minute.

    Code vb : 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
    ' Programme FreeBasic
     
    screenres 800,800,16,,4
    color &h00000000, &h00FFFFFF
    cls
     
    line(0,400)-(799,400)
    line(400,0)-(400,799)
     
    dim as integer x,y
     
    for x=-400 to 399
     
      y = 3 * x + 2
     
      pset(400+x,800-(400+y)),&h00FF0000
     
    next x
     
    sleep
    end
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  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
    En action script, tu as :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    BitmapData.setPixel(x, y, couleur)
    mais je ne crois pas l'avoir vu dans flash8...

    A demander à Paul Toth pour qu'il l'intègre...

    @+

  3. #3
    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 Archimède Voir le message
    En action script, tu as :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    BitmapData.setPixel(x, y, couleur)
    mais je ne crois pas l'avoir vu dans flash8...
    Donc je ne rêvais pas.

    C'est étrange, je trouve, de pouvoir faire une ligne droite, un arc de cercle, et de ne pas pouvoir faire... un point.
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  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
    Il n'a pas eu le temps d'adapter toutes les méthodes d'actionScript... Elles sont très nombreuses.
    De même je cherchais de quoi faire des pointillés...dashdot.
    J'ai pensé me faire une routine pour l'obtenir mais j'attends un peu puisqu'elle existe...

    @+

  5. #5
    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
    sinon tu peux le faire avec realmovie. Tu gardes l'ossature et en trois quatre lignes, c'est fait...
    Ici j'ai deux movieclips au cas où j'ai besoin de faire des clear.
    Pour toi c'est inutile...

    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
     
    program Trace;
     
    {$FRAME_WIDTH   700}
    {$FRAME_HEIGHT  700}
    {$BACKGROUND $A6CAF0}
     
    uses Flash8,math;
     
    const  
      Pi   = 3.14159265359;
     
    type
     
     RealMovie = class(MovieClip)
       graph_width,graph_height:integer;
       xmin, xmax, ymin ,ymax , xsize ,ysize , Gx, Gy ,xo ,yo: number;  
       Arrow,courbe: Array of Point;
       Procedure RMoveTo(x,y:number);
       Procedure RLineTo(x,y:number);
       Procedure RLine(x1,y1,x2,y2:number);
       //Procedure RLineDashto(x1,y1,x2,y2:number);
       Procedure RPolyline;
       Procedure Rrectangle(x1,y1,x2,y2:number);
       Procedure RCircle(Cx,Cy,Radius:number);
       Procedure RCurveTo(x1,y1,x2,y2:number);
       procedure RArrow(x1,y1,x2,y2:number;col,penw:integer); //flèche
       procedure RArrow2(Fx,Fy,norme,alpha:number;col,penw:integer);//en coords polaires /alpha en °
      end;
     
     TGraphe=class(MovieClip)
      espace:Realmovie; //pour faire des clear en cas d'animation
      constructor Create;
     end;
     
    var tabmax:integer; 
     
    Function sqr(n:Double):Double;
    begin
     result:=n*n;
    end;
     
    Function FloattostrF(number:Double;digit:integer):String;
    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);
       if (frac2-frac1)*pow(10,digit+1)>=5 then newnumber:=int+frac1+pow(10,-digit) else newnumber:=int+frac1;
       result:=floattostr(newnumber);
    end;
     
    // Méthodes de dessin de Realmovie
    Procedure RealMovie.RMoveTo(x,y:number);
    begin
     Moveto(xo+x*Gx,yo-y*Gy);
    end;
     
    Procedure RealMovie.RLineTo(x,y:number);
    begin
     Lineto(xo+x*Gx,yo-y*Gy);
    end;
     
    Procedure RealMovie.RLine(x1,y1,x2,y2:number);
    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 do Rlineto(courbe[i].x,courbe[i].y);
    end;
     
    Procedure RealMovie.Rrectangle(x1,y1,x2,y2:number);
    begin
     RMoveto(x1,y1);
     RLineTo(x2,y1);
     RLineto(x2,y2);
     RLineto(x1,y2);
     RLineto(x1,y1);
    end;
     
    Procedure RealMovie.Rcircle(Cx,Cy,Radius:number); //si orthonormé
    var a,b,R: number;
    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:number;col,penw:integer);//flèche
    var i:integer;
        Norme,cX,cY: number;
        ALength,AWidth:number;  //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]:=Point.create(x2,y2);
      Arrow[1]:=Point.create(x2-cX*ALength+cY*AWidth,y2-cY*ALength-cX*AWidth);
      Arrow[2]:=Point.create(x2-cX*ALength-cY*AWidth,y2-cY*ALength+cX*AWidth);
      Arrow[3]:=Point.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:number;col,penw:integer);//Flèche en coords polaires
    var theta: number;
        L,L1: number;
        xf1,yf1 :number;
        xf2,yf2 :number;
        x,y : number;
    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:number);
    begin
     curveto(xo+x1*Gx,yo-y1*Gy,xo+x2*Gx,yo-y2*Gy);
    end;
    //fin méthodes realmovie 
     
     
    constructor TGraphe.Create;
    var x:integer;
    begin
     inherited Create(nil,'video',1);
      espace:=RealMovie.Create(SELF,'espace',1);
      espace._x:=0;
      espace._y:=0;
      espace.graph_width:=700;
      espace.graph_height:=700;
      espace.xmin:= -700;
      espace.xmax := 700;
      espace.ymin := -700;
      espace.ymax :=700;     
      espace.xsize:= espace.xmax -espace. xmin;
      espace.ysize:= espace.ymax - espace.ymin;
      espace.Gx   := espace.graph_width / espace.xsize;
      espace.Gy   := espace.graph_height/ espace.ysize;
      espace.xo   :=-espace.xmin * espace.Gx;
      espace.yo   :=espace. ymax * espace.Gy;
      //repère sans fleuriture
      espace.Rarrow(-700,0,700,0,$00000,2);
      espace.Rarrow(0,-700,0,700,$00000,2);
      //
     
      for x:=-700 to 699 do  espace.Rline(x,3*x+2,x+1,3*(x+1)+2); //ici pour le tracé sans fleuriture
     
    end;
     
    begin
      TGraphe.create;
    end.
    Ce qu'il faut, c'est de se faire des outils et de les réutiliser... on gagne du temps


    Rq : je n'ai pas adapté à une droite lol, ici deux points suffisent.
    un RLine suffit Rline(-700, fct(),700,fc())

  6. #6
    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
    En fait, tu veux pouvoir faire un truc comme ça en utilisant qu'un setpixel... ?

    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
     
    program Trace;
     
    {$FRAME_WIDTH   700}
    {$FRAME_HEIGHT  700}
    {$BACKGROUND $A6CAF0}
    {$FRAME_RATE 30}
     
    uses Flash8,math;
     
    const  
      Pi   = 3.14159265359;
     
    type
     
     RealMovie = class(MovieClip)
       graph_width,graph_height:integer;
       xmin, xmax, ymin ,ymax , xsize ,ysize , Gx, Gy ,xo ,yo: number;  
       Arrow,courbe: Array of Point;
       Procedure RMoveTo(x,y:number);
       Procedure RLineTo(x,y:number);
       Procedure RLine(x1,y1,x2,y2:number);
       //Procedure RLineDashto(x1,y1,x2,y2:number);
       Procedure RPolyline;
       Procedure Rrectangle(x1,y1,x2,y2:number);
       Procedure RCircle(Cx,Cy,Radius:number);
       Procedure RCurveTo(x1,y1,x2,y2:number);
       procedure RArrow(x1,y1,x2,y2:number;col,penw:integer); //flèche
       procedure RArrow2(Fx,Fy,norme,alpha:number;col,penw:integer);//en coords polaires /alpha en °
      end;
     
     TGraphe=class(movieclip)
      x:number;
      espace:Realmovie; //pour faire des clear en cas d'animation
      traj:array of Point;
      constructor Create;
      procedure onEnterFrame;
     end;
     
    var tabmax:integer; 
     
    Function sqr(n:Double):Double;
    begin
     result:=n*n;
    end;
     
    Function FloattostrF(number:Double;digit:integer):String;
    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);
       if (frac2-frac1)*pow(10,digit+1)>=5 then newnumber:=int+frac1+pow(10,-digit) else newnumber:=int+frac1;
       result:=floattostr(newnumber);
    end;
     
    // Méthodes de dessin de Realmovie
    Procedure RealMovie.RMoveTo(x,y:number);
    begin
     Moveto(xo+x*Gx,yo-y*Gy);
    end;
     
    Procedure RealMovie.RLineTo(x,y:number);
    begin
     Lineto(xo+x*Gx,yo-y*Gy);
    end;
     
    Procedure RealMovie.RLine(x1,y1,x2,y2:number);
    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 do Rlineto(courbe[i].x,courbe[i].y);
    end;
     
    Procedure RealMovie.Rrectangle(x1,y1,x2,y2:number);
    begin
     RMoveto(x1,y1);
     RLineTo(x2,y1);
     RLineto(x2,y2);
     RLineto(x1,y2);
     RLineto(x1,y1);
    end;
     
    Procedure RealMovie.Rcircle(Cx,Cy,Radius:number); //si orthonormé
    var a,b,R: number;
    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:number;col,penw:integer);//flèche
    var i:integer;
        Norme,cX,cY: number;
        ALength,AWidth:number;  //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]:=Point.create(x2,y2);
      Arrow[1]:=Point.create(x2-cX*ALength+cY*AWidth,y2-cY*ALength-cX*AWidth);
      Arrow[2]:=Point.create(x2-cX*ALength-cY*AWidth,y2-cY*ALength+cX*AWidth);
      Arrow[3]:=Point.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:number;col,penw:integer);//Flèche en coords polaires
    var theta: number;
        L,L1: number;
        xf1,yf1 :number;
        xf2,yf2 :number;
        x,y : number;
    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:number);
    begin
     curveto(xo+x1*Gx,yo-y1*Gy,xo+x2*Gx,yo-y2*Gy);
    end;
    //fin méthodes realmovie 
     
     
    constructor TGraphe.Create;
    begin
     inherited Create(nil,'mongraphe',1);
      espace:=RealMovie.Create(SELF,'espace',1);
      espace._x:=0;
      espace._y:=0;
      espace.graph_width:=700;
      espace.graph_height:=700;
      espace.xmin:= -10;
      espace.xmax := 10;
      espace.ymin := -10;
      espace.ymax :=10;     
      espace.xsize:= espace.xmax -espace. xmin;
      espace.ysize:= espace.ymax - espace.ymin;
      espace.Gx   := espace.graph_width / espace.xsize;
      espace.Gy   := espace.graph_height/ espace.ysize;
      espace.xo   :=-espace.xmin * espace.Gx;
      espace.yo   :=espace. ymax * espace.Gy;
      x:=espace.xmin;
      espace.Rarrow(-10,0,10,0,$00000,2);
      espace.Rarrow(0,-10,0,10,$00000,2);
    end;
     
    procedure TGraphe.onEnterFrame;
    begin
      if x<espace.xmax then 
      begin
       x:=x+0.5;
       espace.linestyle($00000,1);
       espace.RLine(x,3*x+2,x+0.5,3*(x+0.5)+2);
      end;
    end;
     
    begin
      TGraphe.create;
    end.

  7. #7
    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 Archimède Voir le message
    En fait, tu veux pouvoir faire un truc comme ça en utilisant qu'un setpixel... ?
    Oui, c'est exactement ça. Et c'est exactement ce que fait le petit bout de code en Basic que j'ai donné comme exemple.
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  8. #8
    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
    Cette méthode n'est présente que dans bitmapdata et pas directement dans movieclip en ActionScript...
    Donc il faudra encore s'adapter en faisant un beginBitmapFill ou un attachBitmap.
    Ce n'est pas très pratique.
    @+

  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
    En plus,si tu veux utiliser une simple boucle avec un sleep, celui-ci n'existe pas directement non plus. Il est nécessaire de se le faire avec setinterval()/clearinterval, un timer...Il faut lui demander de l'introduire aussi...

    @+

  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 430
    Points
    28 430
    Par défaut
    Hello, alors en effet le Pixel n'est pas géré par MovieClip qui ne s'intéresse qu'au vectoriel...or un point n'a pas d'épaisseur


    tu peux faire un tout petit carré..moveTo(0,0); lineTo(0,1); lineTo(1,1);, sinon il faut en effet utiliser BitmapData qui permet de gérer des Pixels, et il est affiché par attachBitmap ou beginFillBitmap
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  11. #11
    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
    Hello, alors en effet le Pixel n'est pas géré par MovieClip qui ne s'intéresse qu'au vectoriel...or un point n'a pas d'épaisseur


    tu peux faire un tout petit carré..moveTo(0,0); lineTo(0,1); lineTo(1,1);, sinon il faut en effet utiliser BitmapData qui permet de gérer des Pixels, et il est affiché par attachBitmap ou beginFillBitmap
    Merci, je vais regarder de ce côté-là. Je reviens vers vous avec un exemple de code, j'espère.
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  12. #12
    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
    Voici un premier essai. Le résultat me convient, donc je verrai plus tard le Bitmap.

    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
    program Exemple; { Trace une parabole }
    uses
      Flash8;
    {$FRAME_WIDTH 480}
    {$FRAME_HEIGHT 480}
    {$BACKGROUND $ffffff}
     
    procedure fPoint(xp,yp:Integer);
    { faux point }
    begin
      _root.moveTo(xp,yp);
      _root.lineTo(xp+1,yp+1);
    end;
     
    var x,y: Integer;
     
    begin
      _root.lineStyle(1,$999999);
      _root.moveTo(-200,   0);
      _root.lineTo(+200,   0);
      _root.moveTo(0   ,-200);
      _root.lineTo(0   ,+200);
     
      _root.lineStyle(1,$000000);
     
      for x:=-200 to 200 do
        begin
          y:=-floor((x*x)/100);
          fPoint(x,y);
        end;
     
      _root._x:=240;
      _root._y:=240;
    end.
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  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
    Salut
    Pour davantage de précision, tu peux te passer du floor étant donné que toutes les méthodes de dessin sont en number...

    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
     
    program Exemple; { Trace une parabole }
    uses
      Flash8;
    {$FRAME_WIDTH 480}
    {$FRAME_HEIGHT 480}
    {$BACKGROUND $ffffff}
     
    procedure fPoint(xp,yp:number);
    { faux point }
    begin
      _root.moveTo(xp,yp);
      _root.lineTo(xp+1,yp+1);
    end;
     
    var y: number;
        x:integer;
    begin
      _root.lineStyle(1,$999999);
      _root.moveTo(-200,   0);
      _root.lineTo(+200,   0);
      _root.moveTo(0   ,-200);
      _root.lineTo(0   ,+200);
     
      _root.lineStyle(1,$000000);
     
      for x:=-200 to 200 do
        begin
          y:=-x*x/100;
          fPoint(x,y);
        end;
     
      _root._x:=240;
      _root._y:=240;
    end.

  14. #14
    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 Archimède Voir le message
    Pour davantage de précision, tu peux te passer du floor étant donné que toutes les méthodes de dessin sont en number...
    Merci pour le coup d'œil.
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  15. #15
    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
    De rien, on ne voit pas toujours tout...
    Moi, le premier.

  16. #16
    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
    Voici un exemple un peu plus complet. On y voit une parabole, une droite, un arc de cercle, le tout tracé en "faux points".

    A votre avis, quelle différence cela ferait-il si j'utilisais un Bitmap ? Est-ce que ça vaut la peine ?

    Une fois que je serai sûr de tenir la bonne technique, je voudrais retravailler cet exemple afin d'obtenir un code réutilisable pour divers exercices de géométrie analytique.

    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
    program Exemple;
    uses
      Flash8, Math;
    {$FRAME_WIDTH 480}
    {$FRAME_HEIGHT 480}
    {$BACKGROUND $ffffff}
     
    procedure fPoint(xp,yp:Number);
    { faux point }
    begin
      _root.moveTo(xp,yp);
      _root.lineTo(xp+1,yp+1);
    end;
     
    var
      x,y: Number;
      angle: Number;
     
    const
      pi = 3.1415926535897932;
     
    begin
     
      // Repère
      _root.lineStyle(1,$000000);
      _root.moveTo(-200,   0);
      _root.lineTo(+200,   0);
      _root.moveTo(0   ,-200);
      _root.lineTo(0   ,+200);
     
      // Parabole
      _root.lineStyle(1,$F00000);
      x:=-200;
      while (x<200) do
        begin
          y:=-x*x/100;
          if abs(y)<200 then fPoint(x,y);
          x:=x+1;
        end;
     
      // Arc de cercle
      _root.lineStyle(1,$0000F0);  
      angle:=pi/2;
      while (angle<3*pi/2) do
        begin
          x := 200 + 100 * cos(angle);
          y :=   0 - 100 * sin(angle);
          fPoint(x,y);
          angle:=angle+pi/200;
        end;
     
       // Droite coupant le cercle
      _root.lineStyle(1,$F000F0);
      x:=-200;
      while (x<200) do
        begin
          y := -x / 2 + 30;
          // La droite change de couleur au moment où elle coupe le cercle
          if floor(sqrt((x-200)*(x-200) + y*y)) = 100 then _root.lineStyle(1,$00AA00);
          fPoint(x,y);
          x:=x+1;
        end;
     
      _root._x:=240;
      _root._y:=240;
    end.
    Fichiers attachés Fichiers attachés
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  17. #17
    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
    Pour l'instant, tu n'as pas la méthode setpixel dans Bitmapdata de flash 8... donc tu ne peux pas procéder comme tu voulais au départ.
    Sinon en plus, il te faudrait toutes les méthodes de dessin pour pouvoir construire quelque chose. Elles ne sont pas présentes dans Bitmapdata.
    A voir dans actionScript, mais je n'ai rien vu. Ce n'est pas une classe prévue je pense pour dessiner. En vectoriel, c'est plus rapide pour les animations.
    Puis, il faudrait refaire un attachbitmap pour l'affichage... donc pas d'iintérêt.
    retour à la case départ...

    @+

  18. #18
    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 Archimède Voir le message
    Pour l'instant, tu n'as pas la méthode setpixel dans Bitmapdata de flash 8... donc tu ne peux pas procéder comme tu voulais au départ.
    Sinon en plus, il te faudrait toutes les méthodes de dessin pour pouvoir construire quelque chose. Elles ne sont pas présentes dans Bitmapdata.
    A voir dans actionScript, mais je n'ai rien vu. Ce n'est pas une classe prévue je pense pour dessiner. En vectoriel, c'est plus rapide pour les animations.
    Puis, il faudrait refaire un attachbitmap pour l'affichage... donc pas d'iintérêt.
    retour à la case départ...

    @+
    D'accord, j'ai compris. Je viens de regarder dans Flash8: en effet ça ne peut pas faire mon affaire. Donc je reste sur cette base. Résolu!
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

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

Discussions similaires

  1. comment faire un set point dynamique sous simulink?
    Par saad449 dans le forum Simulink
    Réponses: 1
    Dernier message: 25/05/2013, 01h34
  2. Réponses: 10
    Dernier message: 04/08/2011, 21h21
  3. Réponses: 7
    Dernier message: 28/06/2007, 08h26
  4. Réponses: 5
    Dernier message: 20/04/2006, 11h31

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