Hacker News new | comments | show | ask | jobs | submit login
Show HN: Recursive PNG Generator (algoind.com)
12 points by sagebird on Jan 31, 2017 | hide | past | web | favorite | 8 comments



Lego!

  define q (4 times)
     qq
    ,  ,
    ,  ,
   q,  ,q
     ,,


I created this website.

The thing I am exploring is recursively expanding a rectangular region.

The area on the left allows you to enter text that defines an image. If I wanted to define a tower, I might start by typing:

  define tower
  
     x 
     x
    xxx 
  xxx xxx
The x's get treated as black pixels, and the spaces are transparent.

The image is saved to a variable taken from the first letter of the word. So for tower, it is 't'

That allows you define something else in terms of towers. For example, a city:

  define tower
  
     x 
     x
    xxx 
  xxx xxx

  define city
  
  ttt
(That would create 'tower' and a 'city' with three towers)

By itself, that is not very interesting. Slightly more interesting is allowing recursion in a definition.

That is done by following a definition by parens, and saying how many times to recur.

EG:

  define tower(6 times)
For this to be work, tower must be defined in terms of itself. So instead defining a tower entirely in terms of x, you can put some t's inside, so it will recursively expand.

  define tower(6 times)

     x 
     t
    xtx 
  xxx xxx
There are many limitations to this implementation. - It is easy to define a scene that crashes the browser. - It can get annoying using keeping track of single letter variable names - recursion is limited to 9 times.

It was in Haxe and compiled to JS. It is not efficient or performant. It is entirely computed client side in JS. PNGs images are base64 encoded, and can be downloaded and saved.

Thanks for taking a look.


I love tiny editors like this. I spent hours exploring a js1k project that rendered l-systems.

    define x (5 times)
    
    x   x
     , ,
      ,
     , ,
    x   x

One feature request: zip the code into the url, then it's easy to share w/o a server. Can be done like: compress [string to zip to b64](https://github.com/the-grid/ed-userhtml/blob/5a8c88051a72706...), decompress [b64 to unzip to string](https://github.com/the-grid/ed-userhtml/blob/5a8c88051a72706...).


This is some really cool stuff O_o

what would really help if generated images are cached, as well as a debounce or a "run" button for when I'm typing in new images and old ones are getting regenerated on every keypress, that is kind of really very annoying.


Great toy ! I'll probably waste some time trying to display some crazy sh*t =D


I had fun creating a "town" with this code : http://pastebin.com/kuBYTSqP


lol xD good job!


Reminds me of Wolfram's "A New Kind of Science"




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: