Précédent   Forum du club des développeurs et IT Pro > Autres langages > Pascal > Flash Pascal
Flash Pascal Forum d'entraide sur la création de fichiers Flash en Object Pascal
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 22/10/2012, 18h43   #1
Archimède
Membre émérite
 
Avatar de Archimède
 
Homme anthony
Enseignant
Inscription : avril 2005
Messages : 1 028
Détails du profil
Informations personnelles :
Nom : Homme anthony
Localisation : France, Charente Maritime (Poitou Charente)

Informations professionnelles :
Activité : Enseignant
Secteur : Enseignement

Informations forums :
Inscription : avril 2005
Messages : 1 028
Points : 979
Points : 979
Par défaut Ligne en pointillés

ci-joint, une tentative de ligne en pointillés :

Code :
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
 
program Project6;
 
{$FRAME_WIDTH 550}
{$FRAME_HEIGHT 400}
{$FRAME_RATE 12}
{$BACKGROUND $FFFFFF}
 
uses
  Flash8;
  var
      matrix1:Matrix;
 
begin
  matrix1:=matrix.create();
  matrix1.createGradientBox(10,10,math.pi/2,0,0);
  with _root do
  begin
   lineStyle(1);
   lineGradientStyle('linear',[$000000,$ffffff], [100,100],[20,100], matrix1,'repeat','linearRGB',0.9);
   moveTo(50,10);
   lineTo(300,10);
   lineto(300,260);
   lineto(50,260);
   lineto(50,10);
  end;
les lignes verticales sont en pointillés ...normal !.... en revanche, je suis obligé de mettre rotation à 0 pour avoir les lignes horizontales en pointillés aussi et je perds les lignes verticales... et ne parlons pas des obliques

dashdot n'est pas présent en as2...

comment faire pour contourner le problème ?

merci
__________________
Citation:
tout développeur plongé dans son code subit une poussée d'urticaire de bas en haut égale au poids du volume d'unités qu'il ajoute.
Archimède est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/10/2012, 21h30   #2
Archimède
Membre émérite
 
Avatar de Archimède
 
Homme anthony
Enseignant
Inscription : avril 2005
Messages : 1 028
Détails du profil
Informations personnelles :
Nom : Homme anthony
Localisation : France, Charente Maritime (Poitou Charente)

Informations professionnelles :
Activité : Enseignant
Secteur : Enseignement

Informations forums :
Inscription : avril 2005
Messages : 1 028
Points : 979
Points : 979
vite fait, dans l'instant, un truc adapté comme ça, c'est bon...
Code :
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
 
program Project7;
 
{$FRAME_WIDTH 550}
{$FRAME_HEIGHT 400}
{$FRAME_RATE 12}
{$BACKGROUND $FFFFFF}
 
uses
  Flash8,math;
 
procedure traitpointille(startx, starty, endx, endy, len, gap:number;mc:movieclip);
var seglength, deltax, deltay,delta, cx, cy,radians:number;
    n,segs:integer;
begin
// calculate the legnth of a segment
 seglength := len + gap;
// calculate the length of the dashed line
 deltax := endx - startx;
 deltay := endy - starty;
 delta :=sqrt((deltax * deltax) + (deltay * deltay));
// calculate the number of segments needed
 segs :=floor(abs(delta / seglength));
// get the angle of the line in radians
 radians := atan2(deltay,deltax);
// start the line here
 cx := startx;
 cy := starty;
// add these to cx, cy to get next seg start
 deltax :=cos(radians)*seglength;
 deltay :=sin(radians)*seglength;
// loop through each seg
 for  n :=0 to segs  do
 begin
  with mc do
  begin
   linestyle(1,$000000);
   moveTo(cx,cy);
   lineTo(cx+Math.cos(radians)*len,cy+Math.sin(radians)*len);
  end;
  cx :=cx+ deltax;
  cy :=cy+ deltay;
 end;
 mc.moveTo(cx,cy);
 delta :=sqrt((endx-cx)*(endx-cx)+(endy-cy)*(endy-cy));
 if(delta>len) then
 // segment ends in the gap, so draw a full dash
 mc.lineTo(cx+cos(radians)*len,cy+sin(radians)*len)
 else if(delta>0) then
 // segment is shorter than dash so only draw what is needed
 mc.lineTo(cx+Math.cos(radians)*delta,cy+Math.sin(radians)*delta);
// move the pen to the end position
 mc.moveTo(endx,endy);
end;
 
begin
 traitpointille(10,10,300,400,5,5,_root);
end.
__________________
Citation:
tout développeur plongé dans son code subit une poussée d'urticaire de bas en haut égale au poids du volume d'unités qu'il ajoute.
Archimède est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 22/10/2012, 21h42   #3
Archimède
Membre émérite
 
Avatar de Archimède
 
Homme anthony
Enseignant
Inscription : avril 2005
Messages : 1 028
Détails du profil
Informations personnelles :
Nom : Homme anthony
Localisation : France, Charente Maritime (Poitou Charente)

