LinePaint

From Esolang
Jump to navigation Jump to search

LinePaint is an esoteric programming language created by Dominicentek. It uses 3 instructions to draw lines and shapes on a canvas. Then a pointer moves around the canvas. Based on the length before hitting an obstacle, it executes an instruction.

How it works

In the drawing phase, the program creates a 128x128 canvas, which can be painted to. The pointer starts at [0,0] and moves based on the instruction. Everywhere the pointer goes, it paints a black pixel. A black pixel works like an obstacle. After it finishes drawing, execution phase begins. The execution pointer moves to the exact pixel the draw pointer is on. The pixel is automatically set to white as not an obstacle and the pointer moves to the right. Once it reaches a black pixel, it picks a random direction. It cannot pick a direction to a wall or backwards. When there's no direction to pick, the program ends execution phase. Based on the length the pointer traveled in a direction without interruptions, it executes an instruction. Lengths that don't have an instruction are ignored.

Instructions

Drawing Instructions

There are only 3 instructions to draw.
There are more instructions for logic, but don't impact the canvas.

Paint instructions
Instruction Description
left Rotates the pointer to the left by 90 degrees
right Rotates the pointer to the right by 90 degrees
forward Moves the pointer forward by 1 pixel
Logic instructions
Instruction Parameters Description
input <variablename> Prompts the user for input and stores it into a variable
export <filename> Exports the current canvas into an image file (for debugging purposes)
goto <linenumber> Jumps to a line
if <value> <value> <linenumber> Compares 2 variables or values and if they're equal, it jumps to a line
exec None Program immediately ends drawing phase and begins execution phase
var <variablename> <value> Sets a value to variable
add <variablename> <value> Adds a value to variable
sub <variablename> <value> Subtracts a value from a variable
mul <variablename> <value> Mutliplies variable by value
div <variablename> <value> Divides variable by value
mod <variablename> <value> Modules variable by value

Program instructions

Length Description
1 Pushes a new value to stack
2 Increments the top value in stack
3 Decrements the top value in stack
4 Plus operation: Pops 2 values from stack A and B and pushes value B+A
5 Minus operation: Pops 2 values from stack A and B and pushes value B-A
6 Multiply operation: Pops 2 values from stack A and B and pushes value B*A
7 Divide operation: Pops 2 values from stack A and B and pushes value B/A
8 Modulo operation: Pops 2 values from stack A and B and pushes value B%A
9 Pops and prints the top value in the stack as a number
10 Pops and prints the top value in the stack as an ASCII character
11 Pops the top value of the stack and discards it
12 User input: Pushes the value user inputted
13 If statement: Checks if 2 top values are equal, then are popped. If they are, 1 is pushed, otherwise 0 is pushed
14 Makes the pointer go down/left if the top value is 0, up/right otherwise. The value is then popped
15 Swaps the 2 values on top of the stack
16 Reverses the stack
17 Duplicates the top value of the stack
18 Pushes stack length on top of the stack