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

/* Declaration blocks */

double sin(double a);

@@class() Function: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;

@@end

/* Execution block */

{
id myFunction;
int ii;
double xValue, yValue;
double offset, amplitude, xDelta;
unsigned animationCount;

myFunction = [Function stored];

animationCount = [myFunction animationCount];

[myFunction emptyData];

xDelta = 0.02;
offset = 8.0;
amplitude = 100.0;

for(ii = 0; ii < 500; ii++)
{
xValue = xDelta * ii + offset;
yValue = amplitude * sin(xValue + animationCount * 0.18) + offset;
[myFunction appendXValue:xValue yValue:yValue];
}

}
