Home > javascript > My harmonious background canvas

My harmonious background canvas

So I happened upon squaredesign site and was impressed by their trippy background squares that responded to mouse movement (tutorial here).


Illustration done with Harmony

I got jealous and wanted my own interactive background. Plus @miketaylr's is mad sweet. Turns out, I'm lazy. Never fear. Mr Doob recently put out the magical canvas procedural illustration application Harmony and generously licensed it MIT.

I adapted the code for use as a background, but felt like it still missed something. It needed an easter egg. Oh yes. Taking inspiration from the Harmony Harmony meme (example), I decided an Erasure music video was in order.

Leveraging code from the $1 Unistroke Recognizer (which is righteous), it takes snapshots between drawing pauses and looks to see if you drew a star. If it thinks you did.. then:

The code for the bg integration is on github: /paulirish/harmony. If you want to do the same thing, using the code here is probably most helpful. I can't help you out with this unfortunately.
The code for doob's harmony app is on github, too: /mrdoob/harmony

Take it for a spin if you like. Experiment with some of the other brushes. Thanks again to powerhouse Mr Doob for sharing such beautiful work.

(I'll probably be removing the drawing canvas in a week or so. It's a bit of a resource hog!)

javascript

  1. May 17th, 2010 at 13:28 #1

    If you're looking to get the easter egg, pause before and after, and draw the star pretty quick. The detection isn't that perfect. :)

  2. May 17th, 2010 at 13:39 #2

    That's so damn awesome…love it!

  3. May 17th, 2010 at 13:41 #3

    fun easter egg!

  4. May 17th, 2010 at 13:43 #4

    It also looks like you have to draw the star the same way you did ( from the bottom left corner. I learned to draw the star from the top that it doesn't seem to work that way.

  5. May 17th, 2010 at 13:44 #5

    @Daniel Petrie
    oops, I lie.. Apparently my start wasn't good enough the first few times I drew it my way lol

  6. May 17th, 2010 at 13:52 #6

    i am quite honored and humbled. :)

  7. May 17th, 2010 at 14:05 #7

    LOVE the interactive background effect. Super cool!

  8. May 17th, 2010 at 14:29 #8

    I really need to stop coming to your site, Paul. It's a real productivity killer for me. Damn you!!

  9. May 18th, 2010 at 15:43 #9

    wow – spending 15 minutes on your site now – just to "paint" around.. :D

    great!

  10. May 19th, 2010 at 00:31 #10

    what a journey. i didn't miss a stop. some flickering mischief, harold's huge purple crayon, smoking mr. doob and then having my hopes and dreams dashed upon the rocks endlessly in harmony, harmony with "persistence is futile" (no it's a laugh riot) only to arrive on the set of "Prancing Tiger, Closeted Dragon". What do you suppose the snowball was a metaphor for? Some things are better left to urban dictionary….

    Thanks Paul for the memorable and timely writeup. You rock, DUDE!!!
    bliss and blessings to you and yours.

  11. May 19th, 2010 at 01:37 #11

    ps. Paul, I love my "In Utero" icon. How did you know Kurt was my cousin? Happy afterbirth!

  12. May 19th, 2010 at 01:47 #12

    i'm sorry, that was "Prancing Tiger, Hidden Drag Queen"

  13. May 19th, 2010 at 13:36 #13

    :D

  14. zc
    May 22nd, 2010 at 02:21 #14

    oh,it's so cool,love it

  15. kusum
    May 24th, 2010 at 15:53 #15

    this rocks paul. hi!

  16. May 31st, 2010 at 07:35 #16

    So I have to say it's more than a little frightening to find this easteregg accidentally before finding the explanation. "AAAH WHERE IS THE ERASURE COMING FROM AAAA" etc.

    That said, up to the point where I was afraid I wasn't going to be able to read your work without having erasure leap out at me, I quite enjoyed the drawing interface.

  17. Jeff
    June 14th, 2010 at 09:27 #17

    I love this, but unfortunately all kinds of errors are kicked off when using IE8. Is there a fix for IE?

  18. June 14th, 2010 at 11:52 #18

    @Jeff
    It should quit early in IE8. The script is not compatible. I'll have to look into the errors.

  19. June 17th, 2010 at 09:45 #19

    Shoud've used entire Mr. Doob's demo – it's a bit smoother.

  20. June 20th, 2010 at 08:22 #20

    Awesome! So awesome, that I adapted it for cornify.com for drawing rainbows on the background. Next update will also include sparkles.

    I added a detection to the script whether canvas is supported, since I didn't want to bog down old browsers (IE8). I basically just create a canvas element and check if "canvas.getContext" exists. Hope that helps.

    Sparkles!

  21. July 16th, 2010 at 12:22 #21

    Your background is really awesome, always I always come here I spend at least two minutes just drawing around. I've been trying to apply it to a website or a blog but when I apply it to site or my blog it doesn't work and I can't scroll down.
    Could plese make a post about te steps to apply it to website or a blog?
    thanks and regards.

  22. Kai
    August 12th, 2010 at 07:55 #22

    Hey, this is very very very nice!!

    Love your blog and your work..

    Im trying to expand your code.
    i want to have a background image behind the canvas.
    if you draw the lines, the background should appear.
    so its like you will paint with transparent color.
    is that possible?

    regards kai

  23. August 16th, 2010 at 06:57 #23

    haha awesome background, and i accidentally activated the youtube video, why would you embed THIS video, now i want to play robot unicorn attack… hahah

  24. August 16th, 2010 at 20:15 #24

    @Kai
    I can't help you more but you'll probably be interested in this demo: http://dl.dropbox.com/u/39519/web8demo/draw.html

  25. August 24th, 2010 at 23:44 #25

    This was awsome man…
    Thanks a lot ^^

  26. Kai
    September 6th, 2010 at 04:49 #26

    Thank you!
    Thats what i was looking for!!!!!!!
    Kai
    @Paul Irish

  27. Mr.Somthing
    March 1st, 2011 at 16:33 #27

    how would you put this on a blogger blog.

  28. June 30th, 2011 at 08:38 #28

    The background should appear.
    so its like you will paint with transparent color!!!

  29. February 20th, 2012 at 10:57 #29

    @Paul Irish That preforms REALLY badly on my computer.

For code blocks, use <pre lang="javascript">. css and html4strict are also accepted.