Bonjour,
plus ou moins promis voilà le problème de la rotation d'un élément plus ou moins résolu, mais il va falloir m'expliquer ce que j'ai fini par trouver après moult tests
dans le projet (réduit) joint dans le zip je dessine cette fameuse hermine bretonne dont le fichier SVG est le suivant
Par tâtonnements successifs j'ai bien fini par l'obtenir en utilisant le code suivant
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 <?xml version="1.0" encoding="UTF-8"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1350" height="900"> <rect width="1350" height="900" fill="#aaa"/> <path d="M 300,167.5 l -9,-13.5 l 9,-22.5 l 9,22.5 z" fill="#000"/> <path d="M 300,167.5 l -9,-13.5 l 9,-22.5 l 9,22.5 z" fill="#000" transform="rotate(-90 300,167.5)"/> <path d="M 300,167.5 l -9,-13.5 l 9,-22.5 l 9,22.5 z" fill="#000" transform="rotate(90 300,167.5)"/> <path d="M 300,167.5 l 40.5,99 l -31.5,-13.5 l -9,18 l -9,-18 l -31.5,13.5 z" fill="#000"/> </svg>
Comme vous le constatez, j'applique trois étapes, un premier déplacement , négatif des coordonnées indiquées transform="rotate(-90 300,167.5)"
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 // je ne m'occupe pas du rectangle blanc procedure TForm80.btnHermineClick(Sender: TObject); var s : String; n : single; aP,al,ar : Tpath; // ap triangle haut, al triangle gauche, ar triangle droit M : TMatrix; begin ap:=Tpath.Create(Self); al:=Tpath.Create(Self); ar:=Tpath.Create(Self); try aP.Data.Data:='M 300,167.5 l -9,-13.5 l 9,-22.5 l 9,22.5 z'; al.Data.Data:=ap.Data.Data; ar.Data.Data:=ap.Data.Data; Path1.Fill.Color:=Talphacolors.Black; Path1.Data.Data:='M 300,167.5 l 40.5,99 l -31.5,-13.5 l -9,18 l -9,-18 l -31.5,13.5 z'; Path1.Data.AddPath(ap.data); m:=Tmatrix.CreateTranslation(-300,-167.5); al.data.applymatrix(m); M := TMatrix.CreateRotation(30); // angle normalement 90 al.data.applymatrix(m); M:=TMatrix.CreateTranslation(300,167.5); al.data.applymatrix(m); Path1.Data.AddPath(al.data); m:=Tmatrix.CreateTranslation(-300,-167.5); ar.data.applymatrix(m); M := TMatrix.CreateRotation(-30); // // angle normalement -90 ar.data.applymatrix(m); M:=TMatrix.CreateTranslation(300,167.5); ar.data.applymatrix(m); Path1.Data.AddPath(ar.data); finally ap.free; al.Free; ar.Free; end; end;
procède ensuite à une rotation mais avec la valeur 30 !
Puis refait un déplacement aux coordonnées
N.B. Le code est simplifiable en multipliant les matrices
simplifiant le "mystère" à l'explication de la transformation de 90° en 30 (expression en ?)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 M:=Tmatrix.CreateTranslation(-300,-167.5); M := M * TMatrix.CreateRotation(30); // angle normalement 90 M := M* TMatrix.CreateTranslation(300,167.5); // ou encore // M:=TMatrix.CreateTranslation(-300,-167.5) * TMatrix.CreateRotation(30) * TMatrix.CreateTranslation(300,167.5); al.data.applymatrix(M); Path1.Data.AddPath(al.data);
Ma trigonométrie est loin ...
[Edit] en fait je crois que convertir l'angle en radian est la solution
Partager