Bonjour
Je sais que certains me considèrent comme le plus pointu sur les Tpaths mais il y a encore beaucoup de choses qui m'échappent.
Je veux dessiner un polygone
Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 <svg viewBox="0 0 200 100" xmlns="http://www.w3.org/2000/svg"> <!-- Exemple d'un polygone avec le remplissage par défaut --> <polygon points="0,100 50,25 50,75 100,0" /> </svg>
Seulement voilà mon résultat n'est pas bon , tout d'abord il est "à l'envers"
![]()
et il prend tout l'espace au lieu d'être limité à la zone comme le montre les deux composants tiers
c'est encore plus flagrant avec
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 procedure TLoadSVGForm.SVGPolygone(aNode: IXMLNode; LytParent: TLayout; F : TBrush=nil; S : TStrokeBrush=nil); var val : String; vals,vpoint : TArray<String>; aPoint : TPointF; i : Integer; ChildPath : Tpath; begin ChildPath:=TPath.Create(lytParent); ChildPath.Parent:=lytParent; ChildPath.WrapMode:=TPathWrapMode.Stretch; ChildPath.Align:=TAlignLayout.Contents; val:=Trim(anode.Attributes['points']); // retire la mise en forme val:=StringReplace(val,#$A,' ',[rfReplaceAll]); val:=Trim(val); // pour être sur de commencer avec le premier point vals:=val.Split([' ']); for I := Low(vals) to High(vals) do begin if not vals[i].isempty then // c'est un point begin vpoint:=Vals[i].Split([',']); aPoint:=TPointF.Zero; aPoint.y:=StrToFloatDef(vpoint[0],0,USFormatSettings); aPoint.x:=StrToFloatDef(vpoint[1],0,USFormatSettings); if i>0 then ChildPath.Data.LineTo(aPoint) else ChildPath.Data.MoveTo(aPoint); end; end; ChildPath.Data.ClosePath; end;
Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 <svg viewBox="0 0 200 100" xmlns="http://www.w3.org/2000/svg"> <!-- Exemple d'un polygone avec le remplissage par défaut --> <polygon points="0,100 50,25 50,75 100,0" /> <!-- Le même polygone sans remplissage et avec un contour --> <polygon points="100,100 150,25 150,75 200,0" fill="none" stroke="red" /> </svg>
Jouer sur ChildPath.WrapMode ne fonctionne pas.
Partager