Embedded Brainfuck Canvas

Brainfuck is a turing-complete programming language and abstract machine which has only eight operators.

I’ve written a greasemonkey script which searches webpages for specially formatted brainfuck programs, and turns them into graphics by running a brainfuck interpreter and piping the output of the program to an HTML 5 canvas element.

Full details of the implementation are available on my website, where the embedded brainfuck canvas greasemonkey script can also be downloaded.

Here is an example program:

☸⠠⠐++++++++++++++++[}++++++++++++++++{-]}[{.+}-]{[-.]

And here is what it looks like when it runs: Brainfuck Spectrum program

I’ve also made a couple of modifications to the language, firstly the ability to enter hex numbers 0 to F, as well as using unicode braille symbols to enter numbers 0 to 255. Secondly, the eight operators can be written using unicode trigrams, to make the program look nicer. The following trigram/braille brainfuck program draws a smiley face: Brainfuck Smiley:

☸⠐⠐☵☴☵☴☵☴☵☴☵☴☵☴☵
⠑☵⠏☰☶☴☳☵☲☷☵☵☵⠎☶
☴☴☴☴☳☵⣔☵⠎☶☴☳☵☲
☷☴⠬☵☴☴☳☵☵☵☵☲☷
⠑☵⠏☰☶☴☳☵☲☷☵☵
☵☵⡄☶☵☱☳☴☲☷☳
⠆☵☱☴☶☵☱☳☴☲
☷☳⡘☵☱☴☶☵☱
☳☴☲☷☳⠆☵☱
☴☶☵☱☳☴☲
☷☳⠉☵☱☴
☶☵☱☳☴
☲☷☴⠆
☶☵☳
☴☲

See the embedded brainfuck canvas page for full details on how to embed a brainfuck program into a webpage.

If you have installed the script, below here you should be able to see some running brainfuck machines! Otherwise, you’ll just see the code :-)

☸⠐⠐☵☴☵☴☵☴☵☴☵☴☵☴☵
⠑☵⠏☰☶☴☳☵☲☷☵☵☵⠎☶
☴☴☴☴☳☵⣔☵⠎☶☴☳☵☲
☷☴⠬☵☴☴☳☵☵☵☵☲☷
⠑☵⠏☰☶☴☳☵☲☷☵☵
☵☵⡄☶☵☱☳☴☲☷☳
⠆☵☱☴☶☵☱☳☴☲
☷☳⡘☵☱☴☶☵☱
☳☴☲☷☳⠆☵☱
☴☶☵☱☳☴☲
☷☳⠉☵☱☴
☶☵☱☳☴
☲☷☴⠆
☶☵☳
☴☲
☷

six comments

I wonder if this journal’s comment system will allow brainfuck. It’s worth a shot…

☸⠠⠐++++++++++++++++[}++++++++++++++++{-]}[{.+}-]{[-.]

...yep it works! Try writing and posting your own brainfuck program here, using the "preview" button to test it.

Surround the program with ‘@’ symbols so that the journal places it between <code> tags, and don’t forget the brainfuck signature as the first three characters with no spaces: "☸⠐⠐" or it won’t work!
Idris (Email) (URL) - 25 08 10 - 03:25

☸⣿⠏⠏[}⣿[}.+{-]{-]
Idris (Email) (URL) - 25 08 10 - 04:15

Cool. Makes me want to jump in an learn brainfuck, but I’ve already got to many things pending. If I really need to learn an esoteric language, I’ll finish learning Forth.
papa (URL) - 27 08 10 - 04:33

... Though I did start to program my own bf interpreter as an Excel function during a slow stretch at work today. ;)
papa (Email) (URL) - 27 08 10 - 15:57

Cool! :)

☸⠘⠘}+++++++++++++++}+++++[-}++++[-{{++++++++++}}]{]+++++++++++}+++++[-}++++[-{{++++++++++}}]{]-}++++[-}++++[-{{++++++++}}]{]++++++++++++++}+++++[-}++++[-{{++++++++++}}]{]{{{{{}................................{........}..............{..}}........{{..}...........{.}}............{{.}.........{.}}..............{{.}.......{.}}..{{...}}......{{...}}..{{.}.....{.}}..{{.}.{...}}....{{.}.{...}}..{{.}....{.}}.{{.}..{....}}..{{.}..{....}}.{{.}...{.}}..{{.}...{...}}..{{.}...{...}}..{{.}..{.}}..{{.}.....{.}}..{{.}.....{.}}..{{.}..{.}}..{{.......}}..{{.......}}..{{.}..{.}}....................{{.}..{.}}....................{{.}..{.}}.{{.................}}..{{.}..{.}}...{{.}}}.............{{{.}}..{{.}..{.}}...{{.}}}......{{{....}}}...{{{.}}..{{.}...{.}}...{{.}}}....{{{.}}}}....{{{{.}}}.{{{.}}..{{.}....{.}}....{{.}}}..{{{.}}}}......{{{{.}}...{{.}.....{.}}....{{.}}}.{{{.}}}}....{{{{..}}...{{.}.......{.}}....{{......}}....{{.}.........{.}}............{{.}...........{..}}........{{..}..............{........}................................
Ray (Email) (URL) - 24 10 10 - 00:18

Heh heh! Good one :D
Idris (URL) - 24 10 10 - 04:12

Post a comment


Name:  
Remember personal info?

Email:
URL:
Comment: Emoticons / Textile

This is not a trick question, but a mechanism for spam prevention.
 

  ( Register your username / Log in )

Notify:
Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.
Powered by Pivot. RSS Feed & ATOM Feed