Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Cluster Your Pixels!

Cluster Your Pixels!

Presented at Brooklyn JS's 1 year anniversary, 2014-11-20.

Imagine pixels as points in 4-dimensional space! Then cluster them, and apply different palettes!

Animated gifs and videos are unfortunately not animated due to pdf... :(

Andrew Petersen

November 20, 2014
Tweet

More Decks by Andrew Petersen

Other Decks in Programming

Transcript

  1. Randomly pick two pixel positions. Swap the pixels in the

    palette if the distance between the corresponding shape pixel is smaller than the other shape-palette distance
  2. s1 p1 var a = distance( , ) var b

    = distance( , ) s2 p2 if (a < b) swap( , ); p1 p2
  3. How? Avoid GC by passing / modifying references instead of

    returning instances. Basically what you're never supposed to do.
  4. function showtime(palette, source, stuff){ // do something stuff[0] = 'a

    result' stuff[1] = 'another result' swap(palette, source) } var state = [] showtime(p, s, state); assert(state[0] == 'a result')
  5. And once we have clusters, we can take the pixel

    indices within those clusters and change their colors…