Pixilang/Elements of the language

Elements of the language

edit

Comments

edit

// - comments. Example: //blah blah blah

/* */ - Multiline comments. Example:

/* blah blah blah
blah blah blah */

Text strings

edit

Example:

a = "text string"

You can put the numerical values of a variable to any string, when this string is used as a parameter for some command (except make_pixi). Example:

blahblah = 34
video_export_gif( "VIDEO$blahblah.gif" )
//Save video to the VIDEO34.gif

ASCII codes

edit

ASCII codes (max 4 symbols): 'A','B','ABC'... Example:

ascii_code = 'E'

Variables

edit

a,b,c,d... and other alphabet symbols - used for creating your own variables. Example myvar = 4 //put 4 to variable "myvar"

Math operations

edit

-,+,*,/,% - math operations. Example: a = b + 4

Conditional operations

edit
  • < - less
  • > - greater
  • <= - less or equal
  • >= - greater or equal
  • = - equal (after if operator)
  • != - not equal

Binary logic operations

edit
  • ^ - xor
  • & - and
  • | - or

Numbers

edit

Numbers (for example: -1234) - decimal numbersĀ :)

Some commands (transformations, for example) need numbers in the fixed point format 24.8. Fixed point numbers are decimal numbers, multiplied by 256. Examples:

1   will be 256 (1*256) in the fixed point format;
2   will be 512 (2*256) in the fixed point format;
0.5 will be 128 (0.5*256) in the fixed point format;

Numbers in the form #XXXXXXXX (for example: #80EFB434) can be used as color values for some graphics commands in standard HTML color format: #RRGGBB, where RR - red, GG - greed, BB - blue. For example: #FF0000 - it's a red; #00FF00 - green; #0000FF - blue.

Predefined colors: ORANGE, BLACK, WHITE, RED, GREEN, BLUE, YELLOW.

User defined commands

edit

You can define your own commands (subprogramms). Let's see an example:

//here our main program starts
print("Hello world!",0,0)
myfunc1 //here we execute our own command, which is defined at the end of our main program
stop //stop main program
myfunc:
  //here is the body of our command (named "myfunc1")
ret //Return from subprogram. Don't forget this word!

So user defined commands look like this: COMMAND_NAME: BODY OF YOUR COMMAND (SOME PIECE OF PROGRAM) ret.

Also you can create your commands on the fly:

//Create user defined command:
user_command = { print("hello1") print("hello2") }
//And run it:
user_command
//user_command - it's address of created subprogram.

"goto" command

edit

You can jump from one part of a program to another part. Here is an example:

marker1:
  blah blah
  goto marker1 #here you go to the marker1, that was declared above.

Example2:

my_cool_marker:
  dot(1,1,#FF0000)
  go my_cool_marker

"while" command

edit

"while" command is for conditional loops: while( condition ) { actions }. Example:

a = 0
while( a < 8 )
{ 
  print( "$a", a * 8, 0, WHITE ) 
  a + 1
} //Show "a" variable eight times

Commands

edit

Commands have the following syntax: COMMAND_NAME (PARAMETER1, PARAMETER2,...) For example, let's execute the "dot" command: dot(1,1,#FF0000) If there are no parameters, then you must write the command name only. For example: frame. Some commands can return a value. Example: x = get_dot( 10, 10 )