Voronoi stained glass

Posted: August 13, 2012 in Uncategorized
Tags:

Here’s a pretty image generated using Voronoi functions in Clisk ….

Just had to share this one – was just playing around at the REPL with some Voronoi functions and this one came as a nice surprise:

(show (let [voronoi1 (voronoi)] 
  (v*
    (v* 5.0 (voronoi-blocks :voronoi voronoi1))
    (warp (voronoi-points :voronoi voronoi1) grain))))

Image

I’m pretty pleased with this stained glass effect!

Note a few tricks used:

  • Multiplying the colour value by (warp (voronoi-points …) grain) to give a colour to each panel (which would otherwise be monochrome)
  • Using the same Voronoi map for both voronoi pattern generators via the optional :voronoi keyword argument. This ensure both the panes and the colouring are generated using the same features (try it without if you want to see why this is important).
  • Scaling the voronoi-blocks colour output by 5.0, which saturates the colour at pure white in the middle of many of the panels.
  • Using a regular Clojure “let” inside the clisk DSL. This works in general, although you have to be a bit careful how you use it because the Clisk DSL functions are actually producing an AST tree, not being executed directly. In particular, if you use a let-bound variable multiple times it will result in duplication of whatever part of the AST tree it refers to, which might not be what you want.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s