jingwood / d2dlib

A .NET library for hardware-accelerated, high performance, immediate mode rendering via Direct2D.
MIT License
234 stars 40 forks source link

Open path #52

Open mystery123sk opened 3 years ago

mystery123sk commented 3 years ago

The library is fantastic, thank you for that. I have a little problem with the ClosePath - I can't specify, whether the path should be opened or closed (as it is possible using D2D1_FIGURE_END in D2D). It's impossible to draw bezier cubic curves like this (the first point is always connected to end point).

Also there is a crash/hang, when I don't call ClosePath and I'm trying to draw geometry. E.g.:

var path = crc.GR.Device.CreatePathGeometry();
path.SetStartPoint(new D2DPoint(0, 0.5f));

D2DBezierSegment seg1 = new D2DBezierSegment()
{
  point1 = new D2DPoint(0.25f, 0),
  point2 = new D2DPoint(0.75f, 1),
  point3 = new D2DPoint(1, 0.5f),
};
path.AddBeziers(new D2DBezierSegment[] { seg1 });
path.ClosePath(); //if I don't add this line, the application hangs

graphics.DrawPath(path, D2DColor.AliceBlue, 2 * pixelSize);
jingwood commented 3 years ago

Thanks! @mystery123sk, hope it helps you.

Can you please provide an image that shows your desired result? I'd like to test with your requirement.

mystery123sk commented 3 years ago

image

The problem is, I want to draw non-closed polygon/bezier line. It's not possible using your library functions. The library draws always last point connected to first one.