Table Of Contents

Graph IDEProgramming ► Cubic Bezier

The following is a complete script for programming a Cubic Bezier graphic. It computes a somewhat circular distribution of points.

/* Declarations */

double cos(double a);
double sin(double a);

@@class() CubicBezier:Object

@@method(public, class) (id)alloc;
@@method(public, instance) (id)init;
@@method(public, instance) (void)emptyData;
@@method(public, instance) (unsigned)animationCount;
@@method(public, instance) (void)appendXValue:(double)xValue yValue:(double)yValue;
@@method(public, instance) (void)release;

@@end

/* Execution block */

{
id myCubicBezier;
int ii;
double xValue, yValue;
unsigned animationCount;

myCubicBezier = [[CubicBezier alloc] init];

animationCount = [myCubicBezier animationCount];

printf("animationCount: %d\n", animationCount);

/*
Empty the data and then append new data.
*/

[myCubicBezier emptyData];

for(ii = 0; ii < 20; ii++)
{
red = (animationCount % 10) / 10.0;
green = (animationCount % 30) / 30.0;
blue = (ii % 20) / 20.0;
xValue = cos(ii * .02) + red * sin(ii * .01);
yValue = sin(ii * .02);

[myCubicBezier appendXValue:xValue yValue:yValue];
}

[myCubicBezier release];

}

The general API is define in the section Graphic. The following is API description specific to the Cubic Bezier graphic.

@@method(public, instance) (void)appendXValue:(double)xValue yValue:(double)yValue;
  Call like this:

[myCubicBezier appendXValue:xValue yValue:yValue];

Appends the x and y values to the list of data points for the graphic. The x and y values forms a 2D point. Each value must be of type double.

  @@method(public, instance) (void)emptyData;
  Call like this:

[myCubicBezier emptyData];

Removes (empties) all data from the graphic. Call this right before adding new data points.




© Copyright 1993-2019 by VVimaging, Inc. (VVI); All Rights Reserved. Please email support@vvi.com with any comments you have concerning this documentation. See Legal for trademark and legal information.