Draw

From AGI Wiki
Revision as of 12:05, 30 March 2019 by Andrew Korson (talk | contribs) (Created page with "The '''draw''' command draws a screen object on the visual screen so it will be visible in subsequent interpreter cycles. == Syntax == draw(obj oA)...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

The draw command draws a screen object on the visual screen so it will be visible in subsequent interpreter cycles.

Syntax

draw(obj oA);

Remarks

A screen object will not appear on the graphics screen until the object is initialized, a view is assigned, the object is positioned, and finally the draw command is executed.

Once the object number is validated, AGI enables it for updating (if not already enabled) and then validates the object's position using the shuffling method. The object is then added to the screen, where it will be visible and updated in subsequent interpreter cycles.

If the draw command is used on an object that is already visible AGI ignores the command.

Use the erase command to erase a screen object from the screen.

Possible Errors

If the screen object is not properly initialized or a view is not assigned when the draw command is executed, AGI will try to access invalid memory while trying to position and draw the object, resulting in unpredictable results, including possibly crashing AGI.

When the draw command is executed, AGI first checks that the object's number is less than or equal to the max screen object number; if not, it raises trappable error #19.

Example

Code:

<syntaxhighlight lang="agi"> animate.obj(o5); [ initialize first load.view(8); [ load a view for the object set.view(o5, 8); [ assign the view to the object position(o5, 72, 144); [ position the object on the screen] draw(o2); [ now draw it after all setup is done </syntaxhighlight>

Technical Information

Required Interpreter Version: Available in all AGI versions.
Byte-Code Value: 35 (0x23 hex)

See Also

animate.obj
erase
load.view
position
set.view