<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
   <title>mezzoblue</title>
   <link rel="alternate" type="text/html" href="http://mezzoblue.com/" />
   <link rel="self" type="application/atom+xml" href="http://mezzoblue.com/feeds/index-posts.xml" />
   <id>tag:mezzoblue.com,2011://2</id>
   <updated>2011-12-09T22:17:57Z</updated>
   
   <author>
      <name>Dave Shea</name>
      <uri>http://mezzoblue.com/about/dave/</uri>
   </author>


<entry>
   <title>A New Number 1</title>
   <link rel="alternate" type="text/html" href="http://mezzoblue.com/archives/2011/11/01/a_new_number/" />
   <id>tag:mezzoblue.com,2011://2.1460</id>
   
   <published>2011-11-01T18:24:56Z</published>
   <updated>2011-12-09T22:17:57Z</updated>
   
   <summary> Take it with the usual grain of salt that should accompany any news of global browser trends, but, extrapolating out from the 2011 trend in StatCounter&apos;s Global Stats Chrome appears set to surpass IE as the most-used desktop browser...</summary>
   <content type="html" xml:lang="en" xml:base="http://mezzoblue.com/">
      <![CDATA[<a href="http://www.flickr.com/photos/mezzoblue/6302832047/sizes/o/in/photostream/"><img src="http://mezzoblue.com/i/articles/2011/11/graph-sm.gif" width="560" height="279" alt="Browser usage graph showing Chrome surpassing IE in 2012"></a>

<p>Take it with the usual grain of salt that should accompany any news of global browser trends, but, extrapolating out from the 2011 trend in StatCounter's <a href="http://gs.statcounter.com/">Global Stats</a> Chrome appears set to surpass IE as the most-used desktop browser some time next summer. And that will finally end the 13 year domination of the market by Internet Explorer.</p>

<p>Though, I'm a little sad that Chrome's market share is also coming at the expense of Firefox.</p>]]>
      
   </content>
</entry>

