Table Of Contents

Graph IDEProgramming ► Graphic

This section describes the API specific to Graphic processing. To see the use of this API consult the Circle section.

@@method(public, class) (id)alloc;
  Call like this:

[Circle alloc]

That allocates a Circle object. In practice the receiver class (Circle in this example) needs to be the one specific to the focused graphic such as Circle, Rectangle, Function, etc. or a subclass defined in your own Plugin.

@@method(public, class) (id)append;
  Call like this:

myCircle = [Circle append];

That appends a new Circle graphic in the focused Layer, at the end of the graphic nodes, and then returns the circle object so that it can be programmed using Circle methods. The receiver class (Circle in this example) can be any of the Programming objects.

@@method(public, class) (id)insert;
  Call like this:

myCircle = [Circle insert];

That inserts a new Circle graphic in the focused Layer, in front of the currently focused graphic, and then returns the circle object so that it can be programmed using Circle methods. The receiver class (Circle in this example) can be any of the Programming objects.

@@method(public, class) (id)stored;
  Call like this:

myCircle = [Circle stored];

Returns an instance of the receiver class. That instance is stored by the associated graphic if the class implements the NSCoding protocol and hence the state is persistent and part of the document when saved and retrieved (see Plugin for additional details). If you call this method to make an instance then do not call release on the return. Reminder: if you use this then make sure to declare the method in a declaration section of the script. As none of the stock classes implement the NSCoding protocol this method is only applicable to custom classes defined in a plugin.

@@method(public, instance) (id)init;
  Call like this:

myCircle = [[Circle alloc] init];

That allocates, initializes and associates the Circle object with the focused graphic. Make sure the variable assigned to is previously declared as an id type.

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

[myCircle moveCenterToXValue:200.0 yValue:350.0];

That sets the circle's center point to the coordinate {200.0, 350.0}.

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

[myCircle display];

Displays the graphic of the receiver (a circle in this case). Normally the display occurs at the end of the animation loop of the graphic view. However, sometimes it is desired to directly display the graphic and this method does that. Great care is taken in the system to only display the region that the receiver's graphic occupies. Do not call this method from a script, rather call it from a Custom Application.

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

[myCircle execute];

Executes the script of the receiver (a circle in this case). Normally the script is executed in the animation loop of the graphic view by using the methods in the Container View class instance. However, sometimes it is desired to directly execute the script for only one particular graphic and this method does that. Executing does not display the graphic so in order to display the changes of the execution call the display method. Do not call this method from a script, rather call it from a Custom Application.

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

[myCircle remove];

That removes the receiver (a circle in this case) from the Layer and deallocates it. After this call the receiver is no longer valid.

@@method(public, instance) (void)sizeToCenteredWidth:(double)width height:(double)height;
  Call like this:

[myCircle sizeToCenteredWidth:100.0 height:200.0];

That sets the circle's width to 100.0 and height to 200.0 while maintaining the circle's center point.

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

[myCircle setInteriorRed:0.5 green:0.4 blue:1.0 alpha:1.0];

That sets the interior color of the circle 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.

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

[myCircle setCurveRed:0.5 green:0.4 blue:1.0 alpha:1.0];

That sets the curve (a.k.a.: border, parameter) color of the circle 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.

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

[myCircle release];

That releases the previously made circle. It is very important that you release each object that has been previously allocated.

@@method(public, instance) (unsigned)animationCount;
  Call like this:

animationCount = [myCircle animationCount];

That assigns the circle's animationCount to the variable on the left. The animation count can be used for all sorts of purposes. For example this: (animationCount % 10) / 10.0 can be used to make a red color that modulates and hence makes a color appear to pulse.

@@method(public, instance) (id)controller;
  Call like this:

controller = [myCircle controller];

That returns the controller. The controller is assigned utilizing either Document or Container View methods for loading views into a custom application. Once you are able to access the controller then you can send it any method you wish. In that way, you can synchronize the caller with other elements of an application.

@@method(public, instance) (unsigned)executionCount;
  Call like this:

executionCount = [myCircle executionCount];

That assigns the circle's executionCount to the variable on the left. The execution count is mainly to determine when initialization code should be executed. If its value is one then the script is executed for the first time.

@@method(public, instance) (unsigned)recursionCount;
  Call like this:

recursionCount = [myCircle recursionCount];

That assigns the circle's recursionCount to the variable on the left. Unless you call the recur method the recursionCount is always zero.

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

[myCircle recur];

Causes the script and associated graphic to be duplicated and executed. Since this can happen anywhere in the existing script it causes a recursion. To stop the recursion use recursionCount and a conditional. It is very important to bracket this call with a conditional so that the recursion is not infinite. There is no safety mechanism for infinite recursion so you must take precautions. This call is most important for data graphics such as curves where you might want to start with one curve and computer, say, ten curves for a line graph with many curves.

Recursion inserts new graphics into the layer of the graphic. Because the script runs in a general purpose graphic drawing application some care is taken to make sure the insertion is done correctly. If conditions are nominal then the insertion is as expected. However, there are some circumstances that break recursion. For example, if you execute the recursion and then drag out a new graphic, reorder that graphic into the recursion insertion then that graphic will break the existing recursion chain and execution of a new recursion will insert recursion graphical elements before the manually added graphic and will not reuse the recursive graphics after the manually inserted graphic.

@@method(public, instance) (void)registerWithName:(const char *)aName;
  Call like this:

[myCircle registerWithName:"myName"];

That calls the controller's register:withName:recursionIndex: method. The controller is assigned utilizing either Document or Container View methods for loading views into a custom application. The method above is equivalent to [[myCircle controller] register:myCircle WithName:"myName" recursionIndex:[myCircle recursionIndex]];.

@@method(public, instance) (void)setSourceCode:(const char *)aString;
  Call like this:

[myCircle setSourceCode:"<insert a script here>"];

That injects the source code into the receiver. The source code is then executed after the current script executes; thus this is not a serialized programming technique. Usually this method is only called in a Graphic View script.

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

[myCircle finalize];

That finalize the graphic. Only call this method within a Graphic View script.




© 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.