AL language
AL is a new language (acronym of Algoid Language). It was inspired by java, python, smalltalk and lua, but it is not these languages.
The aim of Algoid is to be simple but fully featured and our goal is to help you learn how to use different paradigms:
Imperative, procedural, functional, recursive, object-oriented (multi-inheritance) and aspect-oriented programming.
It implements powerful idioms like meta-object protocol (from python) and cascade (from smalltalk).
It is a great platform to learn how to use these paradigms and idioms progressively.
And because one day we hope you will work with an industry standard language (certainly close to c/java and c++) AL is as close as possible to their respective syntaxes.
The syntax involving braces may seem a little complicated when you start experimenting, but you will see how easily you get used to it!
In addition, the fundamental principle of AL are :
- A function is an expression.
- An object is an expression.
- An expression is an object.
- So a function is a meta-function and an object is a meta-object.
Everything else in AL is inspired by the languages I have listed above.
Index
Language structure
Language primitives
[dynamic] type
[dynamic] void
[dynamic] boolean
[dynamic] number
.isReal
.isNan
.isInfinite
.toInteger
.minus
.increment
.decrement
.addition
.substract
.multiply
.divide
.modulo
.limit
.greaterThan
.smallerThan
.greaterOrEquals
.smallerOrEquals
.between
.decodePoint
.loopFor
[dynamic] string
.length
.getChar
.contains
.concat
.indexOf
.count
.upper
.lower
.append
.appendSep
.subString
.subStringOf
.replace
.replaceAt
.remove
.split
.splitAt
.trim
.create
.encodePoint
.each
[dynamic] array
.length
.getItem
.setItem
.getFirst
.getLast
.clone
.clear
.contains
.containsAll
.containsAny
.remove
.pop
.indexOf
.count
.swap
.decodePoint
.find
.create
.each
.eachOnRow
.eachOnCol
.eachItem
.filter
.sort
.min
.max
.join
.merge
.union
.intersection
.complement
.difference
.product
[dynamic] function
[dynamic] object
API root
al
al.order
al.combine
al.types
al.types.BOOL
al.types.NUMBER
al.types.STRING
al.types.ARRAY
al.types.FUNCTION
al.types.OBJECT
util
math
math.PI
math.abs
math.acos
math.aim
math.asin
math.atan
math.ceil
math.cos
math.dbl
math.diagonal
math.exp
math.floor
math.log
math.max
math.min
math.pow
math.random
math.round
math.sin
math.sqrt
math.tan
ui
ui.fullScreen
ui.halfScreen
ui.miniScreen
ui.showText
ui.showAlgo
ui.showScope
ui.showLog
ui.clearLog
ui.showMenu
ui.hideMenu
text
algo.color
algo.color.BLACK
algo.color.DARK_BLUE
algo.color.DARK_GREEN
algo.color.DARK_CYAN
algo.color.DARK_RED
algo.color.DARK_MAGENTA
algo.color.BROWN
algo.color.GRAY
algo.color.DARK_GRAY
algo.color.BLUE
algo.color.GREEN
algo.color.CYAN
algo.color.RED
algo.color.MAGENTA
algo.color.YELLOW
algo.color.WHITE
algo
algo.setRGB
algo.setBgColor
algo.setBgRGB
algo.setAlpha
algo.setTextSize
algo.setStroke
algo.setStack
algo.getX
algo.getY
algo.getAngle
algo.getTop
algo.getBottom
algo.getLeft
algo.getRight
algo.getWidth
algo.getHeight
algo.show
algo.hide
algo.clear
algo.autoClear
algo.removeFirst
algo.removeLast
algo.goTo
algo.lineTo
algo.go
algo.jump
algo.turnRight
algo.turnLeft
algo.rotateTo
algo.circle
algo.disc
algo.square
algo.box
algo.rect
algo.plane
algo.oval
algo.platter
algo.path
algo.poly
algo.curve
algo.curvedPoly
algo.text
algo.onClick
algo.onRelease
algo.onMove
algo.onDrag
algo.onWheel
algo.onKey
algo.onTap
algo.onTouch
algo.onUp
algo.onGravity
algo.onAcceleration
algo.onGyroscope
algo.onOrientation
algo.onProximity
algo.onTemperature
algo.onLight
algo.stamp
algo.stamp.width
algo.stamp.height
algo.stamp.clone
algo.stamp.load
algo.stamp.delete
algo.stamp.draw
instruction
The unit of expression is a statement.
In AL Semicolon is entirelly optional. It exists because AL is inspired from C and in C semicolon is mendatory. So you can write your program with ou without. Prefer with, because the majority of languages ??requested it. It's become a habit.
SYNTAX : instruction [';']
Instruction are divided in two familly : the expression and the controls (imperative one).
block
Block is a self scoped suite of instructions.
Scope means that if variables are declared into it, its will be deleted a the end of the block.
SYNTAX : '{' {[instruction]} '}'
expression
Al support several types of expression : VOID, BOOLEAN, NUMBER, STRING, FUNCTION, OBJECT, ARRAY.
AL is a dynamically typed language, so it is not necessary to manage types. Transtyping is automatic.
SYNTAX :
nil
true | false
nan | infinity | number
'"' string '"'
array | function | object
ident '[' expr ']'
Binary operators in expressions can be :
symbol | description |
---|---|
&& | (boolean) and : true and true is true |
|| | (boolean) or : true or false is true |
== | is equals |
!= | is differents |
< | is less than |
> | is greater than |
<= | is less or equals |
>= | is greater or equals |
+ | (number) plus |
- | (number) minus |
* | (number) multiply |
/ | (number) divide |
% | (number) modulo |
.. | (string) concat |
-> | (function) then |
unary operators in expressions can be :
symbol | description |
---|---|
! | (boolean) not : !true is false |
- | (number) minus : -i is equivalent to 0 - i |
++ | increment : i++ is equivalent to i = i + 1 or i += 1 |
-- | decrement : i-- is equivalent to i = i - 1 or i -= 1 |
|
ui.showLog(); set i = 100 / 2 + 4 * -2; i++; set b = true || false; util.log("result : " .. i .. " and 1 or 0 : " .. b); |
---|
AL also support several constant values: true, false, nil, nan, infinity:
- true and false are the two boolean values
- nil represents null value
- nan for "not a number" (result of an unautorized operation)
- infinity for infinite number (use -infinity for negative one)
statement
Statement declare a new variable in the current scope.
Declared variable can be used for future in the same scope.
SYNTAX : 'set' ident [symbol expr] ';'
symbol can be :
symbol | description |
---|---|
= | equal i = n; |
+= | plus and equal, equivalent to i = i + n |
-= | minus and equal, equivalent to i = i - n |
*= | multiply and equal, equivalent to i = i * n |
/= | divide and equal, equivalent to i = i / n |
%= | modulo and equal, equivalent to i = i % n |
..= | concatenate and equal (for string), equivalent to s = s .. t |
->= | then and equal (for function), equivalent to f = f -> g |
Statement is itself an expression.
|
ui.showLog(); set i = 10; i += 20; util.log("result: " .. i); |
---|
while
While is the first control instruction. It loops while condition is true.
SYNTAX : 'while' '(' condition ')' block
|
ui.showLog(); set i = 10; while (i-- > 0) { util.log("result: " .. i); } |
---|
do
Loop until condition become false. Condition is tester after execution.
SYNTAX : 'do' block 'until' '(' condition ')'
|
ui.showLog(); set i = 10; do { util.log("result: " .. i); } until (i-- <= 0) |
---|
loop
Loop repeats a block of code while limit is reached.
SYNTAX : 'loop' (limit) block
|
ui.showLog(); set a = 0; loop (10) { util.log("loop: " .. a); a++; } |
---|
for
For loop repeats a block of code while a control variable runs through an arithmetic progression.
SYNTAX : 'for' ([initialization] ';' [condition] ';' [progression]) block
|
ui.showLog(); for (set i = 0; i < 10; i++) { util.log("loop: " .. i); } |
---|
if
If execute the block if condition is true and else otherwise.
Elseif are executed if the other condition is true
SYNTAX : 'if' '(' condition ')' block {['elseif' '(' condition ')' block]} ['else' block]
|
ui.showLog(); for (set i = 0; i<4; i++) { if (i == 0) { util.log("i is 0"); } elseif (i == 1) { util.log("then 1"); } else { util.log("then others"); } } |
---|
In AL language, IF is also an expression. It can be user to describe a conditional value.
|
ui.showLog(); set i = 0; set s = if (i==0) "zero" elseif (i == 1) "one" else "other"; util.log ("if i=" .. i .. ", s=" .. s); |
---|
function
Define a reusable and nested scoped part of code with parameters.
The particularity of AL it that functions are considered as data. Function is an expression, so function declaring can be terminated by a semicolon.
SYNTAX : 'function' ['(' [arg [{',' arg}]] ')'] '{' instruction '}'
|
set f = function (x) { ui.message("x parameter is " .. x); }; f (10); |
---|
lambda
A lambda is a function with a simplified syntax. It can only been used as parameter of another function. And be designed to lighten the writing of functors in functional style.
SYNTAX : ['(' [arg [{',' arg}]] ')'] '{' instruction '}'
|
util.pulse({ algo.go(10); }, 50); |
---|
object
Define a reusable scope composed of a set of attributes, methods and nested objects.
Statements can be : attributes (variable), methods (functions) and another nested object.
SYNTAX : 'object' '(' {parent {[ ',' parent ]}} ')' '{' declarations '}'
|
ui.showLog (); set o = object () { set a = 0; set b = "my b attribut"; }; util.log ("o.a = " .. o.a); util.log ("o.b = " .. o.b); |
---|
All functions declared into an object are called methods. Methods are the object set of behaviours.
A method designed to access to an attribut is called accessor.
A method designed to modify an attribute is called mutator.
|
set o = object () { set a = 0; // the a setter set setA = function(a) { this.a = a; }; // the a getter set getA = function() { return this.a; }; // a method set doubleA = function() { this.a = this.a * this.a; }; }; o.setA(2); ui.message("o.a parameter is " .. o.getA()); o.doubleA(); ui.message("and its double is " .. o.getA()); |
---|
Objects can be duplicated and keeping their internal structure. It is called cloning object.
In AL objects are created and can be cloned. It exists two maneers to clone; The new statement create a new duplicated object with same states and the clone method.
This last one assign the parameters passed to her to the states of the new object.
|
ui.showLog(); set o = object () { set a = 7; set b = "my attribute b"; set toString = function () { return "o {a=" .. a .. ", b=" .. b .. "};" }; }; set p = o.clone (8, "another parameter"); util.log (o); util.log (p); |
---|
This is a reference to the object himself.
|
ui.showLog(); set o = object () { set a; set setA = function (a) { this.a = a; }; set getA = function () { return this.a; }; }; o.setA (7); util.log (o.getA()); |
---|
Supers[n] accesses to the list of super objects (multi-inheritance).
|
set q = object() { set ret7 = function () { return 7; }; }; set p1 = object() {}; set p2 = object(q) {}; set o = object (p1, p2) { set test = function () { return this.supers[1].supers[0].ret7(); }; }; ui.message("o.test result is " .. o.test()); |
---|
array
Define a list of elements or a dictionary indexed by any expression.
When defining nested arrays, the keyword 'array' is only required for the first level of the array (the root). It then becomes optional.
SYNTAX :
item : [ expr ':' ] expr
array : [ 'array' ]1 '{' item [{ ',' item }] '}'
|
ui.showLog(); set a = array {7, 8, 9, 10, 11}; for (set i=0; i < a.length(); i++) { util.log("a[" .. i .. "] is " .. a[i]); } // or more elegent a.each (function (item, index) { util.log("a[" .. index .. "] is " .. item); }); |
---|
Array can already been used as a dictionary.
It keeps its list capabilities, but its values are accessible by a key expression :
|
ui.showLog(); set a = array {"a" : 7, "b" : 8, "c" : 9, "d" : 10, "e" : 11}; a.each (function (item, index, key) { util.log("a[" .. key .. "] is " .. item); }); util.log ("Find a[c] = " .. a["c"]); |
---|
Algoid framework
A language comprises a set of primitives, control structures and status modifiers.
A framework is a set of tools containing functions and objects.
A feature of the AL langage is that every value in the language has associated methods.
This feature was inspired by SmallTalk (cascade) and Python (magic methods).
type
In AL all variables inherits from type object. When any variable is declared, AL create a specific object that is also a type object. Type have some properties and methods that are common for all variables types.
property
Return the AL type of the data. For complete type reference see AL Types.
Verifies that the data is of the type specified as the parameter. For complete type reference see AL Types.
Verify if variable is VOID (is equals to nil).
Verify if variable is VOID (is equals to nil). In this case the function return the value in parameter.
Verify if variable is not of the type specified as the parameter. In this case the function return nil and break call chain. For complete type reference see AL Types.
Verify if variable is VOID (is equals to nil). In this case the function return nil and break call chain.
Test if boolean is equals to b.
Return the data value as String. In case of complexe data type (like array, function and object), return the set of data of the type as String.
method
Index is optional.
If index is not setted, it create an array with value at first position and add item at its end.
Else, it create the array and add item at the index position on it.
Index is optional.
If index is not setted, create an array with value at first position and add items at the end of the array.
Else, it create the array and add items at the index position on it.
event
An event raised every time a variable is modified in program.
void
When variable is declared and nothing is setted on it, AL create a VOID object. This object have some properties and methods. See Type object for type common methods and properties.
boolean
When an boolean is declared, AL create an object. This object have some properties and methods. See Type object for type common methods and properties.
property
Return the inverted boolean value.
Return the boolean && b operation result.
Return the boolean || b operation result.
Return the (boolean || !b) && (!boolean || b) operation result. In other words boolean != b.
Execute the parameter function if boolean value is true.
It it the functional equivalent of If imperative statement.
Execute the parameter function if boolean value is false.
It it the functional equivalent of Else imperative statement.
Execute the parameter function while function return true.
It it the functional equivalent of While imperative statement.
Execute the parameter function while function return true.
It it the functional equivalent of While imperative statement.
number
When an number is declared, AL create an object. This object have some properties and methods. See Type object for type common methods and properties.
Be carefull, parenthesis must be employed with this type because dot is used for decimal.
ex : (7).isNumber();
Verify if variable type is NUMBER and integer.
Verify if variable type is NUMBER and real.
Verify if value is Not a number, e.g. if the result of the operation is invalid.
Verify if the value is infinite.
method
Return the integer value of the number.
Return the inverted number value, same as -n.
Return the incremented number value, same as number + n. If n is not setted it is equal to 1.
Return the decremented number value, same as number + n. If n is not setted it is equal to 1.
Is the number + n operation equivalent.
Is the number - n operation equivalent.
Is the number * n operation equivalent.
Is the number / n operation equivalent.
Is the number % n operation equivalent.
Limit the value between minimum and maximum.
Is number > n operation equivalent.
Is number < n operation equivalent.
Is number >= n operation equivalent.
Is number <= n operation equivalent.
Return true if number if between min and max. It is equivalent to number >= min && number <= max.
Return the character corresponding to codepoint codes.
Is the for (set index = init; index < number; index += increment) imperarive instruction equivalent. Execute the function from 0 (or optional init) to number by adding 1 (or optional increment) each time.
string
When a string is used, AL create a STRING object. This object have some properties and methods. See Type object for type common methods and properties.
property
Verify if string is empty ("").
Return the number of characters of the string.
Return the character at the index position in the string.
method
Return true if string contains the sub string
Concatenate string with the other one.
Return the position of sub string in string.
Index is optional and indicate at what position it begin to search.
Return the number of sub string present in string.
Return the upper representation of the string.
Return the lower representation of the string.
Return result of string concatening.
Index is optional and specify the position to insert in the string.
Equivalent of ".." operator.
Return result of string concatening and separator if string was not empty.
Get the substring between begin and end position in string.
End is optional, if setted indicate the position of the end of sub-string, else, the end is the end of the string.
Get the substring between begin and end sub string in string.
End is optional.
Return string that sub string has been replaced by the second sub-string.
Return string that the sub string has been replaced at index position in the string.
Return string that the char at position has been removed.
Length is optional, if setted, remove the number of char indicated.
Split the string according the specified separator and store results in an array.
Use "" separator to convert a string to an array of characters.
Split the string according the specified ids (contained in the array) and store results in an array.
Return the string that unused spaces has been removed at the beginning and the end of the string.
Create a string by duplicating sub string from 0 to count time.
Create an array that contains String caracters as codepoint codes.
functional method
Loop on all character of the string.
Executed function must define one parameter to retreive the current character of each loop iteration.
The second parameter index is optional and deliver the character index in the string.Step is optional, it represent the number of character to jump before next call.
array
When an array is declared, AL create an object. This object have some properties and methods. See Type object for type common methods and properties.
property
Verify if array is empty ({}).
Return the number of element of the array.
Get the array item at identity.
Identity should be the position of the item or it's key.
Set the value of the array item at identity.
Identity should be the position of the item or it's key.
Get the first item of the array.
Get the last item of the array.
prototype
Duplicate the array to another new one.
Every modifications of the clone does not affect the original object.
method
Remove all items of array.
Test if the item is contained by the array.
Test if all the items of the subset are contained by the array.
Test if at least one of the items of the subset is contained by the array.
Remove item from the array at identity position.
Identity should be the position of the item or it's key.
Identity is optional and should be the position of the item or it's key.
If identity is not setted, remove the last item from the array and return it.
If identity is setted, remove the item at positin and return it.
Use array.add() and array.pop() to have LiFo (Last in First out) stack behaviours.
Use array.add() and array.pop(0) to have FiFo (First in First out) queue behaviours.
Return the position of item in the array.
Return the number of item with certain value present in string.
Swap the two items at positions identity1 and identity2.
Identity1 & 2 should be the positions of the items or their keys
Create a string from it's unicode codepoint representation.
functional method
Find item of the array for which function returns true.
Executed function must define one parameter to retreive the current item of each loop iteration.
The second parameter index is optional and deliver the item index in the array.
The thrid parameter is optional too and deliver the key of the item.
Pos is an optional parameter too that indicates the index to begin the search in the list.
Create an array of n elements. Each element is calculated by function passed by parameter.
Loop on all items of the array.
Executed function must define one parameter to retreive the current item of each loop iteration.
The second parameter index is optional and deliver the item index in the array.
The thrid parameter is optional too and deliver the key of the item.
In a two dimentional array (une table), loop on all items of the row of the array.
Executed function must define one parameter to retreive the current item of each loop iteration.
The second parameter index is optional and deliver the item index in the array.
The thrid parameter is optional too and deliver the key of the item.
In a two dimentional array (a table), loop on all items of the column of the array.
Executed function must define one parameter to retreive the current item of each loop iteration.
The second parameter index is optional and deliver the item index in the array.
The thrid parameter is optional too and deliver the key of the item.
In a multi-dimentional array (a tree), loop on all items of the array, if element is an array, it will loop on it's children recursivelly.
Executed function must define one parameter to retreive the current item of each loop iteration.
The second parameter index is optional and deliver the item index in the array.
The thrid parameter is optional too and deliver the key of the item.
Filter the array items on function value.
Function must return a boolean value.
If the value is true, the item is keeped, else it is removed.
Executed function must define one parameter to retreive the current item of each loop iteration.
The second parameter index is optional and deliver the item index in the array.
The thrid parameter is optional too and deliver the key of the item.
Return an array that the items of the array has been sorted.
Function is optional.
Return the minimum value contained in the array.
Function is optional. See sort for more details.
Return the maximum value contained in the array.
Function is optional. See sort for more details;
Join all the elements of the array together.
The function is needed to know how to join sequentialy elements.
It is usefull for concatenate an array to one string, or to adding all the number element of an array.
Return result of the two arrays merging. Each element of the first array is merged with the corresponding element of the second array.
The function determin the merging behaviour by returning value of each merged element.
Note: if second array is shorter than first one, the elements will be repeated until merging is complete.
Return the union of array and subset.
Return the intersection of array and subset.
Return the complement of array and subset.
Return the difference of array and subset.
Return the cartesian product of array and subset.
function
When a function is declared, AL create an object. This object have some properties and methods. See Type object for type common methods and properties.
property
Verify that parameter exists on the function definition.
Return an array that containing all the names of the parameters defined in the function.
Set the value to the parameter of the function that correspond to the name. If parameter does not exists, create it. Usefull to set parameters before execution (for function passing in another without parameters copying).
Set the values to the parameters of the function. be carefull, the parameters values must be express as array (with {}). Usefull to set all parameters before execution (for function passing in another without parameters copying).
method
Remove function parameter dynamically from the function definition..
functional method
Return a new function that is the result of functions concatenation. Parameters are merged togather and treatments run along. Equivalent to -> operator.
Return a new function resulte of the decoration of the function execution with a decorator one. The decored fonction execution is encapsulated into the decorator one. Needed for Aspect Oriented Programming paradigm.
object
When an object is declared, AL create a meta-object. This object have some properties and methods. See Type object for type common methods and properties.
prototype
Duplicate the object to another new one.
Every modifications of the clone does not affect the original object.
It is a new operator equivalent.
property
Verify that attribute exists on the object definition.
Return an array that containing all the names of the Attributes defined in the object.
Verify that object is an instance or a sub-object of the parameter one.
Set or add (if does not exists) Attribute dynamically to the object definition. Attribute can be an attribute, a method or a nested object.
method
Replace the default text when object is printed.
Return an object that is the result of two objects merging. The definitions are merged togather by addition of the attributes and methods.
Remove object attribute dynamically from the object definition. Attribute can be an attribute, a method or a nested object.
API root
Print a line with text.
al
property
Return all the Algoid APIÂ objects and methods that can be uses.
Return all the objects and methods that can be uses in current scope.
Return the time is second from Algoid was started.
al.order
method
Sort the order of the array with ascending maneer.
Sort the order of the array with descending maneer.
random the order of the array.
Reverse the order of the array.
al.combine
Combine the elements of an array together by summing.
Combine the elements of an array together with a product.
Combine the elements of an array together by concatening them.
al.types
property
The AL VOID type. It is a null value.
The AL BOOL type. It is a boolean value (true, false).
The AL NUMBER type. It is a numeric value (1, 2, 3.5, 7 ....).
The AL STRING type. It is a string value.
The AL ARRAY type. It is a array value.
The AL FUNCTION type. It is a function.
The AL OBJECT type. It is an object.
util
method
Execute code in parameter in current scope.
Wait the time indicated in milli-seconds.
Execute function each time number of milli-seconds is elapsed.
The called function received an optional parameter named index that specify the call number.
When function return a value, it terminate the event.
The optional parameter count define a number of time that pulse run before finish. When pulse is finnished, call the 'after' parameter function.
Execute function after the amount of specified milli-seconds is elapsed.
PullOn accept an array of functions. It execute them sequentially with a delay between them.
Clear all upcoming tasks and events but not the current one.
Log the message to the log file.
Log the message to the log file as warning (orange).
Log the message to log file as error (red).
math
constant
The mathematical constant e.
The mathematical constant PI.
method
Get the absolute value (positive) of a number.
Calculate the arc cosinus of the segments factor.
Calculates the angle of algo to aim target from center coordonates (0, 0).
Calculate the arc sinus of the segments factor.
Calculate the arc tangent of the segments factor.
Return the smallest natural value directly greater than the number : 10.9 = 11
Calculate the cosinus of the angle in degree.
Calculate the 2 power of the number.
Calculates the diagonal (hypotenuse) of the rectangle.
Calculate the exponential of the number.
Return the natural part of the number : 10.9 = 10
Return the natural(e) log of the number. If base is setted, return the logarithm of the number to the given base.
Returns the greater of the two numbers.
Returns the smaller of the two numbers.
Calculate the n power of the number.
Generate a random number between 0 and factor excluded
Round the reel number to natural one : 10.9 = 11
Calculate the sinus of the angle in degree.
Calculate the squared root of the number.
Calculate the tangent of the angle in degree.
ui
Display a message box popup in application.
Show execution window in full screen mode.
Show execution window in half screen mode.
Hide execution window and show source code.
Flip to text window, text allow exchange input and output messages with user.
Flip to algo window.
Flip to scope debugger window.
Flip to log file window.
Clear the application log file.
(android only !) Show the slidding menu on the right of algo screen.
(android only !) Hide the slidding menu on the right of algo screen.
text
Clear the text window of all content (inputs and outputs).
Print a new line in text window.
Print a new line in text window with text box control to ask user.
Return a string.
Print a new line in text window with number box control to ask user.
Return a number.
algo.color
constant
Represent the transparent color constant (-1). See colors table.
Represent the black color constant (0). See colors table.
Represent the dark blue color constant (1). See colors table.
Represent the dark green color constant (2). See colors table.
Represent the dark cyann color constant(3). See colors table.
Represent the dark red color constant (4). See colors table.
Represent the dark magenta color constant (5). See colors table.
Represent the brown color constant (6). See colors table.
Represent the gray color constant (7). See colors table.
Represent the dark gray color constant (8). See colors table.
Represent the blue constant (9). See colors table.
Represent the green color constant (10). See colors table.
Represent the cyann color constant(11). See colors table.
Represent the red color constant (12). See colors table.
Represent the magenta color constant (13). See colors table.
Represent the yellow color constant (14). See colors table.
Represent the white color constant (15). See colors table.
algo
property
Set the foreground color of Algo's futur shapes and paths.
color | value | color | value |
---|---|---|---|
transp. | -1 | ||
black | 0 | dark gray | 8 |
dark blue | 1 | blue | 9 |
dark green | 2 | green | 10 |
dark cyan | 3 | cyan | 11 |
dark red | 4 | red | 12 |
dark magenta | 5 | magenta | 13 |
brown | 6 | yellow | 14 |
light gray | 7 | white | 15 |
Set the foreground RGB color of Algo's futur shapes and paths.
Set the current background color of Algo.
Set the background RGB color of Algo's futur shapes and paths.
Set the current transparency of color of futur shapes. Value must be between 0 and 1.
Set the text size of Algo's futur text.
Set the stroke size of Algo's futur shapes and paths.
Set the number of simultaneous visible elements in Algo.
Get the X coordonate of Algo.
Get the Y coordonate of Algo.
Get the angle of Algo.
Get the top coordonate of Algo window (lower than 0).
Get the bottom coordonate of Algo window (greater than 0).
Get the left coordonate of Algo window (lower than 0).
Get the right coordonate of Algo window (greater than 0).
Get the width of Algo window.
Get the Height of Algo window.
method
Show the Turtle.
Hide the Turtle.
Delete all the visible elements in Algo.
Delete all the visible elements in Algo without flicking. Useful for animation and game developpement. Put it at the beginning or the render loop.
Delete the first drawn element in Algo.
Delete the last drawn element in Algo.
Move algo's Turtle to the absolute x, y position in the grid.
Draw line from actual position to x, y one.
Move Algo's Turtle go forward and draw line.
Move foreward algo's Turtle without drawing anything.
Turn right the Algo's Turtle to relative angle.
Turn left the Algo's Turtle to relative angle.
Rotate Algo's Turtle to absolute angle.
Draw circle at current position.
Draw filled circle at current position.
Draw square at current position.
Draw filled square at current position.
Draw rectangle at current position.
Draw filled rectangle at current position.
Draw oval at current position.
Draw filled oval at current position.
Draw a path. Closed parameter is optional and determine if path is closed, it's default value is true. Be carefull, need an array of x, y pairs as input. First point of the path is always the current position.
Draw a polygone. Closed parameter is optional and determine if path is closed, it's default value is true. Be carefull, need an array of x, y pairs as input. First point of the path is always the current position.
Draw a curved path. Closed parameter is optional and determine if path is closed, it's default value is true. Be carefull, need an array of x, y pairs as input. First point of the path is always the current position.
Draw a polygone. Closed parameter is optional and determine if path is closed, it's default value is true. Be carefull, need an array of x, y pairs as input. First point of the path is always the current position.
Draw text at current position.
event
(desktop only !) Execute defined function when user click with mouse on algo.
When function return a value, it terminate the event.
(desktop only !) Execute defined function when user has finished to click with the mouse.
When function return a value, it terminate the event.
(desktop only !) Execute defined function when user move the mouse on algo.
When function return a value, it terminate the event.
(desktop only !) Execute defined function when user click and move (drag) the mouse on algo.
When function return a value, it terminate the event.
(desktop only !) Execute defined function when user use the mouse wheel over algo.
Returned values are 1 for down and -1 for up.
When function return a value, it terminate the event.
(desktop only !) Execute defined function when user hit a keyboard key.
When function return a value, it terminate the event.
Execute defined function when user Tap with his finger on algo.
When function return a value, it terminate the event.
Execute defined function when user Move his finger on algo.
When function return a value, it terminate the event.
Execute defined function when user has finished to Tap with his finger.
When function return a value, it terminate the event.
(android only !) Execute defined function when user turn the device. x, y and z are 3d axis of gravity force and their unit is m/s.
When function return a value, it terminate the event.
(android only !) Execute defined function when user move the device. x, y and z are 3d axis of acceleration force and their unit is m/s.
When function return a value, it terminate the event.
(android only !) Execute defined function when user turn the device. x, y and z are 3d axis of rotation force and their unit is degree/s.
When function return a value, it terminate the event.
(android only !) Execute defined function when user turn the device compared with geomagnetic field. z, y and x are Azimuth, Pitch and Roll and their unit is in degree.
When function return a value, it terminate the event.
(android only !) Execute defined function when user become near or fare the device. Distance is in cm.
When function return a value, it terminate the event.
(android only !) Execute defined function when ambient temperature is changing. t is in °C.
When function return a value, it terminate the event.
(android only !) Execute defined function when ambient light is changing. l is in lx.
When function return a value, it terminate the event.
algo.stamp
Stamp is a graphical bitmap that can be drawed in algo.
property
The internal algo's stamp identifier.
The stamp width.
The stamp height.
prototype
Create a new stamp with bitmap information and size.
(desktop only !) Create a new stamp with bitmap image.
Filename must be an existing file. It can be an absolute path or a relative to several default path ([project root]/img or [application root]/img or [user root]/img)
|
set stamp = algo.stamp.load("PlanetCute/Character Princess Girl"); algo.onTouch((x, y) { algo.autoClear(); algo.goTo(x, y); stamp.draw(); }); algo.hide(); |
---|
method
Remove the stamp from algo.
Duplicate and draw the stamp in algo.
Algoid Language Backus-Nauf form
assign ::= var ident ( "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "..=" | "->=" ) expr [ ";" ]
expr ::= concat | assign
concat ::= or [ ( ".." | "->" ) or ]
or ::= and [ "||" and ]
and ::= compar [ "&&" compar ]
compar ::= oper [ "==" | "!=" | "<" | "<=" | ">" | ">=" oper ]
oper ::= mult [ "+" | "-" mult ]
mult ::= unary [ "*" | "/" | "%" unary ]
unary ::= ( ["-" | "!" | new ] ident) | ( ident [ "++" | "--" ] )
// identifiers
ident ::= call [ "." call ]
call ::= index "(" [ expr [ { "," expr } ] ] ")"
index ::= value [ { "[" expr "]" } ]
// values
boolean ::= true | false
number ::= nan | infinity | ("0"-"9") [ { ("0"-"9") } ]
string ::= """ [ { .. ASCII character .. } ] """
value ::= "(" expr ")" | object | lambda | function | array | if | this | supers | ident | nil | boolean | number | string
// structures
assign ::= set ident "=" expr [ ";" ]
lambda ::= [ "(" [ ident ] [ { "," ident } ] ")" ] "{" body "}"
function ::= function "(" [ ident ] [ { "," ident } ] ")" "{" body "}"
return ::= return expr [ ";" ]
array ::= array<1*> [ "(" ")" ] "{" [ item [ { "," item } ] ] "}"
item ::= [ expr ":" ] expr
object ::= object "(" [ ident [ "," ident ] ] ")" "{" [ { assign } ] "}"
// imperatives
if ::= if "(" expr ")" body [ { elseif "(" expr ")" body } ] [ else body ]
loop ::= loop "(" [ expr ] ")" body
for ::= for "(" [ assign ] ";" [ expr ] ";" [ expr] ")" body
while ::= while "(" expr ")" body
until ::= do body until "(" expr ")"
break ::= break [ ";" ]
// others
comment ::= ( "//" .. ASCII character .. .. end of line .. ) | ( "/*" .. ASCII character .. "*/")
body ::= instruction | "{" [ { instruction } ] "}"
instruction ::= comment | return | loop | for | while | until | break | expr [ ";" ] | ";" | body