Question

I'm currently using the GraphicsPath to add a curve into a graphic.

I'm not sure which object and how I should change to make the curve start from a point X, Y of my choice (instead of 0,0).

PointF[] p = // xxx the code to populate the array with points
GraphicsPath path = new GraphicsPath();
path.AddCurve(p);

using (var bitmap = new Bitmap(100, 100, PixelFormat.Format24bppRgb))
{
   using (var g = Graphics.FromImage(bitmap)) 
      g.DrawPath(Pens.White, path);

   MemoryStream ms = new MemoryStream();
   bitmap.Save(ms, ImageFormat.Png);
}

Which Object do i set the initial starting point, so that it does not start drawing the line from 0,0 ??

Thanks in advanced.

Was it helpful?

Solution

From MSDN GraphicsPath.AddCurve:

The curve begins at the point in the array specified by the offset parameter and includes the number of points (segments) specified by numberOfSegments.

http://msdn.microsoft.com/es-es/library/ms142523(v=vs.110).aspx

So if you use the overload without offset, you can asume offset is 0, so it will begin to draw at p[0]

If what you tried to mean is that you want to set a drawing offset (displace the coordinate system 0,0) then you can apply a transform with Graphics.TranslateTransform.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top