logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

New Topic Post Reply
Options
Go to last post Go to first unread
Bazi  
#1 Posted : Tuesday, November 5, 2019 10:31:49 AM(UTC)
Quote
Bazi

Rank: Member

Groups: Registered
Joined: 9/19/2019(UTC)
Posts: 21
Germany
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
Paul Rayman  
#2 Posted : Wednesday, November 6, 2019 2:39:02 AM(UTC)
Quote
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,138

Thanks: 10 times
Was thanked: 133 time(s) in 130 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;
}



Quick Reply Show Quick Reply
Users browsing this topic
Guest
New Topic Post Reply
Forum Jump  
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.