PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

Trying to better understand coordinates
http://forum.pdfsharp.com/viewtopic.php?f=2&t=2753
Page 1 of 1

Author:  frankpytel [ Mon Mar 03, 2014 2:52 pm ]
Post subject:  Trying to better understand coordinates

Hello;

Using PDFsharp GDI+ with VS2010. Not sure of the PDFsharp version but the Copyright is 2005-2009.

I'm trying to get a better handle on coordinates when drawing paths and lines. My first question is how are these numbers measured? That is, what are these doubles I'm putting into the following code? mm? pixels? in-ft?

From Sample Code:

Code:

 XPen pen = new XPen(XColors.Black, 0.0);

            XGraphicsPath path = new XGraphicsPath();

            // Winding fill mode
            path = new XGraphicsPath();
            path.FillMode = XFillMode.Winding;
            path.AddLine([b][u]5.0, 25.0, 30.0, 12.0[/u][/b]);
           
            // First two Numbers = bottom left
            // Second two Numbers = top left

            //path.AddBeziers(new XPoint[]{new XPoint(130, 40), new XPoint(150, 0), new XPoint(160, 20), new XPoint(180, 40),
                                   //new XPoint(200, 60), new XPoint(220, 60), new XPoint(240, 40)});
            path.AddLine([b][u]35.0, 20.0, 5.0, 45.0[/u][/b]);

            // First two numbers = Top Right
            // Second two numbers = btm right

            path.CloseFigure();
            //path.AddEllipse(160, 80, 50, 40);
            gfx.DrawPath(pen, XBrushes.Silver, path);



As you can see I've taken out the Beziers and Ellipse. I'm trying to create a polygon. I understand (I think) that the CloseFigure() is taking the two (+/-) vertical lines and connecting the dots.

My second question is, I have a polygon with up to 12 points. Basically I'm creating block letters from scratch. There will be two letters nested together and they are block, not curved at all. How many of these AddLine(x,x,x,x); can I add to this XGraphicsPath();? I can make 4 points work, but sure would like to have more available to me.

My last question is where is 0.0,0.0 relative to the paperspace?

I've looked on the forum search and the new site for more details. Any direction you could provide would be deeply appreciated.

Thank You. Frank Pytel

Author:  frankpytel [ Mon Mar 03, 2014 8:45 pm ]
Post subject:  Re: Trying to better understand coordinates

It's more than likely me, but I figured this out. For any other newbs with the same question.

Point/Points is/are a part of C# and not a part of PDFsharp (I think. Sort of?!?)

Anyway, the first point in the coordinates or array is the first point on the paper and as near as I can tell they travel clockwise from there. Or at least that's how I had to look at it.

What I ended up doing was to just create a line with one (Pixel?!? Still don't understand the points as you have to put in 1 more as shown below. Not sure what 1 is)

Code:

// Creates a RED point. Coordinate 1 & 2 (x(Left to Right),y(Top Down))

            //XPen pen2 = new XPen(XColors.Red, 0.25);
            //XPoint[] points =
            //  new XPoint[] { new XPoint(18.0, 24.0), new XPoint(18.0, 25.0) };
            //gfx.DrawLines(pen2, points);



The red dot is how I tracked what was going around the paper space. I get one set where I like it and set the second coordinate and the red dot simultaneously. That helped.

Have a Great Day!! Newbs Rule!! :twisted: :twisted: :twisted:

Author:  Thomas Hoevel [ Tue Mar 04, 2014 9:47 am ]
Post subject:  Re: Trying to better understand coordinates

PDF is a vector format and has no pixels - a line of length 0 will not show.
Co-ordinates are points (1 point = 1/72 inch).

See also:
viewtopic.php?p=2979#p2979
viewtopic.php?p=5907#p5907

Author:  frankpytel [ Tue Mar 04, 2014 10:31 am ]
Post subject:  Re: Trying to better understand coordinates

Awesome. Thank You Thomas. That will help immensely

Frank Pytel

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/