<?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>Tucker Watson&#187; HTML5</title>
	<atom:link href="http://tuckwat.com/blog/tag/html5/feed/" rel="self" type="application/rss+xml" />
	<link>http://tuckwat.com/blog</link>
	<description>Software development - Flex, Niagara AX, oBIX, and more</description>
	<lastBuildDate>Fri, 05 Nov 2010 12:20:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>HTML5 Advertisements</title>
		<link>http://tuckwat.com/blog/html5/annoying-html5-ads/</link>
		<comments>http://tuckwat.com/blog/html5/annoying-html5-ads/#comments</comments>
		<pubDate>Sun, 09 May 2010 18:12:05 +0000</pubDate>
		<dc:creator>Tucker</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[advertisement]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://tuckwat.com/blog/?p=307</guid>
		<description><![CDATA[Flash sucks, all it&#8217;s good for is flashing advertisements. If Flash didn&#8217;t exist and HTML5 was the standard, what format would advertisers use? Here&#8217;s an example of the future in HTML5 Canvas (great tutorial here Mozilla Canvas tutorial). HTML5 Ad: Overall it was fairly easy and intuitive to create &#8211; the hardest part was integrating [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Flash sucks, all it&#8217;s good for is flashing advertisements.</p></blockquote>
<p>If Flash didn&#8217;t exist and HTML5 was the standard, what format would advertisers use?  Here&#8217;s an example of the future in HTML5 Canvas (great tutorial here <a href="https://developer.mozilla.org/en/Canvas_tutorial">Mozilla Canvas tutorial</a>).</p>
<p>HTML5 Ad:</p>
<div style="cursor: pointer; width:300px; height:100px; margin-left:auto; margin-right:auto;" id="html5" title="Example HTML5 Ad"></div>
<p><audio id="audio" src="/blog/wp-content/themes/inove/javascript/mmmbeer.wav"></audio></p>
<p>Overall it was fairly easy and intuitive to create &#8211; the hardest part was <a href="http://www.codediesel.com/wordpress/adding-html5-canvas-element-to-wordpress/">integrating it into a WordPress Post</a>!  It works in Chrome (minus the audio), looks slightly different in Firefox, and doesn&#8217;t work at all in IE.  Unfortunately, we won&#8217;t be seeing many of these ads until its browser penetration and development tools improve.  Maybe it is Adobe&#8217;s fault for making it too easy?</p>
<h2>Javascript portion:</h2>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> start<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;">// Redraw the canvas every 80 ms</span>
	setInterval<span style="color: #009900;">&#40;</span>draw<span style="color: #339933;">,</span><span style="color: #CC0000;">80</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">// Add event listener for mouse over / mouse click</span>
	canvas.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mousemove'</span><span style="color: #339933;">,</span> onMouseMove<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	canvas.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> onMouseClick<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> draw<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> ctx <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: #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;">// Draw rectangle</span>
	ctx.<span style="color: #660066;">fillStyle</span> <span style="color: #339933;">=</span> getRandomColor<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	ctx.<span style="color: #660066;">clearRect</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><span style="color: #CC0000;">300</span><span style="color: #339933;">,</span><span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// clear canvas</span>
	ctx.<span style="color: #660066;">fillRect</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><span style="color: #CC0000;">300</span><span style="color: #339933;">,</span><span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
&nbsp;
	<span style="color: #006600; font-style: italic;">// Outer border</span>
	ctx.<span style="color: #660066;">lineWidth</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">;</span>
	ctx.<span style="color: #660066;">strokeRect</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">298</span><span style="color: #339933;">,</span><span style="color: #CC0000;">98</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">// Draw text</span>
	ctx.<span style="color: #660066;">fillStyle</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'white'</span><span style="color: #339933;">;</span>
	ctx.<span style="color: #660066;">textBaseline</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'top'</span><span style="color: #339933;">;</span>
	ctx.<span style="color: #660066;">font</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'bold 40px sans-serif'</span><span style="color: #339933;">;</span>
	ctx.<span style="color: #660066;">fillText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'YOU WIN!!!'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">40</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">30</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	ctx.<span style="color: #660066;">strokeText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'YOU WIN!!!'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">40</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">30</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> onMouseClick<span style="color: #009900;">&#40;</span>ev<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	window.<span style="color: #660066;">location</span>.<span style="color: #660066;">href</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'http://www.google.com'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>			
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> onMouseMove<span style="color: #009900;">&#40;</span>ev<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">// Play Audio</span>
	document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'audio'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">play</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> getRandomColor<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> r <span style="color: #339933;">=</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #CC0000;">256</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> g <span style="color: #339933;">=</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #CC0000;">256</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> b <span style="color: #339933;">=</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #CC0000;">256</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;rgb(&quot;</span> <span style="color: #339933;">+</span> r <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;,&quot;</span> <span style="color: #339933;">+</span> g <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;,&quot;</span> <span style="color: #339933;">+</span> b <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;)&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://tuckwat.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://tuckwat.com/blog/html5/annoying-html5-ads/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

