<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mozilla Hacks - the Web developer blog &#187; SVG</title>
	<atom:link href="http://hacks.mozilla.org/category/svg/feed/" rel="self" type="application/rss+xml" />
	<link>http://hacks.mozilla.org</link>
	<description>hacks.mozilla.org</description>
	<lastBuildDate>Wed, 08 Feb 2012 22:52:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Foxkeh&#8217;s Wallpaper Creator: practical SVG application</title>
		<link>http://hacks.mozilla.org/2010/07/foxkehs-wallpaper-creator-practical-svg-application/</link>
		<comments>http://hacks.mozilla.org/2010/07/foxkehs-wallpaper-creator-practical-svg-application/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 02:42:19 +0000</pubDate>
		<dc:creator>dynamis</dc:creator>
				<category><![CDATA[Demo]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[SVG]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5480</guid>
		<description><![CDATA[When we make graphical web applications, we may use Canvas and SVG. Comparing SVG with Canvas, SVG is suitable to make applications with these features: use large images with smooth lines (SVG is vector graphics) edit size, position, shape or colors of images (easy to change) clip, mask or filter images (SVG supports these features) [...]]]></description>
			<content:encoded><![CDATA[<p>When we make graphical web applications, we may use <a href="http://hacks.mozilla.org/category/canvas/">Canvas</a> and <a href="http://hacks.mozilla.org/category/svg/">SVG</a>. Comparing SVG with Canvas, SVG is suitable to make applications with these features:</p>
<ul>
<li>use large images with smooth lines (SVG is vector graphics)</li>
<li>edit size, position, shape or colors of images (easy to change)</li>
<li>clip, mask or filter images (SVG supports these features)</li>
<li>user interactive objects (DOM events can be added to SVG elements)</li>
</ul>
<p>To demonstrate these advantages of SVG, Mozilla Japan has made a practical web application with SVG. &#8220;Foxkeh&#8217;s Wallpaper Creator&#8221; is a tool that allows you to easily create your own wallpaper in your browser. Not only can you choose Foxkeh and background image, you can easily change the size, position and transparency of Foxkeh and calender image.</p>
<p>I believe this application is enough easy to use and no more explanation is needed.</p>
<p>Just try creating wallpaper and realize how SVG is useful for web applications!</p>
<p><a href="http://wallpapers.foxkeh.com/en/">http://wallpapers.foxkeh.com/en/</a></p>
<p><a href="http://hacks.mozilla.org/2010/07/foxkehs-wallpaper-creator-practical-svg-application/foxkehwallpapercreator/" rel="attachment wp-att-5481"><img src="http://hacks.mozilla.org/wp-content/uploads/2010/07/foxkehwallpapercreator-500x350.png" alt="Screenshot of Foxkeh&#039;s Wallpaper Creator" title="Foxkeh&#039;s Wallpaper Creator" width="500" height="350" class="alignnone size-large wp-image-5481" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/07/foxkehs-wallpaper-creator-practical-svg-application/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Firefox 4: the HTML5 parser &#8211; inline SVG, speed and more</title>
		<link>http://hacks.mozilla.org/2010/05/firefox-4-the-html5-parser-inline-svg-speed-and-more/</link>
		<comments>http://hacks.mozilla.org/2010/05/firefox-4-the-html5-parser-inline-svg-speed-and-more/#comments</comments>
		<pubDate>Tue, 11 May 2010 15:55:26 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Firefox]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[SVG]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4685</guid>
		<description><![CDATA[This is a guest post from Henri Sivonen, who has been working on Firefox&#8217;s new HTML5 parser. The HTML parser is one of the most complicated and sensitive pieces of a browser. It controls how your HTML source is turned into web pages and as such changes to it are rare and need to be [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is a guest post from <a href="http://hsivonen.iki.fi/">Henri Sivonen</a>, who has been working on Firefox&#8217;s new HTML5 parser.  The HTML parser is one of the most complicated and sensitive pieces of a browser.  It controls how your HTML source is turned into web pages and as such changes to it are rare and need to be well-tested.  While most of Gecko has been rebuilt since its initial inception in the late 90s, the parser was one of the stand-outs as being &#8220;original.&#8221;  This replaces that code with a new parser that&#8217;s faster, compliant with the new HTML5 standard and enables a lot of new functionality as well.</em></p>
<p>A project to replace Gecko’s old HTML parser, dating from 1998, has been ongoing for some time now. The parser was just turned on by default on the trunk, so you can now try it out by simply <A HREF="http://nightly.mozilla.org/">downloading a nightly build</A> without having to flip any configuration switch.</p>
<p>There are four main things that improve with the new HTML5 parser:</p>
<ul>
<li>You can now use SVG and MathML inline in HTML5 pages, without XML namespaces.
<li>Parsing is now done off Firefox&#8217;s main UI thread, improving overall browser responsiveness.
<li>It&#8217;s improved the speed of <CODE>innerHTML</CODE> calls by about 20%.
<li>With the landing of the new parser we&#8217;ve fixed <a href="https://bugzilla.mozilla.org/buglist.cgi?status_whiteboard_type=substring&#038;status_whiteboard=[fixed%20by%20the%20HTML5%20parser]&#038;resolution=FIXED">dozens of long-standing parser related bugs</a>.
</ul>
<p>
<strong><a href="http://hsivonen.iki.fi/test/moz/html5-hacks-demo.html">Try the demo with a</a> <a href="http://nightly.mozilla.org">Firefox Nightly</a> or another HTML5-ready browser.  It should look like this:</a></strong>
</p>
<p>
<a href="http://hsivonen.iki.fi/test/moz/html5-hacks-demo.html"><img src="http://hacks.mozilla.org/wp-content/uploads/2010/05/html5-parser.png"/></a>
</p>
<p><strong>What Is It?</strong></p>
<p>The HTML5 parser in Gecko turns a stream of bytes into a DOM tree according to the <A HREF="http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html">HTML5 parsing algorithm</A>. </p>
<p>HTML5 is the first specification that tells implementors, in detail, how parse HTML. Before HTML5, HTML specifications didn’t say how to turn a stream of bytes into a DOM tree. In theory, HTML before HTML5 was supposed to be defined in terms of SGML. This implied a certain relationship between the source of valid HTML documents and the DOM. However, parsing wasn’t well-defined for invalid documents (and Web content most often isn’t valid HTML4) and there are SGML constructs that were in theory part of HTML but that in reality popular browsers didn’t implement.</p>
<p>The lack of a proper specification led to browser developers filling in the blanks on their own and reverse engineering the browser with the largest market share (first Mosaic, then Netscape, then IE) when in doubt about how to get compatible behavior. This led to a lot of unwritten common rules but also to different behavior across browsers.</p>
<p>The HTML5 parsing algorithm standardizes well-defined behavior that browsers and other applications that consume HTML can converge on. By design, the HTML5 parsing algorithm is suitable for processing existing HTML content, so applications don’t need to continue maintaining their legacy parsers for legacy content. Concretely, in the trunk nightlies, the HTML5 parser is used for all <CODE>text/html</CODE> content.</p>
<p><strong>How Is It Different?</strong></p>
<p>The HTML5 parsing algorithm has two major parts: tokenization and tree building. Tokenization is the process of splitting the source stream into tags, text, comments and attributes inside tags. The tree building phase takes the tags and the interleaving text and comments and builds the DOM tree. The tokenization part of the HTML5 parsing algorithm is closer to what Internet Explorer does than what Gecko used to do. Internet Explorer has had the majority market share for a while, so sites have generally been tested not to break when subjected to IE’s tokenizer. The tree building part is close to what WebKit does already. Of the major browser engines WebKit had the most reasonable tree building solution prior to HTML5.</p>
<p>Furthermore, the new HTML5 parser parses network streams off the main thread. Traditionally, browsers have performed most tasks on the main thread. Radical changes like off-the-main-thread parsing are made possible by the more maintainable code base of the HTML5 parser compared to Gecko’s old HTML parser.</p>
<p><strong>What’s In It for Web Developers?</strong></p>
<p>The changes mentioned above are mainly of interest to browser developers. A key feature of the HTML5 parser is that you don’t notice that anything has changed.</p>
<p>However, there is one big new Web developer-facing feature, too: inline MathML and SVG. HTML5 parsing liberates MathML and SVG from XML and makes them available in the main file format of the Web.</p>
<p>This means that you can include typographically sophisticated math in your HTML document without having to recast the entire document as XHTML or, more importantly, without having to retrofit the software that powers your site to output well-formed XHTML. For example, you can now include the solution for quadratic equations inline in HTML:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;math<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>x<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>=<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mfrac<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mrow<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;minus;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>b<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;PlusMinus;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;msqrt<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;msup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>b<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/msup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;minus;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>4<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;InvisibleTimes;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>a<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;InvisibleTimes;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>c<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/msqrt<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mrow<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mrow<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;InvisibleTimes;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>a<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mrow<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mfrac<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/math<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Likewise, you can include scalable inline art as SVG without having to recast your HTML as XHTML. As screen sized and pixel densities become more varied, making graphics look crisp at all zoom levels becomes more important. Although it has previously been possible to use SVG graphics in HTML documents by reference (using the <CODE>object</CODE> element), putting SVG inline is more convenient in some cases. For example, an icon such as a warning sign can now be included inline instead of including it from an external file.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;svg</span> <span style="color: #000066;">height</span>=86 <span style="color: #000066;">width</span>=90 <span style="color: #000066;">viewBox</span>=<span style="color: #ff0000;">'5 9 90 86'</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">'float: right;'</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;path</span> <span style="color: #000066;">stroke</span>=#F53F0C <span style="color: #000066;">stroke-width</span>=10 <span style="color: #000066;">fill</span>=#F5C60C <span style="color: #000066;">stroke-linejoin</span>=round <span style="color: #000066;">d</span>=<span style="color: #ff0000;">'M 10,90 L 90,90 L 50,14 Z'</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;line</span> <span style="color: #000066;">stroke</span>=black <span style="color: #000066;">stroke-width</span>=10 <span style="color: #000066;">stroke-linecap</span>=round <span style="color: #000066;">x1</span>=50 <span style="color: #000066;">x2</span>=50 <span style="color: #000066;">y1</span>=45 <span style="color: #000066;">y2</span>=75 <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/svg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Make yourself a page that starts with <code>&lt;!DOCTYPE html&gt;</code> and put these two pieces of code in it and it should work with a new nightly.</p>
<p>In general, if you have a piece of MathML or SVG as XML, you can just copy and paste the XML markup inline into HTML (omitting the XML declaration and the doctype if any). There are two caveats: The markup must not use namespace prefixes for elements (i.e. no <CODE>svg:svg</CODE> or <CODE>math:math</CODE>) and the namespace prefix for the XLink namespace has to be <CODE>xlink</CODE>.</p>
<p>In the MathML and SVG snippits above you’ll see that the inline MathML and SVG pieces above are more HTML-like and less crufty than merely XML pasted inline. There are no namespace declarations and unnecessary quotes around attribute values have been omitted. The quote omission works, because the tags are tokenized by the HTML5 tokenizer—not by an XML tokenizer. The namespace declaration omission works, because the HTML5 tree builder doesn’t use attributes looking like namespace declarations to assign MathMLness or SVGness to elements. Instead, <CODE>&lt;svg&gt;</CODE> establishes a scope of elements that get assigned to the SVG namespace in the DOM and <CODE>&lt;math&gt;</CODE> establishes a scope of elements that get assigned to the MathML namespace in the DOM. You’ll also notice that the MathML example uses named character references that previously haven’t been supported in HTML.</p>
<p>Here’s a quick summary of inline MathML and SVG parsing for Web authors:</p>
<ul>
<li><CODE>&lt;svg&gt;</CODE>…<CODE>&lt;/svg&gt;</CODE> is assigned to the SVG namespace in the DOM.
<li><CODE>&lt;math&gt;</CODE>…<CODE>&lt;/math&gt;</CODE> is assigned to the MathML namespace in the DOM.
<li><CODE>foreignObject</CODE> and <CODE>annotation-xml</CODE> (an various less important elements) establish a nested HTML scope, so you can nest SVG, MathML and HTML as you’d expect to be able to nest them.
<li>The parser case-corrects markup so <CODE>&lt;SVG VIEWBOX=&#8217;0 0 10 10&#8242;&gt;</CODE> works in HTML source.
<li>The DOM methods and CSS selectors behave case-sensitively, so you need to write your DOM calls and CSS selectors using the canonical case, which is camelCase for various parts of SVG such as <CODE>viewBox</CODE>.
<li>The syntax <CODE>&lt;foo/&gt;</CODE> opens and immediately closes the <CODE>foo</CODE> element if it is a MathML or SVG element (i.e. not an HTML element).
<li>Attributes are tokenized the same way they are tokenized in HTML, so you can omit quotes in the same situations where you can omit quotes in HTML (i.e. when the attribute value is not the empty string and does not contain whitespace, <CODE>&quot;</CODE>, <CODE>&#8216;</CODE>, <CODE>`</CODE>, <CODE>&lt;</CODE>, <CODE>=</CODE>, or <CODE>&gt;</CODE>).
<li><B>Warning:</B> the two above features do not combine well due to the reuse of legacy-compatible HTML tokenization. If you omit quotes on the last attribute value, you must have a space before the closing slash. <CODE>&lt;circle fill=green /&gt;</CODE> is OK but <CODE>&lt;circle fill=red/&gt;</CODE> is not.
<li>Attributes starting with <CODE>xmlns</CODE> have <I>absolutely no effect</I> on what namespace elements or attributes end up in, so you don’t need to use attributes starting with <CODE>xmlns</CODE>.
<li>Attributes in the XLink namespace must use the prefix <CODE>xlink</CODE> (e.g. <CODE>xlink:href</CODE>).
<li>Element names must not have prefixes or colons in them.
<li>The content of SVG <CODE>script</CODE> elements is tokenized like they are tokenized in XML—not like the content of HTML <CODE>script</CODE> elements is tokenized.
<li>When an SVG or MathML element is open <CODE>&lt;![CDATA[</CODE>…<CODE>]]&gt;</CODE> sections work the way they do in XML. You can use this to hide text content from older browsers that don’t support SVG or MathML in <CODE>text/html</CODE>.
<li>The MathML named characters are available for use in named character references everywhere in the document (also in HTML content).
<li>To deal with legacy pages where authors have pasted partial SVG fragments into HTML (who knows why) or used a <CODE>&lt;math&gt;</CODE> tag for non-MathML purposes, attempts to nest various common HTML elements as children of SVG elements (without <CODE>foreignObject</CODE>) will immediately break out of SVG or MathML context. This may make some typos have surprising effects.
</ul>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/05/firefox-4-the-html5-parser-inline-svg-speed-and-more/feed/</wfw:commentRss>
		<slash:comments>66</slash:comments>
		</item>
		<item>
		<title>Mozilla developer preview (Gecko 1.9.3a1) available for download</title>
		<link>http://hacks.mozilla.org/2010/02/mozilla-developer-preview-gecko-1-9-3a1-available-for-download/</link>
		<comments>http://hacks.mozilla.org/2010/02/mozilla-developer-preview-gecko-1-9-3a1-available-for-download/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 22:01:32 +0000</pubDate>
		<dc:creator>Alix Franquet</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[SVG]]></category>
		<category><![CDATA[WebGL]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=3956</guid>
		<description><![CDATA[Editor’s note: Today, Mozilla released a preview of the Gecko 1.9.3 platform for developers and testers. Check out the Mozilla Developer News announcement reposted below. A Mozilla Developer Preview of improvements in the Gecko layout engine is now available for download. This is a pre-release version of the Gecko 1.9.3 platform, which forms the core [...]]]></description>
			<content:encoded><![CDATA[<p><em>Editor’s note: Today, Mozilla released a preview of the Gecko 1.9.3 platform for developers and testers. Check out the <a href="http://bit.ly/bayY7k">Mozilla Developer News</a> announcement reposted below.</em></p>
<p>A Mozilla Developer Preview of improvements in the Gecko layout engine is now available for download. This is a pre-release version of the Gecko 1.9.3 platform, which forms the core of rich Internet applications such as Firefox. <strong>Please note that this release is intended for developers and testers only.</strong> As always, we appreciate any <a href="http://hendrix.mozilla.org/">feedback</a> you may have and encourage users to help us by <a href="http://developer.mozilla.org/en/docs/Bug_writing_guidelines">filing bugs</a>.</p>
<p>This developer preview introduces several new features, including:</p>
<ul>
<li>Support for <a href="http://www.w3.org/TR/css3-transitions/">CSS Transitions</a>. This support is not quite complete: support for animation of transforms and gradients has not yet been implemented.</li>
<li>Support for SMIL Animation in SVG. Support for animating some SVG attributes is still under development and the <code>animateMotion</code> element isn&#8217;t supported yet.</li>
<li>Support for <a href="https://developer.mozilla.org/en/WebGL">WebGL</a>, which is disabled by default but can be enabled by changing a preference. See <a href="http://hacks.mozilla.org/2009/09/webgl-for-firefox/">this blog post</a> and <a href="http://hacks.mozilla.org/2009/12/webgl-draft-released-today/">this blog post</a> for more details.</li>
<li>Support for the <code>getClientRects</code> and <code>getBoundingClientRect</code> methods on <code>Range</code> objects.  See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=396392">bug 396392</a> for details.</li>
<li>Support for the <code>setCapture</code> and <code>releaseCapture</code> methods on DOM elements. See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=503943">bug 503943</a> for details.</li>
<li>Support for the <a href="https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history#Adding_and_modifying_history_entries">HTML5 <code>History.pushState()</code> and <code>History.replaceState()</code> methods and the <code>popstate</code> event</a>. See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=500328">bug 500328</a> for details.</li>
<li>Support for the <code>-moz-image-rect()</code> value for <code><a href="https://developer.mozilla.org/en/CSS/background-image">background-image</a></code>. See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=113577">bug 113577</a> for more details.</li>
</ul>
<p>and several other significant changes, including:</p>
<ul>
<li>On Mac OS X, we render text using Core Text rather than ATSUI.</li>
<li>We rewrote major parts of the code for handling scrolling. See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=526394">bug 526394</a> for details.</li>
<li>We rewrote the way a snapshot of a document is taken in order to print or print preview.  See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=487667">bug 487667</a> for details.</li>
<li>We made significant changes to table border handling. See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=452319">bug 452319</a> and <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=43178">bug 43178</a> for details.</li>
<li>We made various architectural changes to improve Web page        performance.</li>
</ul>
<p>More information on these changes is in the <a href="http://www.mozilla.org/projects/firefox/3.7a1/releasenotes/">release notes</a>, as well as the <a href="https://developer.mozilla.org/en/Upcoming_Firefox_features_for_developers">Upcoming Firefox features for developers</a> article on the <a href="https://developer.mozilla.org/">Mozilla Developer Center</a>.</p>
<p>Please use the following links when downloading this Mozilla Developer Preview:</p>
<ul>
<li><a href="http://download.mozilla.org/?product=devpreview-1.9.3a1&amp;os=win&amp;lang=en-US">Installer for Windows</a></li>
<li><a href="http://download.mozilla.org/?product=devpreview-1.9.3a1&amp;os=osx&amp;lang=en-US">DMG for Mac OS X (10.5 or better required)</a></li>
<li><a href="http://download.mozilla.org/?product=devpreview-1.9.3a1&amp;os=linux&amp;lang=en-US">Archive for Linux</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/02/mozilla-developer-preview-gecko-1-9-3a1-available-for-download/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>pointer-events for HTML in Firefox 3.6</title>
		<link>http://hacks.mozilla.org/2009/12/pointer-events-for-html-in-firefox-3-6/</link>
		<comments>http://hacks.mozilla.org/2009/12/pointer-events-for-html-in-firefox-3-6/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 15:59:32 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[Feature]]></category>
		<category><![CDATA[Featured Demo]]></category>
		<category><![CDATA[Firefox 3.6]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[SVG]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=2647</guid>
		<description><![CDATA[The pointer-events CSS property has long been available as part of SVG as a way to control if a mouse event should be sent to the element directly underneath the mouse or passed through to an element underneath it. In Firefox 3.6 we&#8217;ve extended the property to allow it to apply to normal HTML content [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="https://developer.mozilla.org/en/CSS/pointer-events"><code>pointer-events</code></a> CSS property has long been available as part of SVG as a way to control if a mouse event should be sent to the element directly underneath the mouse or passed through to an element underneath it.  In Firefox 3.6 we&#8217;ve extended the property to allow it to apply to normal HTML content as well.</p>
<p>For SVG you can set the <code>pointer-events</code> property to one of several values, but for HTML you can only set it to one of two values: <code>auto</code> or <code>none</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.foo</span> <span style="color: #00AA00;">&#123;</span>
  pointer-events<span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>When <code>pointer-events</code> is set to <code>none</code>, pointer events are passed through the target element and are instead sent to the element that is underneath it.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.foo</span> <span style="color: #00AA00;">&#123;</span>
  pointer-events<span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>When <code>pointer-events</code> is set to <code>auto</code>, pointer events are handled normally.  That is, the element blocks the events from being passed down to a lower element.</p>
<p><a href="http://demos.hacks.mozilla.org/openweb/pointer-events/">Here&#8217;s a real world example from Paul Rouget</a>.  You will need a <a href="http://www.mozilla.com/en-US/firefox/all-beta.html">Firefox 3.6 beta</a> to see it in action.</p>
<p>Click the <code>pointer-events: none</code> checkbox under the image to see it change.</p>
<p>He&#8217;s replicated the tag list that&#8217;s on the front page of <a href="http://twitter.com">twitter.com</a>.  (Note: you have to not be logged in to see the tag list.)  If you go and look at it on twitter you&#8217;ll notice that it fades off on the right hand side.  This is done with a transparent, faded image that sits on top of the underlying box.  The tags underneath are clickable links but the image blocks events from being sent to the ones underneath the fade.</p>
<div><a href="http://demos.hacks.mozilla.org/openweb/pointer-events/"><img src="http://hacks.mozilla.org/wp-content/uploads/2009/11/faded-twitter.png" alt="" /></a></div>
<p>What Paul has done is show how you can use the <code>pointer-events</code> property to allow you to click on the underlying links even with a fade on top of it.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2009/12/pointer-events-for-html-in-firefox-3-6/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>exploring music with the audio tag</title>
		<link>http://hacks.mozilla.org/2009/06/exploring-music-audio/</link>
		<comments>http://hacks.mozilla.org/2009/06/exploring-music-audio/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 00:28:49 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[35 Days]]></category>
		<category><![CDATA[Audio]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[Firefox 3.5]]></category>
		<category><![CDATA[SVG]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=1066</guid>
		<description><![CDATA[Today&#8217;s demo comes to us from Samuel Goldszmidt. He&#8217;s a web developer specializing in audio applications at Institut de Recherche et Coordination Acoustique/Musique (IRCAM). IRCAM is a European institute covering science, sound and avant garde electro-acoustical art music. The demo uses XML to describe the various segments of a piece of music &#8211; Florence Baschet&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p><em>Today&#8217;s <a href="http://apm.ircam.fr/page/audio-tag/">demo</a> comes to us from Samuel Goldszmidt.  He&#8217;s a web developer specializing in audio applications at Institut de Recherche et Coordination Acoustique/Musique (<a href="http://www.ircam.fr/ircam.html?&#038;L=1">IRCAM</a>).  IRCAM is a European institute covering science, sound and avant garde electro-acoustical art music.</em></p>
<p>The demo uses XML to describe the various segments of a piece of music &#8211; Florence Baschet&#8217;s <em>StreicherKreis (Circle of Strings)</em>.  The music itself is a combination of stringed instruments and electronic effects.  From the XML, SVG is generated for each section of the music.  You can click on each section to listen to that part of the piece and a description is shown on how that particular section was created.</p>
<p>As far as demos go, this is relatively simple.  But it&#8217;s worth highlighting because it shows how easy it is to build a timeline around a piece of music and add descriptive information.  In this case, it&#8217;s information meant to teach people how a particular effect was created.  But it could be anything, from showing different camera angles of people playing the music to links about different covers of a popular piece.  Opening up media to the web means that we can combine it with text, images and other media.  This is just a small example.</p>
<div align="center" style="font-size: 120%"><a target="_blank" href="http://apm.ircam.fr/page/audio-tag/">View the Demo in Firefox 3.5<br/><img src="http://hacks.mozilla.org/wp-content/uploads/2009/06/ircam.png"/></a></div>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2009/06/exploring-music-audio/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>using SVG and APNG to create an animated texture map</title>
		<link>http://hacks.mozilla.org/2009/06/svg-apng-animated-texture/</link>
		<comments>http://hacks.mozilla.org/2009/06/svg-apng-animated-texture/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 07:29:29 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Demo]]></category>
		<category><![CDATA[Firefox 3.5]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[SVG]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=879</guid>
		<description><![CDATA[Yesterday we featured a demo that used SVG to map 3D data. Today we link to Hans&#8217; next demo: dynamically textured animations in the browser. He uses the same techniques that he used in the previous post, but this time he&#8217;s taking an Animated PNG image and mapping a random image texture on top of [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday we featured a demo that used <a href="http://hacks.mozilla.org/2009/06/svg-filter-3d-data/">SVG to map 3D data</a>.  Today we link to Hans&#8217; next demo: <a href="http://www.tapper-ware.net/stable/web.filter.apng.dynamicTexture/index.xhtml">dynamically textured animations in the browser</a>.</p>
<p>He uses the same techniques that he used in the previous post, but this time he&#8217;s taking an Animated PNG image and mapping a random image texture on top of it using his <a href="http://www.tapper-ware.net/2009/05/perspective-texture-with-6-lines-of-svg.html">SVG projection technique</a>.  The result is pretty neat.  Have a look at the demo:</p>
<div align="center" style="font-size: 120%">
<a target="_blank" href="http://www.tapper-ware.net/stable/web.filter.apng.dynamicTexture/index.xhtml">View the Demo in Firefox 3.5<br/><img src="http://www.tapper-ware.net/stable/web.filter.apng.dynamicTexture/texture.marshmallow.png"></a>
</div>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2009/06/svg-apng-animated-texture/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>using svg filters to display 3D data</title>
		<link>http://hacks.mozilla.org/2009/06/svg-filter-3d-data/</link>
		<comments>http://hacks.mozilla.org/2009/06/svg-filter-3d-data/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 06:03:49 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[35 Days]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[Firefox 3.5]]></category>
		<category><![CDATA[SVG]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=789</guid>
		<description><![CDATA[This demo is from Hans Schmucker, who has made a large number of interesting demos using Firefox 3.5 features. Tomorrow we&#8217;ll also have another neat demo from him as well. Hans has used the CSS filter property and an SVG filter to do something really interesting &#8211; rendering a 3D perspective from Voxel data. Hans&#8217; [...]]]></description>
			<content:encoded><![CDATA[<p><em>This demo is from <a href="http://www.tapper-ware.net/">Hans Schmucker</a>, who has made a large number of interesting demos using Firefox 3.5 features.  Tomorrow we&#8217;ll also have another neat demo from him as well.</em></p>
<p>Hans has used the <a href="https://developer.mozilla.org/web-tech/2008/09/15/svg-effects-for-html-content/">CSS <code>filter</code> property</a> and an <a href="https://developer.mozilla.org/En/SVG_in_Firefox">SVG filter</a> to do something really interesting &#8211; rendering a 3D perspective from <a href="http://en.wikipedia.org/wiki/Voxel">Voxel</a> data.  Hans&#8217; comment at the bottom of the demo is quite flattering:</p>
<blockquote><p>Frankly, I didn&#8217;t expect this to work, primarily because the filter is very, very long. It needs to process around 30 operations to generate each frame (4 operations for each of the 5 layers + 5 for the texture + 3 for the texture transformation), and that&#8217;s with a 768&#215;512 surface. It&#8217;s not very difficult to understand, but there&#8217;s simply a lot of processing needed and the speed at which Firefox renders this is nothing short of amazing.</p></blockquote>
<p>If you&#8217;re interested in background also make sure to check out Hans&#8217; post <a href="http://www.tapper-ware.net/2009/05/perspective-texture-with-6-lines-of-svg.html"><em>Perspective texture with 6 lines of SVG</em></a> where he explains how to use filters to create this effect.  Anyway, have a look at the demo &#8211; it&#8217;s very interesting.</p>
<div align="center" style="font-size: 120%"><a target="_blank" href="http://www.tapper-ware.net/stable/web.filter.voxels/index.xhtml">View the Demo in Firefox 3.5<img src="http://www.tapper-ware.net/stable/web.filter.voxels/screen.png"/></a></div>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2009/06/svg-filter-3d-data/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>the tristan washing machine</title>
		<link>http://hacks.mozilla.org/2009/06/tristan-washing-machine/</link>
		<comments>http://hacks.mozilla.org/2009/06/tristan-washing-machine/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 05:05:38 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[35 Days]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[Firefox 3.5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[SVG]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=659</guid>
		<description><![CDATA[This is another demo from Paul Rouget. It&#8217;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 This puts a HTML5-based &#60;video&#62; element into an SVG document like so: &#60;svg:svg xmlns:svg=&#34;http://www.w3.org/2000/svg&#34; width=&#34;194&#34; height=&#34;194&#34;&#62; &#60;svg:foreignObject x=&#34;1&#34; y=&#34;1&#34; width=&#34;192&#34; height=&#34;192&#34;&#62; &#60;html:video src=&#34;tristan3.ogv&#34; [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is another demo from <a href="http://blog.mozbox.org">Paul Rouget</a>.  It&#8217;s a very simple demonstration of what you can do when you combine video, SVG and some fun transformations.</em></p>
<p><a target="_blank" href="http://people.mozilla.com/~prouget/demos/round/index.xhtml"></p>
<div align="center" style="font-size: 120%">
View the Demo in Firefox 3.5<br />
<img src="http://hacks.mozilla.org/wp-content/uploads/2009/06/tristan.jpg" alt="tristan" title="tristan" width="210" height="228" class="aligncenter size-full wp-image-661" />
</div>
<p></a></p>
<p>This puts a HTML5-based &lt;video&gt; element into an SVG document like so:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;svg:svg xmlns:svg<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/2000/svg&quot;</span></span>
<span style="color: #009900;">               <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;194&quot;</span> <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;194&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;svg:foreignObject x<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1&quot;</span> y<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;192&quot;</span> <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;192&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;html:video <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tristan3.ogv&quot;</span> ontimeupdate<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;rotateMePlease()&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>svg:foreignObject&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>svg:svg&gt;</span></pre></div></div>

<div style="font-size: 90%">
Lots of code and many attributes removed for clarity.  Please view the source for more details.
</div>
<p>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&#8217;re also using some of the <a href="https://developer.mozilla.org/En/Applying_SVG_effects_to_HTML_content">CSS and SVG capabilities that are in Firefox 3.5</a> to define the player as well.  For example if you look at the CSS you will see:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#video</span> <span style="color: #00AA00;">&#123;</span>
    filter<span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc00cc;">#filter</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
    clip-path<span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc00cc;">#circle</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>The <code><a href="https://developer.mozilla.org/En/Applying_SVG_effects_to_HTML_content#Example.3a.c2.a0Clipping">clip-path</a></code> property lets you define a clip path for any element &#8211; html, svg or otherwise.  This can be <em>extremely</em> 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&#8217;s what our clip path looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;svg:clipPath <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;circle&quot;</span> clipPathUnits<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;objectBoundingBox&quot;</span>&gt;</span>
   <span style="color: #009900;">&lt;svg:circle cx<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0.5&quot;</span> cy<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0.5&quot;</span> r<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0.5&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>svg:clipPath&gt;</span></pre></div></div>

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

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;svg:filter <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;filter&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;svg:feColorMatrix values<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0.3 0.3 0.3 0 0 0.3 0.3 0.3 0 0 0.3 0.3 0.3 0 0 0 0 0 1 0&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>svg:filter&gt;</span></pre></div></div>

<p>Although it is not used in this demo note that you can also use SVG to <a href="https://developer.mozilla.org/En/Applying_SVG_effects_to_HTML_content#Example.3a.c2.a0Masking">define gradient masks</a> for any element in Firefox 3.5 as well.</p>
<p>When the video runs it uses the <a href="http://hacks.mozilla.org/2009/06/3d-transforms-isocube/">transformation</a> property to rotate the video while it&#8217;s playing:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> rotateMePlease<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// Sure</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>video<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
    video.<span style="color: #660066;">style</span>.<span style="color: #660066;">MozTransform</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'rotate('</span> <span style="color: #339933;">+</span> i <span style="color: #339933;">+</span> <span style="color: #3366CC;">'deg)'</span><span style="color: #339933;">;</span>
    i <span style="color: #339933;">+=</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>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 <a href="https://developer.mozilla.org/web-tech/2008/10/10/svg-external-document-references/">SVG External Document References</a>.  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:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.target</span> <span style="color: #00AA00;">&#123;</span> clip-path<span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span>resources<span style="color: #6666ff;">.svg</span><span style="color: #cc00cc;">#c1</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>What this does is load the SVG from the resources.svg file and then use the object with the ID &#8220;c1&#8243; 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.</p>
<p>I hope that this gives you a taste of what&#8217;s possible when mixing SVG, HTML, video and CSS all together.  Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2009/06/tristan-washing-machine/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>audio player &#8211; HTML5 style</title>
		<link>http://hacks.mozilla.org/2009/06/audio-player-html5/</link>
		<comments>http://hacks.mozilla.org/2009/06/audio-player-html5/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 01:34:36 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[35 Days]]></category>
		<category><![CDATA[Audio]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[SVG]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=555</guid>
		<description><![CDATA[Last week we featured a demo from Alistair MacDonald (@F1LT3R) where he showed how to animate SVG with Canvas and a bunch of free tools. This week he has another demo for us that shows how you can use the new audio element in Firefox 3.5 with some canvas and JS to build a nice-looking [...]]]></description>
			<content:encoded><![CDATA[<p>Last week we featured a demo from <a href="http://hyper-metrix.com/">Alistair MacDonald</a> (<a href="http://twitter.com/F1LT3R">@F1LT3R</a>) where he showed how to <a href="http://hacks.mozilla.org/2009/06/rendering-svg-canvas-burst/">animate SVG with Canvas</a> and a bunch of free tools.  This week he has another demo for us that shows how you can use the new <a href="https://developer.mozilla.org/En/Using_audio_and_video_in_Firefox">audio element in Firefox 3.5</a> with some canvas and JS to build a nice-looking audio player.</p>
<div align="center" style="font-size: 120%">
<a target="_blank" href="http://hyper-metrix.com/misc/jai/"><br />
View the Demo in Firefox 3.5</br><br />
<img src="http://hacks.mozilla.org/wp-content/uploads/2009/06/jai.jpg" alt="jai" title="jai" width="451" height="309" class="aligncenter size-full wp-image-559" /><br />
</a>
</div>
<p>But what&#8217;s really interesting about this demo is not so much that it plays audio &#8211; lots of people have built audio players &#8211; but how it works.  If you look at the source code for the page what you&#8217;ll find looks something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jai&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;canvas <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jai-transport&quot;</span> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;320&quot;</span> <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;20&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>canvas&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;playlist&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;@F1LT3R - Cryogenic Unrest.ogg&quot;</span>&gt;</span>
        F1LT3R - Cryogenic Unrest
      <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
      <span style="color: #009900;">&lt;audio <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;@F1LT3R - Cryogenic Unrest.ogg&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>.
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;@F1LT3R - Ghosts in HyperSpace.ogg&quot;</span>&gt;</span>
        F1LT3R - Ghosts in HyperSpace
      <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
      <span style="color: #009900;">&lt;audio <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;@F1LT3R - Ghosts in HyperSpace.ogg&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>.       
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>    
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<div style="font-size: 80%">(The actual list has fallbacks and is more compact &#8211; cleaned up here for easier reading.)</div>
<p>That&#8217;s right &#8211; the player above is just a simple HTML unordered list that happens to include audio elements and is styled with CSS.  You&#8217;ll notice that if you right click on one of them that it has all the usual items &#8211; save as, bookmark this link, copy this link location, etc.  You can even poke at it with Firebug.</p>
<p>The JavaScript driver that Al has written will look for a <code>&lt;div&gt;</code> element with the <code>jai</code> ID and then look for any audio elements that are inside it.  It then will draw the playback interface in the canvas at the top of the list.  The playback interface is built with simple JS canvas calls and an SVG-derived font.</p>
<p>Using this driver it&#8217;s super-easy to add an audio player to any web site by just defining a canvas and a list.  Much like what we&#8217;ve seen on a lot of the web with the rise of useful libraries like jQuery, this library can add additional value to easily-defined markup.  Another win for HTML5 and the library model.</p>
<p>Al has a much <a href="http://hyper-metrix.com/misc/jai/">larger write-up on the same page as the demo</a>.  If you haven&#8217;t read through it you should now.</p>
<p>(Also?  Al wrote the music himself.  So awesome.)</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2009/06/audio-player-html5/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
		<item>
		<title>animating SVG with canvas and burst</title>
		<link>http://hacks.mozilla.org/2009/06/rendering-svg-canvas-burst/</link>
		<comments>http://hacks.mozilla.org/2009/06/rendering-svg-canvas-burst/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 01:49:04 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[35 Days]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[Firefox 3.5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[SVG]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=21</guid>
		<description><![CDATA[Today&#8217;s demo is short, but it also includes a long screencast that describes how it&#8217;s put together. The demo&#8217;s author, Alistair MacDonald (@F1LT3R), is one of the maintainers of Processing.js and the Burst engine, which is the basis for today&#8217;s demo and tutorial. If you haven&#8217;t clicked through to his site, I strongly suggest that [...]]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s demo is short, but it also includes a long screencast that describes how it&#8217;s put together.  The demo&#8217;s author, <a href="http://hyper-metrix.com/">Alistair MacDonald</a> (<a href="http://twitter.com/F1LT3R">@F1LT3R</a>), is one of the maintainers of <a href="http://processingjs.org/">Processing.js</a> and the <a href="http://hyper-metrix.com/#Burst">Burst engine</a>, which is the basis for today&#8217;s demo and tutorial.</p>
<p>If you haven&#8217;t clicked through to his <a href="http://hyper-metrix.com/">site</a>, I strongly suggest that you do so.  You&#8217;ll notice that the site is animated and slick-looking with sections that slide in and out and lots of graphics.  It&#8217;s the kind of thing that you normally would see written in flash, but there&#8217;s no flash on the main page.  It&#8217;s all CSS, canvas and animation in the DOM.  Pretty amazing.</p>
<p>On to the demo.  There have been some demos done with animating SVG but there&#8217;s one thing that stands out about this one that makes it different.  Instead of loading SVG natively into the DOM, which is how SVG was originally designed, the Burst engine loads the SVG, parses it and creates some JS objects around it which you can then use to render it to a canvas.  From there you can quickly animate it with the Burst engine and mix it with other content on a canvas.</p>
<div align="center">
<a href="http://www.hyper-metrix.com/burst/development/doc/demos/js/Burst%20Engine%20-%20Tutorial%202%20-%20SVG%20Groups/"></p>
<div style="font-size: 120%">
View the Demo
</div>
<p><img src="http://hacks.mozilla.org/wp-content/uploads/2009/06/burst-300x225.jpg"/><br />
</a>
</div>
<p>I also strongly suggest that you watch the tutorial on how this demo was put together.  He shows how easy it is to take <a href="http://www.inkscape.org/">inkscape</a>, the Burst engine and other simple JS to take a simple drawing and animate it.  It&#8217;s worth the length of the video.</p>
<div align="center">
<video width="300" src="http://videos.mozilla.org/serv/blizzard/35days/al-macdonald-svg-burst-canvas/Burst%20Engine%20-%20Tutorial%202%20-%20SVG%20Groups,%20Callbacks.ogv" controls><br />
<img src="http://hacks.mozilla.org/wp-content/uploads/2009/06/burst-tutorial-300x224.jpg"/><br />
</video><br />
<a href="http://videos.mozilla.org/serv/blizzard/35days/al-macdonald-svg-burst-canvas/Burst%20Engine%20-%20Tutorial%202%20-%20SVG%20Groups,%20Callbacks.ogv">View Video (.ogv)</a> | <a href="http://videos.mozilla.org/serv/blizzard/35days/al-macdonald-svg-burst-canvas/Burst%20Engine%20-%20Tutorial%202%20-%20SVG%20Groups,%20Callbacks.mp4"> View Video (.mp4)</a>
</div>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2009/06/rendering-svg-canvas-burst/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>add some ambiance to your videos</title>
		<link>http://hacks.mozilla.org/2009/06/add-ambiance-to-your-videos/</link>
		<comments>http://hacks.mozilla.org/2009/06/add-ambiance-to-your-videos/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 12:02:33 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[35 Days]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[Firefox 3.5]]></category>
		<category><![CDATA[SVG]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=15</guid>
		<description><![CDATA[Note: this post was originally posted to the silverorange labs blog and was written by Mike Gauthier. Mike and other people at silverorange put this demo together for the 35 days project and we thank them. Also note that the demo below is extremely CPU-intensive. If you&#8217;re interested in the effect and you don&#8217;t have [...]]]></description>
			<content:encoded><![CDATA[<p><em>Note: this post was <a href="http://labs.silverorange.com/archive/2009/may/ambiance">originally posted to the silverorange</a> labs blog and was written by <a href="http://labs.silverorange.com/author/gauthierm">Mike Gauthier</a>.  Mike and other people at <a href="http://www.silverorange.com/">silverorange</a> put this demo together for the 35 days project and we thank them.</em></p>
<p><em>Also note that the demo below is extremely CPU-intensive.  If you&#8217;re interested in the effect and you don&#8217;t have a really fast CPU you can just watch a screencast of the effect.</em></p>
<p><em>Last note: <strong>This demo requires Firefox 3.5 Beta99 or later.</strong>.  If you have <a href="http://www.mozilla.com/en-US/firefox/all-beta.html">Beta 4</a> installed you should be able to use Help -> Check for updates&#8230; to get to the latest beta.  Beta 4 included a bug where video data couldn&#8217;t be copied to the canvas.</em></p>
<p>Our work with Mozilla led us to do some experiments on what can be done with the new HTML5 functionality in Firefox 3.5. With &lt;canvas&gt; and the new HTML5 &lt;video&gt; element, we created a demo that pulls color information out of a live playing video and uses it to style a border around the video. The result is not unlike the tackiest of back-lit LCD tvs.</p>
<div align="center">
<p><a href="http://videos.mozilla.org/serv/blizzard/35days/silverorange-ambient-video/ambient.xhtml"><br />
<font size="+1">View the Demo in Firefox 3.5 Beta99 or Later</font></a></p>
<p><img src="http://labs.silverorange.com/file/ambient-preview.jpg"><br />
<a href="http://videos.mozilla.org/serv/blizzard/35days/silverorange-ambient-video/bbunny-ambient-demo.ogv">View a Screencast of the Demo (Ogg Theora, 4.1MB)</a><br/><a href="http://videos.mozilla.org/serv/blizzard/35days/silverorange-ambient-video/bbunny-ambient-demo.mov">View a Screencast of the Demo (mov, h.264, 4.3MB)</a>
</div>
<p><strong>How It Works</strong></p>
<p>The color calculation is done by drawing video frames to a HTML5 canvas element and then computing the average color of the canvas. To make computing the average color faster, the video frame is resampled onto a smaller canvas (this demo uses 50&#215;50). Color accuracy can be improved at the cost of speed by using a larger canvas. Pushing video frames to the canvas is done as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> canvas <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'canvas'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> video <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'video'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> context <span style="color: #339933;">=</span> canvas.<span style="color: #660066;">getContext</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'2d'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// push frame to canvas</span>
context.<span style="color: #660066;">drawImage</span><span style="color: #009900;">&#40;</span>video<span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> canvas.<span style="color: #660066;">width</span><span style="color: #339933;">,</span> canvas.<span style="color: #660066;">height</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// get image data for color calculation</span>
<span style="color: #003366; font-weight: bold;">var</span> data <span style="color: #339933;">=</span> context.<span style="color: #660066;">getImageData</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> canvas.<span style="color: #660066;">width</span><span style="color: #339933;">,</span> canvas.<span style="color: #660066;">height</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The computed color is then changed over time using a <a href="http://developer.yahoo.com/yui/animation/">YUI animation</a>.</p>
<p>The edges of the video are feathered using an SVG mask. Firefox 3.5 allows SVG masks to be applied to elements using a special <a href="http://people.mozilla.com/~roc/SVG-CSS-Effects-Draft.html">CSS+SVG property</a>. First, an SVG mask is defined inline in the document (note: this could also be defined externally). The mask is then applied to the video element using the following CSS rule:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#video</span> <span style="color: #00AA00;">&#123;</span>
    mask<span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span>index<span style="color: #6666ff;">.html</span><span style="color: #cc00cc;">#m1</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>There are two of other CSS+SVG properties available in FF3.5: <em>clip-path</em> and <em>filter</em>. To reference SVG styles in CSS use <em>url(filename#element-id)</em> or just <em>url(#element-id)</em> if the SVG is defined in the same file as the CSS.</p>
<p>Finally, the demo uses some new HTML CSS 3.0 features from Firefox 3.5. The <a href="https://developer.mozilla.org/En/CSS/-moz-box-shadow">box-shadow</a> property, <a href="https://developer.mozilla.org/En/CSS/Text-shadow">text-shadow</a> property and rgba color model are used:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#main-feature</span> <span style="color: #00AA00;">&#123;</span>
    -moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000</span> <span style="color: #933;">0px</span> <span style="color: #933;">5px</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#description</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0.4</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">1px</span> <span style="color: #933;">1px</span> <span style="color: #933;">2px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2009/06/add-ambiance-to-your-videos/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
<enclosure url="http://videos.mozilla.org/serv/blizzard/35days/silverorange-ambient-video/bbunny-ambient-demo.ogv" length="4264613" type="video/ogg" />
<enclosure url="http://videos.mozilla.org/serv/blizzard/35days/silverorange-ambient-video/bbunny-ambient-demo.mov" length="4504370" type="video/quicktime" />
		</item>
	</channel>
</rss>

