Script:Bézier curves

From Spherical
Revision as of 20:12, 16 March 2013 by Apollolux (talk | contribs) (Download and Usage)
Jump to: navigation, search

Bézier curves is a custom script written by NeoLogiX. It is a script that ultimately takes four points and draws a Bézier curve. A later update which has not yet been posted stores the points on the line into a sorted array for future use, i.e. a curved path to make an object travel.

Download and Usage

Getting Started

The source code to generate the curve is at the bottom of this page. Simply copy and paste into the script file of your choice and include it.

API

Object NPoint(int x, int y)
a VERY necessary object for convenience in this code. You COULD write this code using separate variables for each point's x and y, but it would look very messy.
NPoint midpoint(NPoint p1, NPoint p2)
returns the midpoint of two NPoints as an NPoint.
Array killseqduppts(Array arr)
returns an array of NPoints with sequential duplicates removed.
Array BezierLine(NPoint p1, NPoint p2, NPoint p3, NPoint p4, Color col, bool dot, int num)
blits the actual Bézier curve on the screen. p2 is the control point for p1, p3 is the control point for p4, col is the color of the line, dot determines whether the curve is a solid curve or a dotted line curve, and num is an extra level of infinite recursion protection; returns the line as an array of NPoints as well.