the tristan washing machine

This is another demo from Paul Rouget. It’s a very simple demonstration of what you can do when you combine video, SVG and some fun transformations.

View the Demo in Firefox 3.5
tristan

This puts a HTML5-based <video> element into an SVG document like so:


  
    
  

Lots of code and many attributes removed for clarity. Please view the source for more details.

If you look at the rest of the source code you will also see that the rest of the player is also defined and controlled from SVG. And we’re also using some of the CSS and SVG capabilities that are in Firefox 3.5 to define the player as well. For example if you look at the CSS you will see:

#video {
    filter: url(#filter);
    clip-path: url(#circle);
}

The <a href="https://developer.mozilla.org/En/Applying_SVG_effects_to_HTML_content#Example.3a.c2.a0Clipping">clip-path</a> property lets you define a clip path for any element – html, svg or otherwise. This can be extremely powerful and can be any arbitrary path defined in SVG. Much like a cookie cutter this cuts out the center of the otherwise square video and uses that for display. Here’s what our clip path looks like:


   

The <a href="https://developer.mozilla.org/En/Applying_SVG_effects_to_HTML_content#Example.3a.c2.a0Filtering">filter</a> property lets you define an SVG filter to use in the same way as a clip path. In our case we use a feColorMatrix:


  

Although it is not used in this demo note that you can also use SVG to define gradient masks for any element in Firefox 3.5 as well.

When the video runs it uses the transformation property to rotate the video while it’s playing:

function rotateMePlease() {
    // Sure
    if (!video) return;
    video.style.MozTransform='rotate(' + i + 'deg)';
    i += 3;
}

You will notice that Paul built this into an XHTML document, carefully using namespaces and XML syntax. But most people would probably want to use SVG in plain-old-HTML. In Firefox 3.5 there is a way to do this using SVG External Document References. What this means is that instead of defining your SVG in the HTML file directly you can define it in its own file and refer to it through CSS like this:

.target { clip-path: url(resources.svg#c1); }

What this does is load the SVG from the resources.svg file and then use the object with the ID “c1” as the clip path for the target. This is a very easy way to add SVG to your document without making the full switch to XHTML.

I hope that this gives you a taste of what’s possible when mixing SVG, HTML, video and CSS all together. Enjoy!

About Christopher Blizzard

Making the web better, one release at a time.

More articles by Christopher Blizzard…


20 comments

  1. Thomas Broyer

    Makes me think of the demos from Microsoft showing how XAML/WPF is powerful ;-)

    June 18th, 2009 at 01:17

  2. Ken Saunders

    Wow, that’s so very cool (and funny).
    Great demonstration.

    June 18th, 2009 at 02:18

  3. Quezako

    How many degrees washes a Tristan? ;)

    June 18th, 2009 at 03:15

  4. Jason Orendorff

    This is cool, but it would have been cooler if Tristan had been blowing bubbles.

    June 18th, 2009 at 13:25

  5. […] 原文地址:the tristan washing machine 系列地址:颠覆网络35天 […]

    June 18th, 2009 at 22:20

  6. N

    I just love how the video controls rotate with the video :-)

    June 24th, 2009 at 02:08

  7. […] Open video in the background, CSS mask (yes, real masking) using a vector image (SVG, not some pixelated jpeg/png/gif), javascript to turn the video frame around (no it’s not the camcorder that’s being rotated). http://hacks.mozilla.org/2009/06/tristan-washing-machine/ […]

    June 26th, 2009 at 00:44

  8. belarmino

    espero la copia ya que poseeo el 3.0

    July 2nd, 2009 at 19:55

  9. […] se pueden ver un par de ejemplos en Firefox 3.5: http://hacks.mozilla.org/2009/06/tristan-washing-machine y http://people.mozilla.com/~prouget/demos/DynamicContentInjection/play.xhtml. ¡Es increíble lo […]

    July 2nd, 2009 at 21:44

  10. […] se pueden ver un par de ejemplos en Firefox 3.5: http://hacks.mozilla.org/2009/06/tristan-washing-machine y http://people.mozilla.com/~prouget/demos/DynamicContentInjection/play.xhtml. ¡Es increíble lo […]

    July 3rd, 2009 at 11:46

  11. […] se pueden ver un par de ejemplos en Firefox 3.5: http://hacks.mozilla.org/2009/06/tri…ashing-machine y http://people.mozilla.com/~prouget/d…ion/play.xhtml. ¡Es increíble lo que podemos hacer […]

    July 3rd, 2009 at 18:00

  12. […] se pueden ver un par de ejemplos en Firefox 3.5: http://hacks.mozilla.org/2009/06/tri…ashing-machine y http://people.mozilla.com/~prouget/d…ion/play.xhtml. ¡Es increíble lo que podemos hacer […]

    July 4th, 2009 at 00:21

  13. […] http://hacks.mozilla.org/2009/06/tristan-washing-machine […]

    July 4th, 2009 at 04:06

  14. […] se pueden ver un par de ejemplos en Firefox 3.5: http://hacks.mozilla.org/2009/06/tristan-washing-machine y http://people.mozilla.com/~prouget/demos/DynamicContentInjection/play.xhtml. ¡Es increíble lo […]

    July 6th, 2009 at 15:26

  15. […] usando tecnologías web como CSS y SVG.Aquí se pueden ver un par de ejemplos en Firefox 3.5: http://hacks.mozilla.org/2009/06/tristan-washing-machine y http://people.mozilla.com/~prouget/demos/DynamicContentInjection/play.xh…. ¡Es increíble lo […]

    July 7th, 2009 at 06:00

  16. […] some new snazzy new CSS features, you can do some really fantastic things. Take a look at the infamous washing machine demo, in which I subject an esteemed colleague to some rotation. It uses several CSS […]

    July 7th, 2009 at 20:05

  17. yareli

    ola is yo español is a liceo hipainme name is yareli tem 9 años

    November 16th, 2009 at 10:06

  18. […] 19. The tristan washing machine […]

    January 25th, 2011 at 22:09

  19. […] 19. The tristan washing machine […]

    July 28th, 2011 at 19:08

  20. […] 19. The tristan washing machine […]

    March 28th, 2012 at 23:53

Comments are closed for this article.