Online Help for Chasys Draw IES: Effects - Custom via GraphAsm Program

Effects : Custom via GraphAsm Program

About GraphAsm Custom Effects

Sometimes you may want to do something that Chasys Draw IES Artist doesn’t support internally. That is where this effect comes in. By issuing simple instructions to the GraphAsm Interpreter, you can write short programs to implement your own custom visual effects. GraphAsm supports both math operations and more powerful graphical commands like interpolation to give you the power to squeeze as much juice as possible into your macros. Can things get better than that?


General Programming Rules

All GraphAsm statements should end with a semi-colon. ;
Comments should begin with //; the whole line will be treated like a comment.
Most GraphAsm instructions take this form:

instruction dest, value1, value2;
dest is the destination, it must be one of the predefined variables.
and value2 may be variables or numbers, depending on what the instruction does.

To specify a number, use a hash # followed by the numeral. There should be no spaces between the # and the numerals. GraphAsm does not accept decimals. To work with fractional values, use fixed point math with the shift instructions:

#1234   // correct
// correct
# 77     
// wrong - spacing
# -1      
// wrong - spacing
// wrong - decimal

Please note that you can't use a numeral as a destination; it is not logical to do so. For example, the following statement is wrong:

add #123, red, blue;    // wrong

The correct form would be:

add red, #123, blue;    // correct


add _a, red, blue;        // correct

Your program will be executed for each pixel in the image, starting at the top left corner. Keep that in mind.


GraphAsm Variables

The following are preset color variables. On entry, they specify the color of the current pixel. On exit, they specify the color the pixel should be set to by the interpreter. They are:
    blue  green  red  alpha
The following are preset location variables. On entry, they specify the location of the current pixel. They are not checked on exit. They are:
    _x  _y  
note the underscores
The following are general variables, use them for anything you please.
    _a  _b  _c  _d  _e  _f  _g  _h  _i  _j


GraphAsm Commands
The following are the commands that you use with GraphAsm:
Command Description and Usage
EXIT Exit the program
Usage: exit;
ADD Adds two variables
Usage: add dest var1 var2;
SUBTRACT Subtracts var2 from var1
Usage: subtract dest var1 var2;
MULTIPLY Multiplies var1 by var2
Usage: multiply dest var1 var2;
DIVIDE Divides var1 by var2
Usage: divide dest var1 var2;
MODULUS Divides var1 by var2, placing the remainder, not the answer, in destination
Usage: modulus dest var1 var2;
SHIFT_LEFT Left-shifts var1 by var2
Usage: shift_left dest var1 var2;
SHIFT_RIGHT Right-shifts var1 by var2
Usage: shift_left dest var1 var2;
AND Performs a logical AND on var1 and var2
Usage: and dest var1 var2;
OR Performs a logical OR on var1 and var2
Usage: or dest var1 var2;
XOR Performs a logical XOR on var1 and var2
Usage: xor dest var1 var2;
NOT Performs a logical NOT on src
Usage: not dest src;
MIX Performs an interpolation between var1 and var2. The value of factor on entry is the weight of var1 relative to 1000. On exit it contains the result.
Usage: mix factor var1 var2;
COPY Copies the contents of src to dest
Usage: copy dest src;
SWAP Swaps the contents of var1 and dest
Usage: swap var1 var2;
LOAD_PIXEL Loads a pixel into the predefined variables red, green, blue, and alpha.
Usage: load_pixel x-pos y-pos;
COMPARE_EQUAL Sets dest to 1 if var1 is equal to var2.
Usage: compare_equal dest var1 var2;
COMPARE_LESS Sets dest to 1 if var1 is less than var2.
Usage: compare_less dest var1 var2;
COMPARE_MORE Sets dest to 1 if var1 is more than var2.
Usage: compare_more dest var1 var2;
LABEL Used to mark points in a program.
Usage: label number;  e.g.  // label #2;
GOTO Used to jump to a labeled location.
Usage: goto label_number;  e.g.  // goto #2;
GOTOIF Used to jump to a labeled location if var is not zero.
Usage: gotoif var label_number;  e.g.  // gotoif red,  #2;
RAND Used to generate a random number between 0 and 32767
Usage: rand dest;  e.g.  // rand _a;


GraphAsm Examples

Try the following examples to get you up to speed:

Swap RED and GREEN:

swap red green;

Morning Fog effect:

copy _c #500;
mix _c red #192;
copy red _c;


copy _c #500;
mix _c green #192;
copy green _c;

copy _c #500;
mix _c blue #224;
copy blue _c;

Random noise mask:

rand _a;
and red _a #255;
rand _a;
and green _a #255;
rand _a;
and blue _a #255;



Copyright © John Paul Chacha, 2001-2024

The information herein is subject to change without any notice. The author makes no guarantees as to the completeness of this documentation.