<entry>
   <title>Serendipity</title>
   <link rel="alternate" type="text/html" href="http://mezzoblue.com/archives/2011/03/08/serendipity/" />
   <id>tag:mezzoblue.com,2011://2.1459</id>
   
   <published>2011-03-09T05:46:29Z</published>
   <updated>2011-08-16T04:11:39Z</updated>
   
   <summary>How does a photo of a fruit fly breeding chamber lead to the discovery of one&apos;s own lineage back to 14th century France? That&apos;s not a question I&apos;d ever have thought to ask, but this evening I found an answer...</summary>
   <content type="html" xml:lang="en" xml:base="http://mezzoblue.com/">
      <![CDATA[<p>How does a photo of a fruit fly breeding chamber lead to the discovery of one's own lineage back to 14th century France? That's not a question I'd ever have thought to ask, but this evening I found an answer after following the most fascinating click trail in, well, ever.</p>

<p>It started with an idle perusal of recent Flickr photos from my contacts. <a href="http://adactio.com/" rel="met friend bedroll">Jeremy Keith</a> is currently in Chicago for DrupalCon, and after a page of tantalizing food and architectural photos, I found myself back in Brighton looking at his <a href="http://www.flickr.com/photos/adactio/sets/72157626197877306/with/5497876823/">photos</a> from a laboratory-related exhibit at the Lighthouse Gallery.</p>

<p>One especially mundane photo in particular caught my eye, his capture of a <a href="http://www.flickr.com/photos/adactio/5497876823/">placard on a fruit fly breeding chamber</a>. In particular what I noticed was the usage of the Latin genus name <i><a href="http://en.wikipedia.org/wiki/Drosophila">drosophila</a></i>.</p>

<p>I'm quite familiar with the word because Dr. Gordon Tener -- my grandmother's brother and a father figure to my own dad -- had a long career as a professor of biochemistry at the University of British Columbia here in Vancouver. During his tenure he researched, among other things, ribonucleic acid (RNA) and the genetic organization of <a href="http://cshmonographs.org/index.php/monographs/article/view/3388">drosophila melanogaster</a>, otherwise known as the common fruit fly.</p>

<p>Dr. Tener died two years ago, and as I was looking at Jeremy's photo I realized that I may never have punched his name into Google to see what the internet knew about his life and achievements. So I did, and eventually I stumbled across a <a href="http://tenerfamily.com/">Blogger site</a> set up to document the extended family history of the Tener family.</p>

<p>The top of the site references something called the <a href="http://www.riggs.com/tenerbook/id209.htm">Tener Book</a>, which was a genealogy published in the fifties that I'd never heard of. And what do you know, there on page 79 are references to Dr. Tener and my grandmother, which means this book is about <strong>my</strong> family history, back 20 generations through nine centuries and five countries, complete with photos of various great-great-great-great grand-relatives and a family crest I didn't know about.</p>

<div class="block-img image-holder-1up">
<img src="http://mezzoblue.com/i/articles/2011/03/crest.gif" width="436" height="491" alt="Tener family crest">
</div>

<p>All from a photo of a fruit fly breeding chamber.</p>

<p>It's easy to take for granted just how much information we have at our fingertips these days, but then mind-blowingly personal discoveries like this come along every now and then and put it all in sharp focus. The internet is amazing.</p>]]>
      
   </content>
</entry>

<entry>
   <title>Free Icons</title>
   <link rel="alternate" type="text/html" href="http://mezzoblue.com/archives/2011/02/22/free_icons/" />
   <id>tag:mezzoblue.com,2011://2.1458</id>
   
   <published>2011-02-23T00:15:03Z</published>
   <updated>2011-04-10T06:22:26Z</updated>
   
   <summary> I&apos;ve decided to slap a Creative Commons license on the entire darn Chalkwork Family and make them completely free for personal use, starting right now. I&apos;ve been considering doing this for quite a while. These icons represent a lot...</summary>
   <content type="html" xml:lang="en" xml:base="http://mezzoblue.com/">
      <![CDATA[<div class="flRight">
<a href="http://www.mezzoblue.com/icons/chalkwork/"><img src="http://mezzoblue.com/i/icons/icon-sampler.png" width="92" height="86" alt="Chalkwork Icons" /></a>
</div>

<p>I've decided to slap a Creative Commons license on the entire darn <a href="http://www.mezzoblue.com/icons/chalkwork/">Chalkwork Family</a> and make them completely free for personal use, starting right now.</p>

<p>I've been considering doing this for quite a while. These icons represent a lot of hard work for me between 2006 and 2009, so you can imagine I've thought through the implications of making them available for free download without a pay barrier: will people use them commercially and not pay? Will they abuse the license terms? Will some redistribute them elsewhere? Will they modify them and claim them as their own?</p>

<p>The answer to each of those questions is, inevitably, yes. I've been on the web long enough to know that no matter what you intend to happen, someone will always find a way to do the complete opposite of that sooner or later. But you know what? I can live with that.</p> 

<p>I'm of the opinion that <a href="http://www.mezzoblue.com/archives/2006/12/18/merry_drmma/">DRM</a> and <a href="http://www.michaelgeist.ca/index.php?option=com_tags&task=view&tag=c-32&Itemid=411">increasingly consumer-hostile content protection laws</a> are kludgy ways of protecting outdated business models. By offering a product for download, I've effectively been treating the pay barrier as a form of copy-protection all along. Which has worked well enough for my purposes, but if I'm being honest with myself I don't think I really <em>need</em> that protection.</p>

<p>People who appreciate your work do the right thing. Just as <a href="http://boingboing.net/2009/11/01/heavy-illegal-downlo.html">those who download music are more inclined to buy it</a>, my bet is that those who download these icons for personal use may one day come back and pay for commercial use. If they don't, were they ever likely to buy them in the first place? I doubt it.</p>

<p>It's not all philosophy and rhetoric, I'm genuinely curious to see what happens next with the commercial sales since they've been on a steady decline over the years. I tried an AdWords campaign for a while, but that didn't do much to reverse the trend. Will opening them up under a free license provide an extra boost? Maybe, but then maybe I just killed all future sales. Hard to say.</p>

<p>Most of the money I was ever going to make happened at the beginning, the long tail isn't proving that profitable. Sales over the years have at least paid for the time I spent creating the family so I'm happy with the overall return, but there's clearly not much left to lose now so I'm willing to experiment a little.</p>

<p>Share and enjoy.</p>


<p><ins>Note:</ins> if you're having trouble downloading the full files, it's not just you. Downloads appear to be getting cut off halfway through. Lots of data transfer is making weird things happen; I'm looking into it.</p>]]>
      
   </content>
</entry>

<entry>
   <title>Boilerplate</title>
   <link rel="alternate" type="text/html" href="http://mezzoblue.com/archives/2011/01/31/boilerplate/" />
   <id>tag:mezzoblue.com,2011://2.1457</id>
   
   <published>2011-01-31T23:25:04Z</published>
   <updated>2011-02-23T00:15:05Z</updated>
   
   <summary>If you&apos;re not aware of it yet, HTML5 boilerplate is a fantastic starting point when creating a new site with its namesake markup language. But where Boilerplate focuses on basic document setup, external files, scripts, and bug fixes, it strikes...</summary>
   <content type="html" xml:lang="en" xml:base="http://mezzoblue.com/">
      <![CDATA[<p>If you're not aware of it yet, <a href="http://html5boilerplate.com/">HTML5 boilerplate</a> is a fantastic starting point when creating a new site with its namesake markup language.</p>

<p>But where Boilerplate focuses on basic document setup, external files, scripts, and bug fixes, it strikes me that it doesn't do much hand-holding when it comes to basic document semantic patterns. As I've been working more and more HTML5 into my projects, I'm noticing a common template emerging.</p>

<p>I'm sharing this as a minimum viable starting point since I'm still getting comfortable with the new semantics myself. Combined with Boilerplate, I'm feeling more and more confident that I'm beginning to use HTML5 properly. Don't consider it canonical by any means, there's likely a lot of room for improvement and it's most certainly wrong in places. Comments / suggestions for improvement are more than welcome.</p>

<pre><code class="html">&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;meta charset=&quot;utf-8&quot;&gt;
  &lt;title&gt;pageTitle&lt;/title&gt;
  &lt;link rel=&quot;stylesheet&quot; href=&quot;default.css&quot;&gt;
  &lt;script src=&quot;default.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;


&lt;div id=&quot;accessibility&quot;&gt;
  &lt;a href=&quot;#nav&quot;&gt;Skip to Navigation&lt;/a&gt; |
  &lt;a href=&quot;#main-content&quot;&gt;Skip to Content&lt;/a&gt;
&lt;/div&gt;


&lt;header role=&quot;banner&quot;&gt;
  &lt;div class=&quot;masthead&quot;&gt;
    &lt;a href=&quot;#&quot;&gt; ....site title or logo, purposely not an h1.... &lt;/a&gt;
  &lt;/div&gt;
  &lt;nav id=&quot;nav&quot;&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;
        ....main site nav list....
      &lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/nav&gt;
  &lt;div id=&quot;secondary-nav&quot;&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;
        ....other non-primary navigation doesn&#39;t belong in a nav element....
      &lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
&lt;/header&gt;


&lt;section id=&quot;main-content&quot; role=&quot;main&quot;&gt;
  &lt;h1&gt; ....page title here.... &lt;/h1&gt;
  &lt;article&gt;
    &lt;header&gt;
      &lt;h2&gt;....article heading if needed....&lt;/h2&gt;
      &lt;h3&gt;....article sub-heading if needed....&lt;/h3&gt;
    &lt;/header&gt;
    ....article content here....
  &lt;/article&gt;
  &lt;article&gt;
    ....use more article elements if appropriate; if not, I still use divs....
  &lt;/article&gt;
&lt;/section&gt;


&lt;aside id=&quot;sidebar&quot;&gt;
   ....site sidebar here....
&lt;/aside&gt;


&lt;footer&gt;
  .... footer content here ....
&lt;/footer&gt;


&lt;/body&gt;
&lt;/html&gt;</code></pre>

<p>You'll notice I'm a believer in reserving <code>h1</code> headings for the page title, and not the site / company name. I'm still not sure I get how to use the revised <a href="http://www.brucelawson.co.uk/2009/headings-in-html-5-and-accessibility/">heading order</a> so I'm sticking with old school <code>h1</code>-<code>h6</code> for now.</p>

<p>Thanks to the <a href="http://www.w3.org/TR/html-design-principles/#pave-the-cowpaths">pave the cowpaths</a> philosophy that guided HTML5 development, it feels almost too easy. It's not much more than a tweak to my previous XHTML template: change a few <code>id</code>s to their corresponding elements here and there, replace various <code>div</code>s with <code>section</code>s, <code>article</code>s and <code>aside</code>s where relevant, and add / remove extra attributes where necessary. Done.</p>]]>
      
   </content>
</entry>

<entry>
   <title>SSD + Photoshop</title>
   <link rel="alternate" type="text/html" href="http://mezzoblue.com/archives/2010/12/01/ssd_photos/" />
   <id>tag:mezzoblue.com,2010://2.1456</id>
   
   <published>2010-12-01T23:53:48Z</published>
   <updated>2011-02-21T21:57:37Z</updated>
   
   <summary>I just got my first Mac with a solid state drive. If you&apos;ve heard anything about SSD performance, you won&apos;t be surprised to hear that it&apos;s fast. How fast? Well, I filmed a video....</summary>
   <content type="html" xml:lang="en" xml:base="http://mezzoblue.com/">
      <![CDATA[<p>I just got my first Mac with a solid state drive. If you've heard anything about SSD performance, you won't be surprised to hear that it's fast. How fast? Well, I filmed a video.</p>

<object width="560" height="337"><param name="movie" value="http://www.youtube.com/v/wtKrTjsntYc?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/wtKrTjsntYc?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="337"></embed></object>]]>
      
   </content>
</entry>

<entry>
   <title>PaintbrushJS</title>
   <link rel="alternate" type="text/html" href="http://mezzoblue.com/archives/2010/10/07/paintbrushjs/" />
   <id>tag:mezzoblue.com,2010://2.1455</id>
   
   <published>2010-10-07T21:41:34Z</published>
   <updated>2010-11-19T18:44:49Z</updated>
   
   <summary> It occurs to me that I should finally mention here a project I&apos;ve been working on over the past month or so. Much to my surprise, what started out as a simple foray into the canvas element&apos;s pixel manipulation...</summary>
   <content type="html" xml:lang="en" xml:base="http://mezzoblue.com/">
      <![CDATA[
<p>It occurs to me that I should finally mention here a project I've been working on over the past month or so. Much to my surprise, what started out as a simple foray into the canvas element's pixel manipulation APIs quickly evolved into a full-fledged Javascript library called <a href="http://github.com/mezzoblue/PaintbrushJS">PaintbrushJS</a>.</p>

<p>It's basically a set of image filters that render in the browser. Greyscale, sharpening gaussian blur and more on the web, no ImageMagick or GD required. It allows you to take an image like this:</p>

<img src="http://www.mezzoblue.com/i/articles/2010/10/bee.jpg" width="500" height="333" alt="" />

<p>And using a simple class and a couple of HTML5 <code>data-*</code> attributes, render it in a number of different ways:</p>

<img class="filter-blur" src="http://www.mezzoblue.com/i/articles/2010/10/bee-blur.png" width="500" height="333" alt="" />

<img class="filter-sharpen" src="http://www.mezzoblue.com/i/articles/2010/10/bee-sharpen.png" width="500" height="333" alt="" />

<img class="filter-sepia" src="http://www.mezzoblue.com/i/articles/2010/10/bee-sepia.png" width="500" height="333" alt="" />

<img class="filter-greyscale" src="/i/articles/2010/10/bee-greyscale.png" width="500" height="333" alt="" />

<p>I skipped the jQuery and went full Javascript on this one, but it ought to play nice alongside most other Javascript libraries out there. More on <a href="http://mezzoblue.github.com/PaintbrushJS/demo/usage.html">how to use it</a>, and there's a real-time <a href="http://mezzoblue.github.com/PaintbrushJS/demo/">demo page</a> you can play around with. (works best in Safari and Chrome, thanks to their speedy Javascript engines and support for the HTML5 <code>range</code> form input)</p>

<p>Since I'm using <code>canvas</code> to pull this off I'm automatically excluding IE8 and lower from the equation (it works great in the IE9 beta), which meant that I could also save out the images as dataURLs. The upshot? You can use the output images the same way you would any other image within a web page; as a CSS background, as source for a canvas animation, and if you really want, you can even Right Click -&gt; Save As to save the filtered image to your hard drive.</p>

<p>(And this blog template is really starting to show its age. In a fit of irony worthy of an entire extra verse by Alanis, I had to pre-render the effects above and save them as separate images instead of showing them rendering realtime, because the HTML5-friendly PaintbrushJS doesn't play nice with an XHTML doctype.)</p>]]>
      
   </content>
</entry>

<entry>
   <title>A CSS3 Tip</title>
   <link rel="alternate" type="text/html" href="http://mezzoblue.com/archives/2010/07/27/a_css3_tip/" />
   <id>tag:mezzoblue.com,2010://2.1453</id>
   
   <published>2010-07-27T22:38:04Z</published>
   <updated>2010-10-18T20:23:18Z</updated>
   
   <summary>I&apos;m probably way behind the curve on this one, but I recently realized the following: All browsers that support the CSS text-shadow and box-shadow properties also support the new CSS3 RGBa syntax. Which means you can safely combine them today....</summary>
   <content type="html" xml:lang="en" xml:base="http://mezzoblue.com/">
      <![CDATA[<p>I'm probably way behind the curve on this one, but I recently realized the following:</p>

<p>All browsers that support the CSS <code>text-shadow</code> and <code>box-shadow</code> properties also support the new CSS3 RGBa syntax. Which means you can safely combine them today.</p>

<p>That's handy, because it means no worrying about matching a precise hex colour shadow to a specific hex colour background. Instead just let the browser blend. An example:</p>

<pre><code class="css">p {
  text-shadow: rgba(0, 0, 0, 0.2) 0 1px 0;
}</code></pre>

<p style="text-shadow: rgba(0, 0, 0, 0.2) 0 1px 0;">That will produce a paragraph with a 20% opacity black drop shadow that will blend into any background colour below it. A paragraph like this one.</p>

<p>Previously I might have created the drop shadow in Photoshop, then used the eye dropper tool to pull out the composited shadow hex value after the transparency was applied to the background colour. No more!</p>]]>
      
   </content>
</entry>

<entry>
   <title>IE8 Still Failing PNG Alpha</title>
   <link rel="alternate" type="text/html" href="http://mezzoblue.com/archives/2010/05/20/ie8_still_fa/" />
   <id>tag:mezzoblue.com,2010://2.1452</id>
   
   <published>2010-05-20T21:48:38Z</published>
   <updated>2010-10-12T18:43:57Z</updated>
   
   <summary>You thought our long nightmare of PNG alpha transparency support was finally over as of IE7, didn&apos;t you? Yeah, me too. Over the past few months I&apos;ve been collaborating with Chris Glass on the newly-launched Joyent site. (When someone comes...</summary>
   <content type="html" xml:lang="en" xml:base="http://mezzoblue.com/">
      <![CDATA[<p>You thought our long nightmare of PNG alpha transparency support was finally over as of IE7, didn't you? Yeah, me too.</p>

<p>Over the past few months I've been collaborating with <a href="http://chrisglass.com/">Chris Glass</a> on the newly-launched <a href="http://joyent.com/">Joyent</a> site. (When someone comes to you and says, hey, we have Chris Glass helping us out with this project and we'd like the two of you to work together, you jump at that chance.)</p>

<p>I was tossing around ideas for building an <a href="http://www.joyent.com/technology/">interactive infographic</a> Chris had designed, and thought of at least four different ways of pulling it off. We're reaching this interesting point with front end web technology where we now have actual choices besides Flash for jobs like this. I considered CSS3 animations and the Canvas element before ultimately deciding on PNGs with alpha transparency and jQuery transitions and fades.</p>

<p>I put off browser testing as long as I could, but just this week prior to launch I realized it was very broken in all versions of Internet Explorer. I had a plan to back out to a static graphic in IE6, assuming IE7 and IE8 would treat the PNG + animation combo like any other reasonably modern browser. I was wrong.</p>

<p>It seems that IE's implementation of PNGs with alpha transparency is still buggy or incomplete in some way. When you place a PNG with alpha on a static page, you'll never be the wiser. It's when you adjust the opacity of that PNG that you run into problems. Take the following example:</p>

<ul id="test-1" style="width: 550px; overflow: hidden; padding: 20px 0;">
	<li style="float: left; width: 150px; background: #fff; text-align: center; margin-right: 30px; padding: 20px 0;">
	<img src="http://mezzoblue.com/articles/supplements/2010/05/triangles.png" width="89" height="251" alt="" />
	</li>
	<li style="float: left; width: 150px; background: url(http://mezzoblue.com/articles/supplements/2010/05/bg1.jpg); text-align: center; margin-right: 30px; padding: 20px 0; -webkit-border-radius: 20px; -moz-border-radius: 20px; border-radius: 20px;">
	<img src="http://mezzoblue.com/articles/supplements/2010/05/triangles.png" width="89" height="251" alt="" />
	</li>
	<li style="float: left; width: 150px; background: url(http://mezzoblue.com/articles/supplements/2010/05/bg2.jpg); text-align: center; margin-right: 30px; padding: 20px 0; -webkit-border-radius: 20px; -moz-border-radius: 20px; border-radius: 20px;">
	<img src="http://mezzoblue.com/articles/supplements/2010/05/triangles.png" width="89" height="251" alt="" />
	</li>
</ul>

<p>I'm overlaying this slightly-transparent image of three triangles atop a few different backgrounds. So far so good. IE7 and IE8 keep up. But if I apply further transparency to the image in the form of a jQuery <code>fadeIn</code> or an opacity value, things go a little haywire:</p>

<ul id="test-2" style="width: 550px; overflow: hidden; padding: 20px 0;">
	<li style="float: left; width: 150px; background: #fff; text-align: center; margin-right: 30px; padding: 20px 0;">
	<img src="http://mezzoblue.com/articles/supplements/2010/05/triangles.png" width="89" height="251" alt="" />
	</li>
	<li style="float: left; width: 150px; background: url(http://mezzoblue.com/articles/supplements/2010/05/bg1.jpg); text-align: center; margin-right: 30px; padding: 20px 0; -webkit-border-radius: 20px; -moz-border-radius: 20px; border-radius: 20px;">
	<img src="http://mezzoblue.com/articles/supplements/2010/05/triangles.png" width="89" height="251" alt="" />
	</li>
	<li style="float: left; width: 150px; background: url(http://mezzoblue.com/articles/supplements/2010/05/bg2.jpg); text-align: center; margin-right: 30px; padding: 20px 0; -webkit-border-radius: 20px; -moz-border-radius: 20px; border-radius: 20px;">
	<img src="http://mezzoblue.com/articles/supplements/2010/05/triangles.png" width="89" height="251" alt="" />
	</li>
</ul>

<p>That's the same setup as before, only with an opacity value of 0.99 (almost completely opaque) applied to each <code>img</code> element. In non-IE browsers, the previous two examples ought to look the same. In IE7 and IE8 on the other hand, the previous example instead looks like this next one:</p>

<img src="http://mezzoblue.com/articles/supplements/2010/05/nicejob.jpg" width="510" height="295" alt="IE rendering" style="margin: 20px 0;" />

<p>Of course, no version of IE supports the CSS <code>opacity</code> property yet, so jQuery instead applies the opacity by exploiting the IE-proprietary AlphaImageLoader filter. This ends up being the root cause of the (<a href="http://groups.google.com/group/jquery-dev/browse_thread/thread/1f693c5f4e8ea650/f49280e7958bac7d?lnk=gst&amp;q=fade+transparent+png&amp;pli=1">seemingly well-known</a>) bug. The suggested fix is to apply the transparency to the parent element instead, but I've had little success with that workaround.</p>

<p>What did work was a little library called <a href="http://www.dillerdesign.com/experiment/DD_belatedPNG/">DD_belatedPNG</a> that applies PNG transparency via VML instead of AlphaImageLoader. It's designed for IE6, but it works just fine in IE7 as well. For IE8, I was forced to throw out an <a href="http://msdn.microsoft.com/en-us/library/cc288325(VS.85).aspx">X-UA-Compatible</a> meta tag and step IE8 down to IE7 mode for this particular page.</p>

<p>It's still not perfect. I noticed a faint white bounding box poking through at lower opacities that forced me to slightly adjust hover effects for all versions of IE. But you know, for all that, it's darn well good enough.</p>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">

$(document).ready(function(){


	$("#test-2 li img").css({
		opacity: 0.99
	});

});
</script>]]>
      
   </content>
</entry>

<entry>
   <title>Smaller PNGs</title>
   <link rel="alternate" type="text/html" href="http://mezzoblue.com/archives/2010/04/15/smaller_pngs/" />
   <id>tag:mezzoblue.com,2010://2.1451</id>
   
   <published>2010-04-16T05:23:55Z</published>
   <updated>2010-11-19T18:44:42Z</updated>
   
   <summary>Last week I put together an animated infographic that required some flexibility. Alpha transparency was essential, but the number of images I needed to pull it off meant that my typical way of creating PNGs wasn&apos;t going to work. Let&apos;s...</summary>
   <content type="html" xml:lang="en" xml:base="http://mezzoblue.com/">
      <![CDATA[<p>Last week I put together an animated infographic that required some flexibility. Alpha transparency was essential, but the number of images I needed to pull it off meant that my typical way of creating PNGs wasn't going to work.</p>

<p>Let's be honest; Photoshop is absolutely terrible at saving transparent PNGs for web use. Your choices are between an 8-bit with 1-bit transparency (better than a GIF in terms of file size, but no better in terms of transparency options) or a huge 32-bit PNG with alpha transparency. There's no middle ground. You can run the resulting files through various PNG reduction utilities (<a href="http://advsys.net/ken/utils.htm">PNGOUT</a>, <a href="http://pmt.sourceforge.net/pngcrush/">Pngcrush</a>, or my personal favourite <a href="http://www.brothersoft.com/pngthing-245069.html">PngThing</a>) but when the savings are a few hundred bytes off an 80KB file, the returns are slim.</p>

<p>I'm not in the practice of using Fireworks, so those of you who do can start gloating now. But as I thought about the problem a bit, I remembered that Fireworks has a few more options. Specifically, I remembered that you can save out 8-bit PNGs with alpha transparency, which seemed like the right mix.</p>

<p>And the resulting lower byte counts were respectable: 95KB &rsaquo; 11.7KB. 28KB &rsaquo; 4.6KB. 38KB &rsaquo; 8.9KB. 36KB &rsaquo; 7.1KB. 45KB &rsaquo; 7.3KB. 28KB &rsaquo; 4.7KB. etc.</p>

<p>When I casually mentioned the smaller files I was able to produce on Twitter I was a little surprised by the response. Seems that a lot of people don't know about this, so a quick write-up feels like it's in order. Here's my process.</p>

<h3>1. Save out a full 32bit PNG from Photoshop</h3>
<p>Any file format with transparency will do really. You could probably even just open the PSD. But I start here.</p>

<h3>2. Load it into Fireworks.</h3>

<h3>3. In the Optimize palette, adjust the settings to PNG 8.</h3>
<p>You'll probably want to go further and find a colour level less than 256 that works with your image for more savings, but this is the starting point anyway.</p>
<div class="block-img image-holder-1up">
<img src="http://www.mezzoblue.com/articles/supplements/2010/04/fireworks.png" width="500" height="236" alt="screenshot of Fireforks Optimization panel" />
<p class="caption"><span class="caption-title">Figure:</span> an image open in Fireworks with the Optimize panel shown, adjusted to PNG 8, 32 colours, with Alpha Transparency selected.</p>
</div>

<h3>4.Export.</h3>
<p>File &gt; Export, then pick a spot for your smaller file.<p>

<p>And that's basically it. Clearly this only works for images that would normally do well with lower colour levels, you won't be using this for photographic elements any time soon. But for those that work, you can throw the result through one of the previously-mentioned optimization tools to shave off a few more bytes too.</p>]]>
      
   </content>
</entry>

<entry>
   <title>Illustrator to HTML5&apos;s Canvas</title>
   <link rel="alternate" type="text/html" href="http://mezzoblue.com/archives/2010/01/14/illustrator_/" />
   <id>tag:mezzoblue.com,2010://2.1450</id>
   
   <published>2010-01-15T02:15:29Z</published>
   <updated>2010-04-05T19:35:47Z</updated>
   
   <summary>I&apos;ve spent a bit of time playing around with HTML5&apos;s canvas element lately. It&apos;s a fun new toy and has a lot of potential to be useful. But the biggest headache I&apos;m finding so far is the lack of authoring...</summary>
   <content type="html" xml:lang="en" xml:base="http://mezzoblue.com/">
      <![CDATA[<p>I've spent a bit of time playing around with HTML5's <code>canvas</code> element lately. It's a fun new toy and has a lot of potential to be useful. But the biggest headache I'm finding so far is the lack of authoring tools.</p>

<p>SVG has been around for ages, whereas Canvas is still relatively new. (Mozilla's <a href="http://blog.vlad1.com/">Vladimir Vukićević</a> has a <a href="http://people.mozilla.com/~vladimir/xtech2006/">good overview presentation</a> of the differences between the two, and when and where to use each.) SVG support is built into plenty of graphic editing tools; Canvas support is so far sadly lacking, although <a href="http://www.bestkungfu.com/">Matt May</a> pointed me to <a href="http://www.youtube.com/watch?v=bP98Tfc4WWg">this YouTube video</a> that shows off the upcoming Canvas support Adobe's CS5 suite will have, whenever it becomes available.</p>

<p>In the meantime, most of the Canvas demos we've seen thus far have mostly  featured simple primitive shapes like lines and ellipses for good reason: it's too hard to build up a reasonably complex vector image by manually plotting bezier curves.</p>

<p>Over the past few days I've tried out various ways to get around this problem. I came up with two methods of taking vector shapes out of Illustrator and rendering them with Canvas, both involving an intermediate step as SVG first.</p>

<p>So to start, from Illustrator (or any other vector editing application capable of doing so) export your artwork to SVG. You'll find the SVG option in the Save As / Save a Copy dialog, and I've found the SVG profile you choose doesn't really make much of a difference (though for the sake of argument I've been using 1.1).</p>

<p>We'll use this happy little cloud image as our reference file:</p>

<div class="block-img image-holder-1up">
	<iframe src="http://www.mezzoblue.com/articles/supplements/2010/01/happy-cloud.svg" width="200" height="200"></iframe>

	<p><a href="http://www.mezzoblue.com/articles/supplements/2010/01/happy-cloud.svg">(download the SVG file)</a></p>
</div>

<h3>1) Manually</h3>

<p>This method is only theoretical so if you're looking for the actual how-to, skip ahead to #2. I figure it might be worth writing this up anyway because, even though I couldn't get it working, perhaps it'll provide enough of a starting point for someone else to pick up where I left off and build a proper converter.</p>

<p>SVG and Canvas are both essentially vector drawing tools; Canvas is more pixel-oriented, but you are certainly able to plot lines and curves mathematically. Canvas is also limited to fewer primitive shapes, but there are obvious parallels between the two.</p>

<p>I spent a bit of time looking into the bezier commands in particular. In SVG, to plot a bezier curve, you do something like this:</p>

<pre><code class="svg">  &lt;path d="C x1,y1 x2,y2 x,y" /&gt;
</code></pre>

<p>In Canvas, it's this instead:</p>

<pre><code class="javascript">  ctx.bezierCurveTo(x1,y1, x2,y2, x,y);
</code></pre>

<p>Different syntax, but the same basic components: you're drawing a line from the current pen position to the x, y value, and before that you have two additional points (x1, y1 and x2, y2) that set your handles. (More <a href="http://tutorials.jenkov.com/svg/path-element.html">SVG path commands</a>, <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#complex-shapes-(paths)">Canvas path methods</a>.) It's worth noting that SVG is more forgiving about commas; each coordinate must be separated by a comma for the Canvas method, but they're strictly optional in the SVG example. This is relevant because Illustrator's SVG export seems to be wildly inconsistent about when and how many commas each command uses.</p>

<p>Given the similarities, I thought it might be fairly straightforward to manually tweak the SVG output into Canvas drawing functions. <code>M</code> becomes <code>moveTo</code>, <code>C</code> becomes <code>bezierCurveTo</code>, and so forth.</p>

<pre><code class="svg">  &lt;path d="
    M 62.58, 31.96
    c -0.711,0 -1.811,0.062 -3.181,0.165
    c -0.566 -6.309 -5.862 -11.255 -12.318 -11.255
    c -2.363,0 -4.564,0.675 -6.442,1.824 "/&gt;
</code></pre>

<p>Becomes:</p>

<pre><code class="javascript">  ctx.moveTo(62.58, 31.96);
  ctx.bezierCurveTo(-0.711,0,-1.811,0.062,-3.181,0.165);
  ctx.bezierCurveTo(-0.566,-6.309,-5.862,-11.255,-12.318,-11.255);
  ctx.bezierCurveTo(-2.363,0,-4.564,0.675,-6.442,1.824);
</code></pre>


<p>This did not work. I suspect the absolute vs. relative coordinate difference between SVG's <code>c</code> and <code>C</code> commands tripped me up, but after a half hour or so of poking around this was all I had to show for it:</p>

<div class="block-img image-holder-1up">
<canvas id="ctx" width="200" height="100"></canvas>
<script>
function fill(){

	var canvas=document.getElementById('ctx');
	if (!canvas.getContext) return;
	var c=canvas.getContext('2d');

	c.fillStyle="#4a6481";	
	c.beginPath();
	c.moveTo(62.58, 31.96);
	c.bezierCurveTo(-0.711,0, -1.811,0.062, -3.181,0.165);
	c.bezierCurveTo(-0.566,-6.309,-5.862,-11.255,-12.318,-11.255);
	c.bezierCurveTo(-2.363,0,-4.564,0.675,-6.442,1.824);
	c.bezierCurveTo(-2.888,-2.688,-6.748,-4.344,-11.003,-4.344);
	c.bezierCurveTo(-8.934,0,-16.174,7.241,-16.174,16.175);
	c.bezierCurveTo(0,0.797,0.077,1.573,0.188,2.339);
	c.bezierCurveTo(7.187,37.298, 2.075, 42.663, 2.075, 49.236);
	c.bezierCurveTo(0, 6.855, 5.558, 12.413, 12.413, 12.413);
	c.bezierCurveTo(5.761, 0, 41.874, 0, 48.092, 0);
	c.bezierCurveTo(8.197, 0, 14.844 -6.646, 14.844 -14.846);
	c.bezierCurveTo(77.424, 38.607, 70.777, 31.96, 62.58, 31.96);
	c.closePath();
	c.fill();
}

fill();
</script>
</div>


<p>Still, even if I'd have managed to get it right, I'd rather not have to manually massage my SVG output every time I want a new Canvas drawing. Which leads me to method #2.</p>

<h3>2) Automatically</h3>

<p>One of the main reasons I bothered to attempt a manual conversion in the first place was because after an extensive search it appeared that people are mostly interested in converting <a href="http://code.google.com/p/canvas-svg/">Canvas to SVG</a>. There are very few articles and tools that cover going the other way, which is what we're after. Maybe I didn't come up with exactly the right search term, but I was finding so little I almost gave up entirely.</p>

<p>Then after one last shot in the dark, I managed to stumble across <a href="http://code.google.com/p/lindenb/wiki/SVGToCanvas">SVGToCanvas</a>, a Java library that promised to do exactly what it sounds like, with a few disclaimers and a major caveat:</p>

<ul>
	<li><strong>You need Java 6.</strong> Otherwise known as 1.6, this comes installed with Mac OS X Snow Leopard but previous versions will need to upgrade. I believe <a href="http://support.apple.com/downloads/Java_for_Mac_OS_X_10_5_Update_1">this</a> is the download necessary for Leopard, if you're on an even older version you're on your own. No idea what the Windows situation is, but <a href="http://www.java.com/en/download/index.jsp">this might be a good place to start</a>.</li>
	
	<li><strong>You need to run it on the command line.</strong> I know this will freak out some designers, but really, it's not terribly difficult.</li>
	
	<li><strong>You mainly get outlines for now.</strong> This would be the big ugly caveat. Sometimes you get colour and gradients, sometimes you get mixed-up colour and gradients, mostly you don't. Plan to re-add them manually. Hopefully this will work better in a future version of the library, but still, having outlines is a solid start.</li>
</ul>

<p>Still with me? Great, go grab the JAR file and drop it on your hard drive somewhere easy to find. For now, probably best to drop it in the same folder with the SVG files you're going to convert.</p>

<p>Now, load up the terminal, and find your way to the same directory. Here's a <a href="http://www.ee.surrey.ac.uk/Teaching/Unix/unix1.html">quick command line primer</a> that ought to get you going. The <code>cd</code>, <code>ls</code>, and <code>pwd</code> commands in particular are the ones you need.</p>

<p>(If you need a bit more help than that: put the SVG and JAR files in a folder on your Desktop called 'canvas'. When you open up the terminal, type this minus quotes: '<kbd>cd ~/Desktop/canvas</kbd>'. Hit return. You're good, keep reading.)</p>

<p>Run the converter with the following command:</p>

<pre><kbd>  java -jar svg2canvas.jar -o cloud.html cloud.svg</kbd></pre>

<p>From left to right: we're invoking Java with the SVGToCanvas library, then by <kbd>-o cloud.html</kbd> we're specifying the output will be written to <kbd>cloud.html</kbd>, otherwise it just displays the output in the terminal (which can be handy if you'd like to just copy and paste without managing temporary files). Then finally at the end, <kbd>cloud.svg</kbd> is the input SVG file that we had previously generated from Illustrator.</p>

<p>That generates an HTML file which contains a <code>canvas</code> element and the Javascript necessary to render the cloud:</p>


<div class="block-img image-holder-1up">
<canvas id='ctx1263521617450' width='200' height='200'></canvas>
<script>/* generated with svg2canvas by Pierre Lindenbaum http://plindenbaum.blogspot.com plindenbaum@yahoo.fr */function paint1263521617450(){var canvas=document.getElementById('ctx1263521617450');if (!canvas.getContext) return;var c=canvas.getContext('2d');c.fillStyle="white";c.strokeStyle="black";c.globalAlpha="1.0";c.lineWidth="1";c.lineCap="butt";c.lineJoin="round";c.mitterLimit="1";c.fillStyle="#496480";c.beginPath();c.moveTo(156.85,80.25);c.bezierCurveTo(155.10,80.25,152.43,80.39,149.04,80.64);c.bezierCurveTo(147.65,65.14,134.63,52.99,118.77,52.99);c.bezierCurveTo(112.97,52.99,107.55,54.62,102.94,57.43);c.bezierCurveTo(95.85,50.84,86.35,46.80,75.90,46.80);c.bezierCurveTo(53.95,46.80,36.15,64.60,36.15,86.55);c.bezierCurveTo(36.15,88.49,36.30,90.40,36.57,92.27);c.bezierCurveTo(20.71,93.35,8.17,106.56,8.17,122.70);c.bezierCurveTo(8.17,139.54,21.83,153.20,38.68,153.20);c.bezierCurveTo(52.83,153.20,141.57,153.20,156.85,153.20);c.bezierCurveTo(177.00,153.20,193.33,136.87,193.33,116.72);c.bezierCurveTo(193.33,96.58,176.99,80.25,156.85,80.25);c.closePath();c.moveTo(102.02,87.16);c.bezierCurveTo(102.02,84.18,104.43,81.77,107.41,81.77);c.lineTo(108.18,81.77);c.bezierCurveTo(111.16,81.77,113.57,84.18,113.57,87.16);c.lineTo(113.57,100.55);c.bezierCurveTo(113.57,103.53,111.16,105.94,108.18,105.94);c.lineTo(107.41,105.94);c.bezierCurveTo(104.43,105.94,102.02,103.53,102.02,100.55);c.lineTo(102.02,87.16);c.closePath();c.moveTo(76.78,87.16);c.bezierCurveTo(76.78,84.18,79.19,81.77,82.17,81.77);c.lineTo(82.94,81.77);c.bezierCurveTo(85.92,81.77,88.33,84.18,88.33,87.16);c.lineTo(88.33,100.55);c.bezierCurveTo(88.33,103.53,85.92,105.94,82.94,105.94);c.lineTo(82.17,105.94);c.bezierCurveTo(79.19,105.94,76.78,103.53,76.78,100.55);c.lineTo(76.78,87.16);c.closePath();c.moveTo(126.80,120.33);c.bezierCurveTo(123.12,129.11,110.68,135.02,95.83,135.02);c.bezierCurveTo(95.83,135.02,68.54,129.11,64.87,120.33);c.bezierCurveTo(63.97,118.17,64.98,115.70,67.13,114.80);c.bezierCurveTo(69.29,113.90,71.76,114.91,72.66,117.07);c.bezierCurveTo(74.59,121.67,83.36,126.57,95.83,126.57);c.bezierCurveTo(108.30,126.57,117.08,121.67,119.00,117.07);c.bezierCurveTo(119.90,114.92,122.38,113.90,124.53,114.80);c.bezierCurveTo(126.68,115.70,127.70,118.17,126.80,120.33);c.closePath();c.fill();c.stroke();}paint1263521617450();</script>
</div>


<p>In this case it worked, though it added a stroke. When it's just the outline, you can restore the colour by manually tweaking the code. Add a <code>fillStyle</code> method before the draw, and a <code>fill</code> after:</p>

<pre><code class="javascript">  ctx.fillStyle(#4a6481);

  ... (drawing commands here) ..

  ctx.fill();
</code></pre>

<p>Not too difficult for simple shapes. I'd hate to have to manually re-add the subtle gradients for more complicated illustrations, but it's nice to know the outline conversion is fairly robust:</p>


<div class="block-img image-holder-2up">
	<iframe src="http://www.mezzoblue.com/articles/supplements/2010/01/globe.svg" width="240" height="210"></iframe>
	<iframe src="http://www.mezzoblue.com/articles/supplements/2010/01/globe.html" width="240" height="210"></iframe>
	<p class="caption"><span class="caption-title">Figure:</span> SVG original on the left, the converted Canvas version on the right.</p>
</div>


<p>One more thing: I'd recommend flattening the vector art as much as possible. Join shapes that can be joined, expand effects and compound paths and masks, and generally clean up the artwork to as few points as possible. Smaller file sizes, more chance of success upon conversion.</p>

<p>So there you go. It's still a fairly painful way to get your vector work into a <code>canvas</code>, but until we get some better tools or built-in support for our existing tools, it's one way to fill the gap.</p>]]>
      
   </content>
</entry>

</feed>

