Skip to content

albertlarsan68/mondrians

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mondrians

GitHub deployments GitHub GitHub Sponsors Liberapay patrons

example

Generates uniquely deterministic images, in the style of Mondrian.

This project is split in three parts:

  1. A library that takes in the parameters of the generation and the seeds, and returns a base64 encoded binary blob containing the image in PNG format.
  2. A web page that uses the library and Wasm to generate the image in a browser.
  3. A WIP binary that does the same as the web page, but without a browser.

Algorithm

Start with a blank canvas.

You have a one over max depth + 5 chance of stopping there, and choosing a random color between White, Red, Yellow or Blue.

Choose a middle point between min middle and max middle in the X axis.
Create a black line through the whole height, between your chosen middle point - sep width and your chosen middle point + sep width.

For each half:

  • You have a one over max depth + 5 chance of stopping there, and filling your part with a random color chosen between White, Red, Yellow or Blue.
  • Choose a middle point between min middle and max middle in the Y axis.
  • Create a black line through the whole half's width, between your chosen middle point - sep width and your chosen middle point + sep width.
  • Reduce max depth by one
  • For each half half:
    • You have a one over max depth + 5 chance of stopping there, and filling your part with a random color chosen between White, Red, Yellow or Blue.
    • Choose a middle point between min middle and max middle in the x axis.
    • Create a black line through the whole half's width, between your chosen middle point - sep width and your chosen middle point + sep width.
    • Reduce max depth by one
    • Repeat until max depth is 0.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.