Rank: Member
Groups: Registered
Joined: 9/19/2019(UTC) Posts: 18  Location: Landshut Thanks: 1 times
|
Hello, i have seen how i can add lines and rectangles to the pageobjects. But how can i add rounded shapes like elypse etc. my way to add a line : Code:
/// <summary>erzeugt ein PathObjekt mit einer Linie</summary>
/// ''' <param name="x1">X-Koordinate im PDF (von links)</param>
/// ''' <param name="y1">Y-Koordinate im PDF (von unten)</param>
/// ''' <param name="x2">y-Koordinate im PDF (von links)</param>
/// ''' <param name="y2">Y-Koordinate im PDF (von unten)</param>
/// ''' <param name="fillFS_COLOR">Patagames.Pdf.FS_COLOR (Farbe)</param>
/// ''' <returns>Patagames.Pdf.Net.PdfPathObject</returns>
public Patagames.Pdf.Net.PdfPathObject InsertLine(float x1, float y1, float x2, float y2, Patagames.Pdf.FS_COLOR fillFS_COLOR)
{
Patagames.Pdf.Net.PdfPathObject pathObject = Patagames.Pdf.Net.PdfPathObject.Create(Patagames.Pdf.Enums.FillModes.Alternate, false);
pathObject.FillColor = fillFS_COLOR;
pathObject.Path.Add(new Patagames.Pdf.FS_PATHPOINTF(x1, y1, Patagames.Pdf.Enums.PathPointFlags.MoveTo));
pathObject.Path.Add(new Patagames.Pdf.FS_PATHPOINTF(x2, y2, Patagames.Pdf.Enums.PathPointFlags.LineTo));
pathObject.Path.Add(new Patagames.Pdf.FS_PATHPOINTF(x1, y1, Patagames.Pdf.Enums.PathPointFlags.CloseFigure | Patagames.Pdf.Enums.PathPointFlags.LineTo));
return pathObject;
}
Christian
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 844
Thanks: 2 times Was thanked: 103 time(s) in 101 post(s)
|
Hello, You should use Bezier curve to achieve this Code:foreach (var point in AnnotDrawing.GetCirclePoints(rect, lineWidth))
path.Path.Add(point);
Code:/// <summary>
/// Get points for a circle
/// </summary>
/// <param name="rect">Rectangle in which the figure should be inscribed.</param>
/// <param name="lineWidth">The line width.</param>
/// <returns>A Collection of points of this figure.</returns>
public static List<FS_PATHPOINTF> GetCirclePoints(FS_RECTF rect, float lineWidth)
{
rect = InflateRect(rect, -lineWidth / 2);
var ret = new List<FS_PATHPOINTF>();
float x = rect.left + rect.Width / 2;
float y = rect.bottom + rect.Height / 2;
float w = rect.Width;
float h = rect.Height;
var width_over_2 = w / 2;
var width_two_thirds = w * 2 / 3;
var height_over_2 = h / 2;
ret.Add(new FS_PATHPOINTF(x, y + height_over_2, PathPointFlags.MoveTo));
ret.Add(new FS_PATHPOINTF(x + width_two_thirds, y + height_over_2, PathPointFlags.BezierTo));
ret.Add(new FS_PATHPOINTF(x + width_two_thirds, y - height_over_2, PathPointFlags.BezierTo));
ret.Add(new FS_PATHPOINTF(x, y - height_over_2, PathPointFlags.BezierTo));
ret.Add(new FS_PATHPOINTF(x - width_two_thirds, y - height_over_2, PathPointFlags.BezierTo));
ret.Add(new FS_PATHPOINTF(x - width_two_thirds, y + height_over_2, PathPointFlags.BezierTo));
ret.Add(new FS_PATHPOINTF(x, y + height_over_2, PathPointFlags.BezierTo | PathPointFlags.CloseFigure));
return ret;
}
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close