/*
This is an example script for a 2D scatter graphic. Click the Execute button to apply and then execute this script. Upon each execution the scatter alters its appearance. Turn on animation to execute periodically. Note that typically a scatter graphic should be instantiated on a graph data layer and the graph should be set to autoscale during animation.
*/

/* Declarations */

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

@@class() Scatter:Object

@@method(public, class) (id)stored;
@@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;

@@end

/* Execution block */

{
id myScatter;
int ii;
double xValue, yValue, radius, center, phase;
unsigned animationCount;
double red, green, blue;

myScatter = [Scatter stored];

animationCount = [myScatter animationCount];

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

[myScatter emptyData];

center = 4.0;
phase = animationCount * 0.1;

for(ii = 0; ii < 40; ii++)
{

radius = ii * 0.1;

red = 1.0;
green = (animationCount % 30) / 30.0;
blue = 1.0;
xValue = radius * cos(ii * .3 + phase) + center;
yValue = radius * sin(ii * .3 + phase) + center;

[myScatter appendXValue:xValue yValue:yValue];
[myScatter appendMarkerRed:red green:0.0 blue:blue alpha:1.0];
}

}
