Table Of Contents

Graph IDEProgramming ► Trajectory

The following is a complete script for programming a Trajectory graphic. It computes a somewhat circular distribution of points and also assigns a bubble value. For this to work, the trajectory graphic must have been made with a point tag marker.

/* Declarations */

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

@@class() Trajectory: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)setCurveRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha;
@@method(public, instance) (void)appendBubbleValue:(double)aValue;
@@method(public, instance) (void)appendMarkerRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha;
@@method(public, instance) (void)release;

@@end

/* Execution block */

{
id myTrajectory;
int ii;
double xValue, yValue;
unsigned animationCount;
double red, green, blue;

myTrajectory = [[Trajectory alloc] init];

animationCount = [myTrajectory animationCount];

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

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

[myTrajectory 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);

[myTrajectory appendXValue:xValue yValue:yValue];
[myTrajectory appendMarkerRed:red green:green blue:blue alpha:1.0];
[myTrajectory appendBubbleValue:(ii * 1.0)];
}

[myTrajectory release];

}

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

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

[myTrajectory 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)appendMarkerRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha;
  Call like this:

[myTrajectory appendMarkerRed:0.5 green:0.4 blue:1.0 alpha:1.0];

That appends the marker color to the red, green, blue and alpha values of 0.5, 0.4, 1.0 and 1.0 respectively. Those values must be between 0.0 and 1.0. An alpha of 0.0 is transparent while 1.0 is completely opaque. Each argument must be a number literal or a variable (or expression) of type double. Note that this call must accompany a appendXValue:xValue yValue: call in order to synchronize the parameters that depend upon sequence index.

@@method(public, instance) (void)appendSegmentRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha;
  Call like this:

[myTrajectory appendSegmentRed:0.5 green:0.4 blue:1.0 alpha:1.0];

That appends the segment color to the red, green, blue and alpha values of 0.5, 0.4, 1.0 and 1.0 respectively. Those values must be between 0.0 and 1.0. An alpha of 0.0 is transparent while 1.0 is completely opaque. Each argument must be a number literal or a variable (or expression) of type double. Note that this call must accompany a appendXValue:xValue yValue: call in order to synchronize the parameters that depend upon sequence index.

@@method(public, instance) (void)appendBubbleValue:(double)aValue;
  Call like this:

[myTrajectory appendBubbleValue:aValue];

Appends aValue to the list of bubble values for the graphic. aValue must be of type double.

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

[myTrajectory emptyData];

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




© Copyright 1993-2022 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.