Home
Donovan Preston's Journal
 
[Most Recent Entries] [Calendar View] [Friends View]

Sunday, June 13th, 2004

    Time Event
    11:38a
    Artistic Hacks
    On memorial day weekend, when I was driving back up to Paradise, I drank a Red Bull to stay awake. Having been off caffeine for a while and *never* drinking Red Bull, it got me thinking.

    Arianna and I have been talking about doing a web toy for a while which uses Flash, mixes interactivity with multiple user shared spaces, and lets the user affect the animations and the soundtrack playing in the space. I could have at any point written a one-off chunk of client and server code for implementing this space, but in the car I had a better idea.

    nevow.canvas is the result, and it is an outgrowth of the LivePage philosophy of web application interaction I have been attempting to get off the ground for a few years now. nevow.canvas is a module which has a simple function, canvas(height, width, onload). The result of this function call is an embedded Flash movie in your HTML page of the given height and width. The movie itself never changes (that is to say I am not doing .swf file generation on the server, here); instead, the movie opens a socket connection to the server and the server holds it open until you say to close it.

    Once the Flash movie connects a socket to the server, nevow calls your onload function with a CanvasSocket object. The CanvasSocket object has many very convenient APIs for drawing in the movie. pen, line, fill, curve, gradient, image, and text APIs are all available for you to draw with.

    Since the server holds the socket connection open until you say you are done with it, you are free to perform animations, draw graphs in response to server-side information becoming available, etc. I haven't yet completed mouse and keyboard event handling, but plan to in the near future.

    I have put up a simple demo application which draws some random shapes at http://soundtractor.com:8080/, and the source is available as nevow/canvas.py and nevow/Canvas.as. The demo application is in examples/canvas.tac.

    Hope you enjoy the canvas, and I look forward to performing lots of artistic hacks with it!

    Current Mood: pleased

    << Previous Day 2004/06/13
    [Calendar]

About LiveJournal.com

Advertisement