/*
This is a complete example of how to program without any user interaction.
*/
/* Declarations */
@@class() GraphicView:Object
@@method(public, class) (id)stored;
@@method(public, class) (id)alloc;
@@method(public, instance) (id)init;
@@method(public, instance) (unsigned)animationCount;
@@method(public, instance) (void)empty;
@@method(public, instance) (void)release;
@@end
@@class() SingleCoordinateGraph:Object
@@method(public, class) (id)stored;
@@method(public, class) (id)alloc;
@@method(public, class) (id)append;
@@method(public, instance) (id)init;
@@method(public, instance) (void)setDoesAutoscaleAfterExecution:(unsigned)doesAutoscaleAfterExecution;
@@method(public, instance) (void)autoscale;
@@method(public, instance) (void)focus;
@@method(public, instance) (void)unfocus;
@@method(public, instance) (void)release;
@@end
@@class() Circle:Object
@@method(public, class) (id)insert;
@@method(public, class) (id)append;
@@method(public, class) (id)alloc;
@@method(public, instance) (id)init;
@@method(public, instance) (unsigned)animationCount;
@@method(public, instance) (void)setCurveRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha;
@@method(public, instance) (void)setInteriorRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha;
@@method(public, instance) (void)moveCenterToXValue:(double)xValue yValue:(double)yValue;
@@method(public, instance) (void)sizeToCenteredWidth:(double)width height:(double)height;
@@method(public, instance) (void)finalize;
@@method(public, instance) (void)release;
@@end
@@class() Rectangle:Object
@@method(public, class) (id)insert;
@@method(public, class) (id)append;
@@method(public, class) (id)alloc;
@@method(public, instance) (id)init;
@@method(public, instance) (unsigned)animationCount;
@@method(public, instance) (void)setCurveRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha;
@@method(public, instance) (void)setInteriorRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha;
@@method(public, instance) (void)moveCenterToXValue:(double)xValue yValue:(double)yValue;
@@method(public, instance) (void)sizeToCenteredWidth:(double)width height:(double)height;
@@method(public, instance) (void)finalize;
@@method(public, instance) (void)release;
@@end
@@class() Function:Object
@@method(public, class) (id)alloc;
@@method(public, class) (id)stored;
@@method(public, class) (id)append;
@@method(public, instance) (id)init;
@@method(public, instance) (void)setSourceCode:(const char *)aString;
@@method(public, instance) (void)emptyData;
@@method(public, instance) (unsigned)animationCount;
@@method(public, instance) (unsigned)recursionCount;
@@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)setInteriorRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha;
@@method(public, instance) (void)release;
@@end
/* Execution block */
{
id aGraphicView;
id aGraphic, aGraph;
int ii;
unsigned animationCount;
double red, green, blue;
aGraphicView = [GraphicView stored];
animationCount = [aGraphicView animationCount];
[aGraphicView empty];
aGraphic = [Circle append];
red = (animationCount % 10) / 10.0;
green = (animationCount % 20) / 20.0;
blue = 1.0;
[aGraphic setInteriorRed:1.0 green:green blue:1.0 alpha:1.0];
[aGraphic setCurveRed:red green:1.0 blue:1.0 alpha:1.0];
[aGraphic moveCenterToXValue:300.0 yValue:400.0];
[aGraphic sizeToCenteredWidth:50.0 height:200.0];
[aGraphic finalize];
aGraphic = [Rectangle append];
red = (animationCount % 10) / 10.0;
green = (animationCount % 20) / 20.0;
blue = 0.0;
[aGraphic setInteriorRed:red green:green blue:blue alpha:1.0];
[aGraphic setCurveRed:0.0 green:0.0 blue:0.0 alpha:1.0];
[aGraphic moveCenterToXValue:300.0 yValue:400.0];
[aGraphic sizeToCenteredWidth:50.0 height:200.0];
[aGraphic finalize];
aGraph = [SingleCoordinateGraph append];
[aGraph moveCenterToXValue:400.0 yValue:400.0];
[aGraph sizeToCenteredWidth:300.0 height:300.0];
[aGraph setDoesAutoscaleAfterExecution:1];
[aGraph focus];
aGraphic = [Function append];
[aGraphic setSourceCode:"
double cos(double a);
@@class() Function:Object
@@method(public, class) (id)alloc;
@@method(public, class) (id)stored;
@@method(public, class) (id)append;
@@method(public, instance) (id)init;
@@method(public, instance) (void)setSourceCode:(const char *)aString;
@@method(public, instance) (void)emptyData;
@@method(public, instance) (unsigned)animationCount;
@@method(public, instance) (unsigned)recursionCount;
@@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)setInteriorRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha;
@@method(public, instance) (void)release;
@@end
{
id myFunction;
int ii;
double xValue, yValue;
unsigned animationCount;
unsigned recursionCount;
double red;
myFunction = [MyFunction stored];
animationCount = [myFunction animationCount];
recursionCount = [myFunction recursionCount];
/*
Empty the data and then append new data.
*/
[myFunction emptyData];
for(ii = 0; ii < 500; ii++)
{
xValue = 0.01 * ii + animationCount * 0.5;
yValue = cos(xValue) + recursionCount;
[myFunction appendXValue:xValue yValue:yValue];
}
red = (animationCount % 10) / 10.0;
[myFunction setCurveRed:red green:0.0 blue:0.0 alpha:1.0];
if(recursionCount < 5)
{
[myFunction recur];
}
}"];
[aGraph unfocus];
[aGraph finalize];
[aGraphicView finalize];
}
|