Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Bezier curve class — Gideros Forum

Bezier curve class

NiicodemusNiicodemus Member
edited May 2013 in Code snippets
I just finished some work on a new Bezier class based on Paul Burke's algorithm, but with a couple interesting additions in the form of automatic step-estimation, and also algorithmic reduction of extra points based on the Ramer-Douglas-Peucker algorithm. The end result is Bezier curves with only the exact number of points needed to be rendered smoothly. I have full details on my blog if anyone is interested.

http://blog.lotech.org/2013/05/implementing-better-bezier-class-in.html

And the code at GitHub, including a demo/testing project to see it in action.

https://github.com/nshafer/Bezier

Hopefully it's useful to someone.

Thanks,
Nathan Shafer
+1 -1 (+5 / -0 )Share on Facebook

Comments

  • @Niicodemus, hey I've got an immediate use for this, thanks. I'll let you know when I've got something to show for it.

    Incidentally, that blog theme you use (I think it's the same as the one used by @OzApps) plays havoc when viewed on an IPad.

    Best regards
  • This should very helpful!
  • OZAppsOZApps Guru
    edited May 2013
    Incidentally, that blog theme you use (I think it's the same as the one used by @OzApps) plays havoc when viewed on an IPad.
    I think that is the Dynamic view by Google, it restricts/messes up a few other plug-ins too. I could not get the Syntax Highlighter working since I changed to the Dynamic view, but it looks much better than the static views.

    I will check if something can be done about fixing that on the iPad as there are two templates one for Mobile and one for the desktops.

    Update: On my iPad, I can see the howto.oz-apps.com render perfectly fine, so I am confused on what is the issue of it not rendering properly on an iPad. Are you using the Mobile theme by any chance?
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
  • @OZApps, yes, I've just checked again and your site does seem better than I remember it.

    I find it a bit weird that it has these dual scroll bars and that the width is wider than the iPad screen (and it can't be zoomed to fit) but, apart from that, the rendering seems fine. Sorry for the false alarm.

    best regards
  • loucsamloucsam Member
    What are some practical examples of using these Bezier curves?
  • @loucsam, any where you need a curve, really. Bezier curves are the most efficient and compact way to describe a curve. You only need 3 or 4 points, and it will do the rest. You could draw them to the screen as the most basic usage. Beyond that, you could just calculate all the points in the curve, then use those points to guide sprites around by tweening them to each point in turn. You could do that for any type of graphical element, such as titles, characters, enemies, missiles, etc. Or you could use the points to draw Box2D bodies for physics.

    The practical reason I wrote this class is that I use it as part of an SVG Parser I'm working on, and SVG uses bezier paths extensively. I use the class to either draw the shapes on screen or create physics bodies from them, or both.
  • loucsamloucsam Member
    Thanks @Niicodemus, helpful response, that was what I needed to understand.

    Cheers,
    Max
Sign In or Register to comment.