GRPE
Designed by | User:Bil-joodusstudios |
---|---|
Appeared in | 2023 |
Computational class | Unknown computational class |
Major implementations | GRPE Javascript interperter |
File extension(s) | none |
GRPE (GRaphics Producing Esolang) was designed for one purpose, to generate graphics from code.
The output from the Javascript interperter is 512 x 512 pixels, with the actual caluclated pixels being either 256 x 256 or 64 x 64, but in theory the resolution does not matter as long as the x and y coordinates are treated as going from 0 to 255.
Because of the graphical output it is pointless to do mathematical calculations with the intent of reading the output.
Producing Images
The code is run for every pixel in the image, the color is determined by the last value found or calculated, it is converted to r, g and b values and displayed.
Simply typing a number or a hexadecimal value prefixed by #.
255 (or) #0000ff
Will both make every pixel blue.
Numbers are the only recognized data type.
You can use the digraph -> to assign a value from 0 to 255 (if value is higher the modulo is used) to one of the color values.
All operations also require a space between them.
@ Make 26 the value of the red channel 26 -> r @ Make 86 the value of the green channel 86 -> g @ make 170 the value of the blue channel 170 -> b @ make the luminosity 128, this makes all channels half as bright 128 -> l
The @ symbol can be used as a comment and as a label to jump to later in the prorgam
In order to not produce just one color, you can use a few constants to change values per pixel.
Constant | Function |
---|---|
x | Return the x coordinate between 0 and 255 |
y | Return the y coordinate between 0 and 255 |
n | Return the value of the frame |
i | Return the index of the pixel between 0 and 65535 |
? | Return a random decimal between 0 and 1 |
c | Return the current color |
Math
These are operations that require an argument.
Operation | Function |
---|---|
+ | Add two values |
- | Subtract two values (- without a space before a number marks it as negaive) |
* | Multiply two values |
/ | Divide two values |
^ | Take a number to the power of the other |
% | Find the modulo of two numbers |
: | Multiply colors together The induvidual rgb channels from 0 to 1 multiplied with the argument's rgb channels |
; | Add colors together Add the induvidual rgb channels together and take the average |
These operations require no argument.
Operation | Function |
---|---|
` | Round number to nearest integer |
{ | Take the sin of a number |
{\ | Take the inverse sin of a number |
} | Take the cos of a number |
}\ | Take the inverse cos of a number |
\/ | Take the tan of a number |
/\ | Take the inverse tan of a number |
The trigonometric functions are in radians
If statements
Whenever an if statement is encountered, if it is evaluated as true it will execute the other code on the line, if not it will continue to the next line of the program.
Start an if statment with a ( to set the first argument, then a , to set the next.
( x , 200 @ first argument second argument
Now you need to close the if statement to make it evaluate:
Character | Function |
---|---|
) | First == Second |
! | First != Second |
> | First > Second |
< | First < Second |
Loops
To loop you need to use labels and goto statements.
@this is a label ~this is a goto
A label can also be used as a comment as it will be ignored by the interperter.
With the goto statement you can jump back to a label of the same name.
A label and goto can have any characters and no code can appear after it on the same line.
You want to use an if statement to break out of a loop because an infinite loop will hang the interperter for it cannot calculate the color of a pixel.
Variables
A variable can be defined and modified with the => digraph, if a variable does not exist you will create it otherwise you will change its value.
A variable name can only consist of lower case letters, and can not be equal to b, c, g, i, l, n, r, x or y.
To recall a variables value type its name in the code.
100 => var var + 1 => var @ set var to 100 and add 1 to it
Animation
The aforementioned constant n returns the value of the current frame, thus can be used to create animations.
This is acomplished by increasing the frame value every time the image renders and rendering it constantly.
x -> r y -> g n * 64 -> b
Excuse the bad gif compression.
The interperter is quite slow, so the 64 x 64 mode is reccomended for animation, this animation is made slower, it runs at around 30 fps on 64 x 64 mode, and 2 on 256 x 256 mode.
Examples
Hello, world!
x - 195 => xx y - 70 ^ 2 => yy xx ^ 2 + yy ^ .5 => oone x - 80 => xx y - 120 ^ 2 => yy xx ^ 2 + yy ^ .5 => otwo x - 185 => xx y - 120 ^ 2 => yy xx ^ 2 + yy ^ .5 => othree x - 115 => xx y - 112 ^ 2 => yy xx ^ 2 + yy ^ .5 => rcircle y / 3 + x => lslant y / 3 - x => rslant #000000 (x,10>(x,15< (y,50>(y,90< #ffffff (x,10>(x,40< (y,65>(y,70< #ffffff (x,35>(x,40< (y,50>(y,90< #ffffff (x,55>(x,60< (y,50>(y,90< #ffffff (x,55>(x,80< (y,50>(y,55< #ffffff (x,55>(x,80< (y,85>(y,90< #ffffff (x,55>(x,80< (y,65>(y,70< #ffffff (x,95>(x,100< (y,50>(y,90< #ffffff (x,95>(x,125< (y,85>(y,90< #ffffff (x,135>(x,140< (y,50>(y,90< #ffffff (x,135>(x,165< (y,85>(y,90< #ffffff (oone,20<(oone,15> #ffffff (lslant,250>(lslant,255< (y,75>(y,90< #ffffff (rslant,17>(rslant,22< (y,100>(y,140< #ffffff (lslant,70>(lslant,75< (y,115>(y,140< #ffffff (rslant,0>(rslant,5< (y,115>(y,140< #ffffff (lslant,87>(lslant,92< (y,100>(y,140< #ffffff (otwo,20<(otwo,15> #ffffff (rcircle,12<(rcircle,7>(x,109> #ffffff (x,105>(x,110< (y,100>(y,140< #ffffff (rslant,-80>(rslant,-75< (y,120>(y,140< #ffffff (x,135>(x,140< (y,100>(y,140< #ffffff (x,135>(x,165< (y,135>(y,140< #ffffff (othree,20<(othree,15>(x,179> #ffffff (x,175>(x,180< (y,100>(y,140< #ffffff (x,215>(x,220< (y,100>(y,130< #ffffff (x,215>(x,220< (y,135>(y,140< #ffffff
Due to the nature of the language there can be no trivial Hello, World! program, so any program that produces the text as the main thing is a Hello, world! program.
Mandelbrot set
x / 84 - 2.2 => cx y / -100 + 1.3 => cy 0 => it 0 => xt => yt @main yt ^ 2 => yb xt ^ 2 - yb + cx => ma 2 * xt * yt + cy => yt ma => xt yt ^ 2 => yb xt ^ 2 + yb ^ 0.5 => escape (escape, 2> ~final it + 1 => it (it, 15< ~main @final 15 - it * 17
Hello world triangle
x - 128 ^ 2 => xcircleone y ^ 2 + xcircleone ^ .5 => cone 255 - cone => cone (cone,1< 0 => cone y - 255 ^ 2 => ycircletwo x ^ 2 + ycircletwo ^ .5 => ctwo 255 - ctwo => ctwo (ctwo,1< 0 => ctwo x - 255 ^ 2 + ycircletwo ^ .5 => cthree 255 - cthree => cthree (cthree,1< 0 => cthree cone -> r ctwo -> b cthree -> g c => space #000000 y / 2 => yy 128 + yy => ma 128 - yy => mb (x,ma< (x,mb> space
Computational class
Currently I cannot conclude if this language would be turing complete.
I would say turing tarpit because it might be possible to use a lot of if statements to create a complex system.
However that kind of approach would leave the program too slow to practically run, disregarding the difficulties of making sense of the output.
Interperter controls
The interperter has 5 buttons here are their functions in order.
Play/Pause animation
Stop animation and set frame to 0
Step to the next frame and increment frame by 1
Toggle between 256 x 256 and 64 x 64
Help, which links to this page