#include <JSpline.h>
Public Member Functions | |
JSpline () | |
bool | Load (const char *filename, float xscale=1.0f, float yscale=1.0f) |
void | AddControlPoint (const Point &pt) |
void | GetControlPoint (Point &point, int index) |
void | GeneratePixels () |
void | PointOnCurve (Point &out, float t, const Point &p0, const Point &p1, const Point &p2, const Point &p3) |
int | GetPixelCount () |
void | GetPixel (Point &point, int index) |
void | Render (float x, float y, PIXEL_TYPE color=ARGB(255, 255, 255, 255), PIXEL_TYPE controlColor=ARGB(192, 0, 192, 0)) |
JSpline::JSpline | ( | ) |
Constructor.
bool JSpline::Load | ( | const char * | filename, | |
float | xscale = 1.0f , |
|||
float | yscale = 1.0f | |||
) |
Load spline from a file.
Here is a sample spline definition file:
<?xml version="1.0" standalone="no" ?> <path> <contro_point x="89" y="270" /> <contro_point x="113" y="154" /> <contro_point x="227" y="94" /> <contro_point x="347" y="154" /> <contro_point x="367" y="278" /> </path>
filename | - Name of spline definition file. | |
xscale | - Scaling factor for X of all control points. | |
yscale | - Scaling factor for Y of all control points. |
void JSpline::AddControlPoint | ( | const Point & | pt | ) |
Add a control point to the spline.
pt | - Control point. |
void JSpline::GetControlPoint | ( | Point & | point, | |
int | index | |||
) |
Get a control point of the spline.
index | - Control point index. |
void JSpline::GeneratePixels | ( | ) |
Work out all pixels of the spline.
void JSpline::PointOnCurve | ( | Point & | out, | |
float | t, | |||
const Point & | p0, | |||
const Point & | p1, | |||
const Point & | p2, | |||
const Point & | p3 | |||
) |
Get a point between 2nd and 3rd control point.
t | - Fraction of the curve between 2nd and 3rd control point. (0.0f ~ 1.0f) | |
p0 | - 1st control point. | |
p1 | - 2nd control point. | |
p2 | - 3rd control point. | |
p3 | - 4th control point. |
int JSpline::GetPixelCount | ( | ) |
Get a number of pixels for this spline.
void JSpline::GetPixel | ( | Point & | point, | |
int | index | |||
) |
Get a pixel on the spline.
index | - Pixel index. |
void JSpline::Render | ( | float | x, | |
float | y, | |||
PIXEL_TYPE | color = ARGB(255, 255, 255, 255) , |
|||
PIXEL_TYPE | controlColor = ARGB(192, 0, 192, 0) | |||
) |
Render the spline to screen.