Informations professionnelles :
Activité : Enseignant
Secteur : Enseignement

Informations forums :
Inscription : avril 2005
Messages : 1 028
Points : 979
Points : 979
Par défaut avec un léger lifting...

Code :
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
 
{$FRAME_WIDTH 550}
{$FRAME_HEIGHT 400}
{$FRAME_RATE 12}
{$BACKGROUND $FFFFFF}
 
uses
  Flash8;
 
procedure traitpointille(startx, starty, endx, endy, len, gap:number;mc:movieclip);
var seglength, deltax, deltay,delta, cx, cy,radians:number;
    n,segs:integer;
begin
 seglength := len + gap;
 deltax := endx - startx;
 deltay := endy - starty;
 delta :=sqrt((deltax * deltax) + (deltay * deltay));
 segs :=floor(abs(delta / seglength));
 radians := atan2(deltay,deltax);
 cx := startx;
 cy := starty;
 deltax :=cos(radians)*seglength;
 deltay :=sin(radians)*seglength;
 for  n :=0 to segs  do
 begin
  with mc do
  begin
   moveTo(cx,cy);
   lineTo(cx+cos(radians)*len,cy+sin(radians)*len);
  end;
  cx :=cx+ deltax;
  cy :=cy+ deltay;
 end;
 mc.moveTo(cx,cy);
 delta :=sqrt((endx-cx)*(endx-cx)+(endy-cy)*(endy-cy));
 if delta>len then
 mc.lineTo(cx+cos(radians)*len,cy+sin(radians)*len)
 else if delta>0 then mc.lineTo(cx+cos(radians)*delta,cy+sin(radians)*delta);
 mc.moveTo(endx,endy);
end;
 
begin
 _root.linestyle(2,clblack);
 traitpointille(10,200,300,100,7,5,_root);
end.
__________________
Citation:
tout développeur plongé dans son code subit une poussée d'urticaire de bas en haut égale au poids du volume d'unités qu'il ajoute.
Archimède est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 22/10/2012, 21h57   #4
Paul TOTH
Expert Confirmé Sénior
 
Avatar de Paul TOTH
 
Homme Paul TOTH
Freelance
Inscription : novembre 2002
Messages : 4 409
Détails du profil
Informations personnelles :
Nom : Homme Paul TOTH
Âge : 43
Localisation : Réunion

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

Informations forums :
Inscription : novembre 2002
Messages : 4 409
Points : 10 782
Points : 10 782
en effet il n'y a pas d'effet standard pour cela

une autre solution aussi, tu gardes ta première méthode avec le lineGradientStyle mais tu dessines chaque ligne dans un nouveau MovieClip auquel tu appliques une rotation.

exemple, la fonction dot() qui fonctionne comme une tortue "logo" ... mais c'est surtout pour éviter les calculs, on pourrait très bien calculer d'après x1,y1,x2,y2 la position est l'angle de rotation de la ligne.

Code :
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
 
program Project1;
 
{$FRAME_WIDTH 550}
{$FRAME_HEIGHT 400}
{$FRAME_RATE 12}
{$BACKGROUND $FFFFFF}
 
uses
  Flash8;
 
var
  matrix1: Matrix;
  ox, oy : Number;
  om     : MovieClip;
 
procedure dot(a, l: Number);
var
  m: MovieClip;
begin
  m := MovieClip.Create(om, '', _root.getNextHighestDepth());
  with m do
  begin
   lineStyle(1);
   _x := ox;
   _y := oy;
   lineGradientStyle('linear',[$000000,$ffffff], [100,100],[20,100], matrix1,'repeat','linearRGB',0.9);
   lineTo(l,0);
   _rotation := a;
  end;
  ox := l;
  oy := 0;
  om := m;
end;
 
begin
  matrix1:=matrix.create();
  matrix1.createGradientBox(10,10,0,0,0);
  om := _root;
  ox := 100;
  oy := 100;
  dot(-30, 100);
  dot(+60, 100);
  dot(+60, 150);
  dot(+90, 175);
  dot(+90, 150);
  dot(+130, 240);
end.
__________________
Developpez.com: Mes articles, forum FlashPascal
Entreprise: Execute SARL
Produits : UPnP, RemoteOffice, FlashPascal
Embarcadero : Ile de la Réunion, Dephi, C++Builder, RADPHP...TVA à 8,5%
Paul TOTH est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 22/10/2012, 22h00   #5
Archimède
Membre émérite
 
Avatar de Archimède
 
Homme anthony
Enseignant
Inscription : avril 2005
Messages : 1 028
Détails du profil
Informations personnelles :
Nom : Homme anthony
Localisation : France, Charente Maritime (Poitou Charente)

Informations professionnelles :
Activité : Enseignant
Secteur : Enseignement

Informations forums :
Inscription : avril 2005
Messages : 1 028
Points : 979
Points : 979
Bravo , super bien vu !

