Jump to content

Graphics.DrawBeziers(Pen pen, Point[] points) doesn't seem to work


Moonpile
 Share

Recommended Posts

Is there any work around to use that method? 

 

I get (and I had to type this, is there any way to copy exceptions out of CodeLab?):
 

System.ArgumentException: Parameter is not valid

at System.Drawing.Graphics.CheckErrorStatus(Int32 status)

at System.Drawing.Graphics.DrawBeziers(Pen pen, Point[] points)

at PaintDotNet.Effects.UserScripts.Render(.....)

 

I built a List<Point>

 

then did

Point[] pointsArr = points.ToArray();

g.DrawBeziers(myPen, pointsArr);

Link to comment
Share on other sites

How may points are in your Point Array?

 

Due to the nature of Bezier Curves, they need to have a multiple of Three plus One.

EX: 4, 7, 10, 13, 16, ect.

 

 

You can use any amount of Points with Spline Curves, but of course they behave differently compared to Bezier Curves.

Edited by toe_head2001
Link to comment
Share on other sites

DrawBeziers works with an array of PointFs.

You may (or may not) find the source code here useful.

http://forums.getpaint.net/index.php?/topic/26464-bentley-beta-for-bezncurve-update/

 

I can upload the original codelab version if that's easier.

 

Red ochre Plugin pack.............. Diabolical Drawings ................Real Paintings

 

PdnForumSig2.jpg

Link to comment
Share on other sites

How may points are in your Point Array?

 

Due to the nature of Bezier Curves, they need to have a multiple of Three plus One.

EX: 4, 7, 10, 13, 16, ect.

 

 

You can use any amount of Points with Spline Curves, but of course they behave differently compared to Bezier Curves.

 

This was definitely my problem.  Wow, DrawBeziers does not fail gracefully with the wrong number of elements in that array!

DrawBeziers works with an array of PointFs.

You may (or may not) find the source code here useful.

http://forums.getpaint.net/index.php?/topic/26464-bentley-beta-for-bezncurve-update/

 

I can upload the original codelab version if that's easier.

 

Looks like there's actually a signature for an array of Points or PointF.

Link to comment
Share on other sites

It's not supposed to fail gracefully. The documentation says the requirements for the arguments, you didn't meet them, and because the method can't draw beziers from invalid input, it threw an exception.

 

The alternative is to fail silently and then have mysteriously blank output that is completey undebuggable when working at a medium to larger scale of code.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

System.Drawing is pretty vague when it comes to error descriptions. It's a wrapper around GDI+ and doesn't attempt to provide any extra detail beyond mapping error codes to exception types.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

I haven't done a whole lot with System.Drawing before, so I'll keep an eye on the documentation.

 

I see that while you can just draw what you want, it looks like the more accepted way for a Paint.NET plugin to work is to set values dot by dot in the nested loops anyway.

Link to comment
Share on other sites

You can use GDI+ if you want, there's nothing "wrong" with it. It just depends on what you want to do. GDI+ won't be able to do lots of the more interesting stuff; it's primarily suited for drawing geometry, text, and some types of gradients.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...