Jump to content

Drawing Bezier Curves From An Array Of Points


blindwig
 Share

Recommended Posts

I've been working on graphics routines for my 360-degree Snake program, and I've been experimenting with bezier curves. It's kind of a pain to have to generate all those control points, so I wrote a routine to do it automatically. I thought someone else might like it, so I'll share it.

This routine would be useful to anyone who is doing line-graphics and wants them smoother, or for example if you are drawing a graph and want it to look more round and not so sharp.

The _PointDrawBezier() function is designed to draw open shapes, but with some modifications I can write another function better suited for closed shapes.

Anyway, have a look. The example is really easy to understand - it will ask you for a curve strength (just take the default of 0.5 for now) and then click on the screen to set the points. Once you have at least 4 point (3 points set, the mouse counts as a 4th), it can calculate the curve.

If you're curious to know where the control points are, then uncomment the 4 lines that have "$GUI_GR_DOT" in them.

Enjoy!

EDIT

Added a new version that also does closed figures.

Last version had 17 downloads.

MWR_beziers_20060511.zip

Edited by blindwig
Link to comment
Share on other sites

well done blindwig! Very nice...

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

OK I wrote a function that does closed figures.

The function is _PointDrawBezierClosed()

If the display is confusing, go to GraphRedraw() and comment out the routines you don't want to see.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...