merci, nickel
__________________
Citation:
tout développeur plongé dans son code subit une poussée d'urticaire de bas en haut égale au poids du volume d'unités qu'il ajoute.
Archimède est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/10/2012, 23h13   #6
Archimède
Membre émérite
 
Avatar de Archimède
 
Homme anthony
Enseignant
Inscription : avril 2005
Messages : 1 028
Détails du profil
Informations personnelles :
Nom : Homme anthony
Localisation : France, Charente Maritime (Poitou Charente)

Informations professionnelles :
Activité : Enseignant
Secteur : Enseignement

Informations forums :
Inscription : avril 2005
Messages : 1 028
Points : 979
Points : 979
oui, en effet, on pouvait le faire comme ceci :

Code :
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
 
program Project6;
 
{$FRAME_WIDTH 550}
{$FRAME_HEIGHT 400}
{$FRAME_RATE 12}
{$BACKGROUND $FFFFFF}
 
uses
  Flash8;
 
procedure dot(x1,y1,x2,y2:number;m:movieclip);
var theta:number;
    matrix1:Matrix;
begin
   theta:=atan2(y2-y1,x2-x1);
   matrix1:=matrix.create();
   matrix1.createGradientBox(10,10,theta,0,0);
 
   with m do
   begin
    lineGradientStyle('linear',[$000000,$ffffff], [100,100],[20,100], matrix1,'repeat','linearRGB',0.9);
    moveTo(x1,y1);
    lineTo(x2,y2);
   end;
end;
 
begin
  with _root do
  begin
   lineStyle(1,clblack);
   dot(50,50,350,50,_root);
   dot(350,50,350,350,_root);
   dot(50,350,350,350,_root);
   dot(50,350,50,50,_root);
   dot(50,50,350,350,_root);
   dot(50,350,350,50,_root);
  end;
 
end.
merci
__________________
Citation:
tout développeur plongé dans son code subit une poussée d'urticaire de bas en haut égale au poids du volume d'unités qu'il ajoute.
Archimède est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 23/10/2012, 06h34   #7
Paul TOTH
Expert Confirmé Sénior
 
Avatar de Paul TOTH
 
Homme Paul TOTH
Freelance
Inscription : novembre 2002
Messages : 4 409
Détails du profil
Informations personnelles :
Nom : Homme Paul TOTH
Âge : 43
Localisation : Réunion

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

Informations forums :
Inscription : novembre 2002
Messages : 4 409
Points : 10 782
Points : 10 782
ah oui encore mieux, je n'avais pas songé à jouer sur la matrice
__________________
Developpez.com: Mes articles, forum FlashPascal
Entreprise: Execute SARL
Produits : UPnP, RemoteOffice, FlashPascal
Embarcadero : Ile de la Réunion, Dephi, C++Builder, RADPHP...TVA à 8,5%
Paul TOTH est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 23/10/2012, 09h22   #8
Archimède
Membre émérite
 
Avatar de Archimède
 
Homme anthony
Enseignant
Inscription : avril 2005
Messages : 1 028
Détails du profil
Informations personnelles :
Nom : Homme anthony
Localisation : France, Charente Maritime (Poitou Charente)

Informations professionnelles :
Activité : Enseignant
Secteur : Enseignement

Informations forums :
Inscription : avril 2005
Messages : 1 028
Points : 979
Points : 979
Ceci dit l'inutilité du with et la répétition du _root n'est pas très judicieuse... Les neurones étaient en panne hier soir

Code :
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
 
program Project6;
 
{$FRAME_WIDTH 550}
{$FRAME_HEIGHT 400}
{$FRAME_RATE 12}
{$BACKGROUND $FFFFFF}
 
uses
  Flash8;
 
type
  pointille=class(movieclip)
   procedure dot(x1,y1,x2,y2:number);
  end;
 
 
 
procedure pointille.dot(x1,y1,x2,y2:number);
var theta:number;
    matrix1:Matrix;
begin
   theta:=atan2(y2-y1,x2-x1);
   matrix1:=matrix.create();
   matrix1.createGradientBox(10,10,theta,0,0);
   lineGradientStyle('linear',[$000000,$ffffff], [100,100],[20,100], matrix1,'repeat','linearRGB',0.9);
   moveTo(x1,y1);
   lineTo(x2,y2);
end;
 
var m:pointille;
 
begin
  m:= pointille.create(_root,'pointille',0);
  with m do
  begin
   lineStyle(1,clblack);
   dot(50,50,350,50);
   dot(350,50,350,350);
   dot(50,350,350,350);
   dot(50,350,50,50);
   dot(50,50,350,350);
   dot(50,350,350,50);
  end;
 
end.
Bonne journée et merci pour ton idée...
__________________
Citation:
tout développeur plongé dans son code subit une poussée d'urticaire de bas en haut égale au poids du volume d'unités qu'il ajoute.
Archimède est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Cette discussion est résolue.
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 00h34.


 
 
 
 
Partenaires

Hébergement Web