https://issues.apache.org/ooo/show_bug.cgi?id=124084
JP CASSOU <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|CONFIRMED |RESOLVED Resolution|--- |FIXED --- Comment #14 from JP CASSOU <[email protected]> --- The good method for drawing Bezier uses the following steps: // ViewBox must be used // Steps: // 1 - Calculate viewbox parameters // -- Find maxi et mini of the points control // --> obtaining ViewBoxX, ViewBoxY, ViewBoxL, ViewBoxH // 2 - Translate all points with tx = -ViewBoxX et ty = -ViewBoxY // 3 - Draw curve with avec svg:x="<ViewBoxX>", // svg:y="<ViewBoxY>", // svg:width="<ViewBoxL>", // svg:height="<ViewBoxH>", // svg:viewBox="0, 0, <ViewBoxL>, <ViewBoxH>", See the following code ======================== procedure Todg.DessinPolyBezier(const QStyle: string; var BezierArcs: array of TBezierArc; const QClosed, QFilled: boolean); const FM1 = '%.0f, %.0f '; var ViewBoxX, ViewBoxY, ViewBoxL, ViewBoxH: TScalaire; BB_X1, BB_Y1, BB_X2, BB_Y2: TScalaire; Qx1, Qy1, Qx2, Qy2: TScalaire; i:integer; coords: String; sname: String; EWE: TBezierArc; WU: String; // translater les arcs pour les mettre dans la ViewBox procedure TranslaterArcs; var BBCx1, BBCy1, BBCx2, BBCy2 : TScalaire; MonArc: TBezierArc; A: Integer; procedure Miou(const qx, qy: TScalaire); begin BBCx1 := min(qx, BBCx1); BBCx2 := max(qx, BBCx2); BBCy1 := min(qy, BBCy1); BBCy2 := max(qy, BBCy2); end; begin // Etape 1: Calcul des min/max BBCx1 := +BIGMAX; BBCy1 := +BIGMAX; BBCx2 := -BIGMAX; BBCy2 := -BIGMAX; for A := 0 to High(BezierArcs) do begin MonArc := BezierArcs[A]; Miou(MonArc.P1.X, MonArc.P1.y); Miou(MonArc.PC1.X, MonArc.PC1.y); Miou(MonArc.PC2.X, MonArc.PC2.y); Miou(MonArc.P2.X, MonArc.P2.y); end; // Etape 2: Paramétrage des viexbox ViewBoxX := BBCx1; ViewBoxY := BBCy1; ViewBoxL := BBCx2 - BBCx1; ViewBoxH := BBCy2 - BBCy1; // Etape 3: Translation for A := 0 to High(BezierArcs) do begin MonArc := BezierArcs[A]; MonArc.P1.X := MonArc.P1.X - ViewBoxX; MonArc.P1.Y := MonArc.P1.Y - ViewBoxY; MonArc.PC1.X := MonArc.PC1.X - ViewBoxX; MonArc.PC1.Y := MonArc.PC1.Y - ViewBoxY; MonArc.PC2.X := MonArc.PC2.X - ViewBoxX; MonArc.PC2.Y := MonArc.PC2.Y - ViewBoxY; MonArc.P2.X := MonArc.P2.X - ViewBoxX; MonArc.P2.Y := MonArc.P2.Y - ViewBoxY; BezierArcs[A] := MonArc; end; end; procedure DrawArc2(var QCoords: string; const BA: TBezierArc; const Idx: integer); begin if (Idx = 0) then QCoords += Format('M ' + FM1, [BA.P1.X, BA.P1.Y]); QCoords += Format('C ' + FM1, [BA.PC1.X, BA.PC1.Y]); QCoords += Format(FM1, [BA.PC2.X, BA.PC2.Y]); QCoords += Format(FMT_2V_CMM, [BA.P2.X, BA.P2.Y]); end; Begin Inc(FNbCourbesBeziers); // Pour dessiner un Polybezier, il est nécessaire d'utiliser ViewBox // Etapes: // 1 - Calculer les paramètres de la viewbox // -- Rechercher les maxi et mini des points de controle // --> on obtient ViewBoxX, ViewBoxY, ViewBoxL, ViewBoxH // 2 - Translater les points avec tx = -ViewBoxX et ty = -ViewBoxY // 3 - Tracer la courbe avec svg:x="<ViewBoxX>", // svg:y="<ViewBoxY>", // svg:width="<ViewBoxL>", // svg:height="<ViewBoxH>", // svg:viewBox="0, 0, <ViewBoxL>, <ViewBoxH>", // calcul des translations TranslaterArcs; // composition du texte à passer en paramètre de path="" if (QFilled) then coords := 'M 0 0 Z ' // tout polygone (ou courbe) rempli est encadré de deux Z en début et en fin de chemin else coords := 'M 0 0 '; // Le Z de tête indique que l'objet est rempli // Le Z de queue indique qu'il est fermé // L'objet n'est rempli que s'il y a un Z de queue for i := 0 to High(BezierArcs) do begin EWE := BezierArcs[i]; DrawArc2(coords, EWE, i); end; // polygone fermé ? if (QClosed) then coords += 'z'; // début de la chaine de paramètres WU := ''; AddAttribute(WU, 'draw:style-name', QStyle, false); AddAttribute(WU, 'draw:name', Format('Polybezier%d', [FNbCourbesBeziers]),false); AddAttribute(WU, 'svg:x' , Format(FMT_CMM, [ViewBoxX]), false); AddAttribute(WU, 'svg:y' , Format(FMT_CMM, [ViewBoxY]), false); AddAttribute(WU, 'svg:width' , Format(FMT_CMM, [ViewBoxL]), false); AddAttribute(WU, 'svg:height' , Format(FMT_CMM, [ViewBoxH]), false); AddAttribute(WU, 'svg:viewBox' , Format(FMT_4V_CMM, [0.0, 0.0, ViewBoxL, ViewBoxH]), false); AddAttribute(WU, 'svg:d', coords, false); BeginSection(FPointerToFileContent, 5, 'draw:path', WU); WriteLnUTF8(FPointerToFileContent, StringOfChar(' ', 6 * 2) + '<text:p/>'); EndSection(FPointerToFileContent, 5, 'draw:path'); // move to last point for further painting with lineto DessinMoveTo(EWE.P2.x, EWE.P2.y); end; -- You are receiving this mail because: You are on the CC list for the bug. You are watching all bug changes.
