<?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>markstar</title>
	<atom:link href="http://markstar.co.uk/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://markstar.co.uk/blog</link>
	<description>blogging about web technologies</description>
	<lastBuildDate>Sat, 07 May 2011 13:42:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Shottts is now available in the Blackberry App Store!</title>
		<link>http://markstar.co.uk/blog/?p=511</link>
		<comments>http://markstar.co.uk/blog/?p=511#comments</comments>
		<pubDate>Sat, 07 May 2011 13:42:36 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flash Platform]]></category>
		<category><![CDATA[StarDribbbleLib]]></category>
		<category><![CDATA[App]]></category>
		<category><![CDATA[Blackberry]]></category>
		<category><![CDATA[Dribbble]]></category>
		<category><![CDATA[Playbook]]></category>
		<category><![CDATA[Shottts]]></category>
		<category><![CDATA[World]]></category>

		<guid isPermaLink="false">http://markstar.co.uk/blog/?p=511</guid>
		<description><![CDATA[My app, Shottts, has been approved and is now available in the Blackberry App World! This is the first app I've built and published to a store myself, so I'm pretty excited.]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a title="Screenshot of Shottts App" href="http://appworld.blackberry.com/webstore/content/30821" target="_blank"><img class="size-full wp-image-487" title="Screenshot of Shottts App" src="http://79.170.44.80/markstar.co.uk/blog/wp-content/uploads/2011/05/ShotttsApp.jpg" alt="Screenshot of Shottts App" width="592" height="347" /></a></p>
<p>
My app, Shottts, has been approved and is now <a href="http://appworld.blackberry.com/webstore/content/30821" title="See Shottts in the Blackberry App World">available for free in the Blackberry App World</a>! This is the first app I&#8217;ve developed and published to a store myself, so I&#8217;m pretty excited to see it out there.
</p>
<p>
I submitted the app as part of the <a href="http://us.blackberry.com/developers/tablet/playbook_offer.jsp">free BlackBerry PlayBook offer for developers</a>, but the app has only been tested on the simulator as I haven&#8217;t got my device yet. Perhaps there&#8217;s an argument for not making it available, but it ran well on the simulator so I took the decision to release it and it&#8217;s had quite a few downloads considering I haven&#8217;t advertised it at all! I&#8217;ve got lots of features planned for the app, I&#8217;m just waiting for my Playbook to be shipped so I can properly test the app before investing time on updates.
</p>
<p>
For those of you that are interested, the app was developed using StarDribbbleLib, which is <a href="https://github.com/markstar/StarDribbbleLib" title="StarDribbbleLib on Github">available on Github</a>, there&#8217;s also a <a href="http://markstar.co.uk/blog/?p=333" title="StarDribbbleLib – AS3 Dribbble Library">blog post about it</a>.
</p>
<p>
Anyway, if you&#8217;ve got a Playbook <a href="http://appworld.blackberry.com/webstore/content/30821" title="See Shottts in the Blackberry App World">give it a <em>shot</em></a>, it&#8217;s free! And let me know what you think.</p>
]]></content:encoded>
			<wfw:commentRss>http://markstar.co.uk/blog/?feed=rss2&#038;p=511</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Canvas Play 10: Shooting Stars</title>
		<link>http://markstar.co.uk/blog/?p=490</link>
		<comments>http://markstar.co.uk/blog/?p=490#comments</comments>
		<pubDate>Tue, 29 Mar 2011 08:00:37 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[Colour Pooling]]></category>
		<category><![CDATA[Object Pooling]]></category>

		<guid isPermaLink="false">http://markstar.co.uk/blog/?p=490</guid>
		<description><![CDATA[The last demo introduced triggers and a proper implementation of the object pool. This demo uses both of those concepts as well as introducing the emitter behaviour. The emitter behaviour emits objects using specified parameters such as the angle, force and gravity to apply when emitting.]]></description>
			<content:encoded><![CDATA[<p>
The <a href="http://markstar.co.uk/?p=488" title="View Canvas Play 09: Recycling Orbs">last demo</a> introduced triggers and a proper implementation of the object pool. This demo uses both of those concepts as well as introducing the emitter behaviour. The emitter behaviour emits objects using specified parameters such as the angle, force and gravity to apply when emitting. The demo emits stars from the bottom of the canvas and uses a trigger to detect when the star leaves the canvas so it can be recycled back into the object pool. This demo also displays the amount of objects on the canvas and allows you to toggle whether the canvas captures the individual frame, or the series of frames, click the image below to see it in action.
</p>
<p style="text-align: center;"><a title="View the Canvas_10 demo" href="http://markstar.co.uk/html5/Canvas/Canvas_10.html" target="_blank"><img class="aligncenter size-full wp-image-487" title="Canvas_10" src="http://79.170.44.80/markstar.co.uk/blog/wp-content/uploads/2011/03/Canvas_10.jpg" alt="Canvas_10 Demo" width="592" height="370" /></a><br />
[Please note that this demo hasn't been optimised to work on all machines, so you may experience some slow down]</p>
<p><span id="more-490"></span></p>
<h2>View Source</h2>
<p>
Below, I&#8217;ve included the source code of the demo. You can have a look through all of the code properly on <a href="http://github.com/markstar/CanvasPlay">GitHub</a>, but I&#8217;ll give a quick overview.
</p>
<p>
The <a href="http://markstar.co.uk/?p=488" title="View Canvas Play 09: Recycling Orbs">last demo</a> introduced triggers and a different approach to releasing objects from the <strong>ObjectPool</strong>. There are two things that are new in this demo, the <strong>StarOrb</strong> class and the <strong>Emitter</strong> class, the demo also requests a new object from the <strong>ObjectPool</strong> every frame and has a limit of 100.
</p>
<p>
The <strong>StarOrb</strong> class makes use of the new <strong>Star</strong> class. The <strong>Star</strong> class draws a star to the canvas and allows you to customise all of it&#8217;s parameters such as the number of points it has, and it&#8217;s inner and outer radii.
</p>
<p>
The <strong>Emitter</strong> behaviour takes a number of parameters when it&#8217;s created. These are the target, the amount of drag to apply, the amount of scale to apply to the target, the amount of force to apply to the target, the angle to emit the target and the gravity to apply to the target. It is a little complicated to set up, but it works in the same way as all other behaviours, and can be used in conjunction with them.
</p>
<p>
You can <a href="http://github.com/markstar/CanvasPlay">grab the source code from GitHub</a> and have a play.
</p>
<p><script src="https://gist.github.com/888293.js"> </script></p>
]]></content:encoded>
			<wfw:commentRss>http://markstar.co.uk/blog/?feed=rss2&#038;p=490</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Canvas Play 09: Recycling Orbs</title>
		<link>http://markstar.co.uk/blog/?p=488</link>
		<comments>http://markstar.co.uk/blog/?p=488#comments</comments>
		<pubDate>Mon, 28 Mar 2011 10:00:14 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[Colour Pooling]]></category>
		<category><![CDATA[Object Pooling]]></category>

		<guid isPermaLink="false">http://markstar.co.uk/blog/?p=488</guid>
		<description><![CDATA[The last few demos have shown different uses of the SineOscillator behaviour, this demo introduces triggers and a proper implementation of object pooling.]]></description>
			<content:encoded><![CDATA[<p>
The <a href="http://markstar.co.uk/?p=477" title="View Canvas Play 08: Waving The Flag">last few demos</a> have shown different uses of the SineOscillator behaviour, this demo introduces triggers and a proper implementation of object pooling. In this demo an Orb is added to the center of the Canvas with behaviours added to randomly move it around. An Orb is added every third frame, however it is only added if there is one available in the object pool. In this demo the object pool has a limit of 50 objects, the current object count is displayed to illustrate the number of objects on the canvas, you&#8217;ll notice that it never goes above 50.
</p>
<p>
Triggers are added to each orb created; a trigger is something that calls a function when it&#8217;s conditions are met. In this case we&#8217;re using the ExitBoundsTrigger, which is triggered when the Orb is out of the bounds specified (the Canvas area). The function called by the trigger recycles the target object by removing all behaviours and releasing it back into the object pool ready for it to be used again. I&#8217;ve also added the ability to toggle whether the canvas captures the individual frame, or the series of frames, click the image below to see it in action.
</p>
<p style="text-align: center;"><a title="View the Canvas_09 demo" href="http://markstar.co.uk/html5/Canvas/Canvas_09.html" target="_blank"><img class="aligncenter size-full wp-image-486" title="Canvas_09" src="http://79.170.44.80/markstar.co.uk/blog/wp-content/uploads/2011/03/Canvas_09.jpg" alt="Canvas_09 Demo" width="592" height="370" /></a><br />
[Please note that this demo hasn't been optimised to work on all machines, so you may experience some slow down]</p>
<p><span id="more-488"></span></p>
<h2>View Source</h2>
<p>
Below, I&#8217;ve included the source code of the demo. You can have a look through all of the code properly on <a href="http://github.com/markstar/CanvasPlay">GitHub</a>, but I&#8217;ll give a quick overview.
</p>
<p>
If you&#8217;ve been following along, you&#8217;ll see that this demo uses many of the classes we&#8217;re already familiar with, such as the <strong>ColorPool</strong>, <strong>ObjectPool</strong> and the <strong>BehaviourManager</strong>. In this post we&#8217;re introducing the concept of triggers, as well as the <strong>TriggerManager</strong> to manage the triggers.
</p>
<p>
As mentioned above, in this demo we&#8217;re using the <strong>ExitBoundsTrigger</strong>, which is created in the <strong>onCreateObject</strong> function. The <strong>ExitBoundsTrigger</strong> takes three parameters; the target object, the bounds that confine the target and the function to be called when the target exits the specified bounds. The <strong>Bounds</strong> are specified in the <strong>init</strong> function, so far only a rectangle is supported.
</p>
<p>
When an <strong>Orb</strong> exits the bounds specified the <strong>onExitBounds</strong> function is called. This function removes the <strong>Orb</strong> from the <strong>CanvasController</strong>, thus removing it from the <strong>Canvas</strong>, releases it back into the <strong>ObjectPool</strong> and removes all behaviours and triggers for the object. Doing this allows us to reuse the objects already created in memory, rather than creating a new object every time one is requested.
</p>
<p>
This demo using a different method to release objects from the <strong>ObjectPool</strong> than used in previous demos. Previous demos have used <strong>requestAll</strong> to request all available object from the pool at once, this demo requests objects in the <strong>update</strong> function, on every third frame. By recycling the objects used we are able to continuously request and reuse objects from the <strong>ObjectPool</strong>.
</p>
<p>
You can <a href="http://github.com/markstar/CanvasPlay">grab the source code from GitHub</a> and have a play.
</p>
<p><script src="https://gist.github.com/888290.js"> </script></p>
]]></content:encoded>
			<wfw:commentRss>http://markstar.co.uk/blog/?feed=rss2&#038;p=488</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Canvas Play 08: Waving The Flag</title>
		<link>http://markstar.co.uk/blog/?p=477</link>
		<comments>http://markstar.co.uk/blog/?p=477#comments</comments>
		<pubDate>Wed, 23 Mar 2011 10:00:19 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Behaviours]]></category>
		<category><![CDATA[SineOscillator]]></category>

		<guid isPermaLink="false">http://markstar.co.uk/blog/?p=477</guid>
		<description><![CDATA[Again, this demo doesn't add much from the last demo, but demonstrates another use of the SineOscillator. This time, it shows 1180 Orbs oscillating in a grid shape, giving an impression of a waving flag.]]></description>
			<content:encoded><![CDATA[<p>
Again, this demo doesn&#8217;t add much from the <a href="http://markstar.co.uk/blog/?p=476" title="View Canvas Play 07: Sine Wave">last demo</a>, but demonstrates another use of the SineOscillator. This time, it shows 1180 Orbs oscillating in a grid shape, giving an impression of a waving flag, click the image below to see it in action.
</p>
<p style="text-align: center;"><a title="View the Canvas_08 demo" href="http://markstar.co.uk/html5/Canvas/Canvas_08.html" target="_blank"><img class="aligncenter size-full wp-image-479" title="Canvas_08" src="http://79.170.44.80/markstar.co.uk/blog/wp-content/uploads/2011/03/Canvas_08.jpg" alt="Canvas_08 Demo" width="592" height="370" /></a><br />
[Please note that this demo hasn't been optimised to work on all machines, so you may experience some slow down]</p>
<p><span id="more-477"></span></p>
<h2>View Source</h2>
<p>
Below, I&#8217;ve included the source code of the demo. You can have a look through all of the code properly on <a href="http://github.com/markstar/CanvasPlay">GitHub</a>, but I&#8217;ll give a quick overview.
</p>
<p>
As mentioned <a href="http://markstar.co.uk/blog/?p=454" title="View Canvas Play 06: Oscillating Orbs">previously</a>, the <strong>SineOscillator</strong> uses the sine wave to oscillate the specified property between two values. This demo lays the orbs out in a grid and applies the <strong>SineOscillator</strong> behaviour to oscillate the <strong>x</strong>, <strong>y</strong> and <strong>alpha</strong> values, which gives the impression of a waving flag.
</p>
<p>
You can <a href="http://github.com/markstar/CanvasPlay">grab the source code from GitHub</a> and have a play.
</p>
<p><script src="https://gist.github.com/880347.js"> </script></p>
]]></content:encoded>
			<wfw:commentRss>http://markstar.co.uk/blog/?feed=rss2&#038;p=477</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Canvas Play 07: Sine Wave</title>
		<link>http://markstar.co.uk/blog/?p=476</link>
		<comments>http://markstar.co.uk/blog/?p=476#comments</comments>
		<pubDate>Tue, 22 Mar 2011 10:00:39 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Behaviours]]></category>
		<category><![CDATA[SineOscillator]]></category>

		<guid isPermaLink="false">http://markstar.co.uk/blog/?p=476</guid>
		<description><![CDATA[This demo doesn't add much from the last demo, but demonstrates another use of the SineOscillator. It shows 120 Orbs oscillating up and down in a sine wave formation.]]></description>
			<content:encoded><![CDATA[<p>
This demo doesn&#8217;t add much from the <a href="http://markstar.co.uk/blog/?p=454" title="View Canvas Play 06: Oscillating Orbs">last demo</a>, but demonstrates another use of the SineOscillator. It shows 120 Orbs oscillating up and down in a sine wave formation, click the image below to see it in action.
</p>
<p style="text-align: center;"><a title="View the Canvas_07 demo" href="http://markstar.co.uk/html5/Canvas/Canvas_07.html" target="_blank"><img class="aligncenter size-full wp-image-478" title="Canvas_07" src="http://79.170.44.80/markstar.co.uk/blog/wp-content/uploads/2011/03/Canvas_07.jpg" alt="Canvas_07 Demo" width="592" height="370" /></a><br />
[Please note that this demo hasn't been optimised to work on all machines, so you may experience some slow down]</p>
<p><span id="more-476"></span></p>
<h2>View Source</h2>
<p>
Below, I&#8217;ve included the source code of the demo. You can have a look through all of the code properly on <a href="http://github.com/markstar/CanvasPlay">GitHub</a>, but I&#8217;ll give a quick overview.
</p>
<p>
As mentioned <a href="http://markstar.co.uk/blog/?p=454" title="View Canvas Play 06: Oscillating Orbs">previously</a>, the <strong>SineOscillator</strong> uses the Sine wave to oscillate the specified property between two values. This demo lays the orbs out evenly across the x axis and applies the <strong>SineOscillator</strong> behaviour to oscillate the y value from the top to the bottom of the canvas.
</p>
<p>
You can <a href="http://github.com/markstar/CanvasPlay">grab the source code from GitHub</a> and have a play.
</p>
<p><script src="https://gist.github.com/880328.js"> </script></p>
]]></content:encoded>
			<wfw:commentRss>http://markstar.co.uk/blog/?feed=rss2&#038;p=476</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Canvas Play 06: Oscillating Orbs</title>
		<link>http://markstar.co.uk/blog/?p=454</link>
		<comments>http://markstar.co.uk/blog/?p=454#comments</comments>
		<pubDate>Fri, 18 Mar 2011 10:00:59 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Behaviours]]></category>
		<category><![CDATA[Oscillate]]></category>

		<guid isPermaLink="false">http://markstar.co.uk/blog/?p=454</guid>
		<description><![CDATA[The last demo introduced the concept of behaviours. In this demo demonstrates use of a new behaviour, SineOscillator, which oscillates a specified parameter between two values. In this case it uses the Sine wave to oscillate between the two values. In the demo each of the 120 Orbs have their x and y positions oscillated.]]></description>
			<content:encoded><![CDATA[<p>
The <a href="http://markstar.co.uk/blog/?p=451" title="View Canvas Play 05: Vibrating Behaviours">last demo</a> introduced the concept of behaviours. This demo demonstrates use of a new behaviour, the <strong>SineOscillator</strong>, which oscillates a specified parameter between two values. In this case it uses the Sine wave to oscillate between the two values. In the demo each of the 120 Orbs have their x and y positions oscillated over the canvas width and height, click the image below to see it in action.
</p>
<p style="text-align: center;"><a title="View the Canvas_06 demo" href="http://markstar.co.uk/html5/Canvas/Canvas_06.html" target="_blank"><img class="aligncenter size-full wp-image-456" title="Canvas_06" src="http://79.170.44.80/markstar.co.uk/blog/wp-content/uploads/2011/03/Canvas_06.jpg" alt="Canvas_06 Demo" width="592" height="370" /></a><br />
[Please note that this demo hasn't been optimised to work on all machines, so you may experience some slow down]</p>
<p><span id="more-454"></span></p>
<h2>View Source</h2>
<p>
Below, I&#8217;ve included the source code of the demo. You can have a look through all of the code properly on <a href="http://github.com/markstar/CanvasPlay">GitHub</a>, but I&#8217;ll give a quick overview.
</p>
<p>
As I&#8217;ve mentioned above, the <strong>SineOscillator</strong> uses the Sine wave to oscillate the specified property between two values. When creating a new instance of the <strong>SineOscillator</strong> you specify the target object and the property of that target to apply the behaviour to, <a href="http://markstar.co.uk/blog/?p=451" title="View Canvas Play 05: Vibrating Behaviours">as before</a>. You also specify the frequecy, the two values to oscillate between and the offset. The frequency specifies the amount of times the property will be oscillated between the two values, and the offset specifies the amount that&#8217;s applied to each step, without an offset the oscillator will start from the first value each time.
</p>
<p>
You can <a href="http://github.com/markstar/CanvasPlay">grab the source code from GitHub</a> and have a play.
</p>
<p><script src="https://gist.github.com/872195.js"> </script></p>
]]></content:encoded>
			<wfw:commentRss>http://markstar.co.uk/blog/?feed=rss2&#038;p=454</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Canvas Play 05: Vibrating Behaviours</title>
		<link>http://markstar.co.uk/blog/?p=451</link>
		<comments>http://markstar.co.uk/blog/?p=451#comments</comments>
		<pubDate>Thu, 17 Mar 2011 09:30:28 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Behaviours]]></category>
		<category><![CDATA[FixedVibration]]></category>

		<guid isPermaLink="false">http://markstar.co.uk/blog/?p=451</guid>
		<description><![CDATA[The last demo introduced concepts from the HYPE Framework; object pooling and colour pooling. This demo introduces another one, behaviours, and in particular the FixedVibration behaviour, which is based on the HYPE class of the same name.]]></description>
			<content:encoded><![CDATA[<p>
The <a href="http://markstar.co.uk/blog/?p=443" title="View Canvas Play 04: The Little Things">last demo</a> introduced concepts from <a title="View the HYPE Framework website" href="http://www.hypeframework.org/">the HYPE Framework</a>; object pooling and colour pooling. This demo introduces another one, behaviours, and in particular the <strong>FixedVibration</strong> behaviour, which is based on the HYPE class of the same name. The resulting effect is similar to previous demos, but the animation is much smoother, click the image below to see it.
</p>
<p style="text-align: center;"><a title="View the Canvas_05 demo" href="http://markstar.co.uk/html5/Canvas/Canvas_05.html" target="_blank"><img class="aligncenter size-full wp-image-464" title="Canvas_05" src="http://79.170.44.80/markstar.co.uk/blog/wp-content/uploads/2011/03/Canvas_05.jpg" alt="Canvas_05 Demo" width="592" height="370" /></a><br />
[Please note that this demo hasn't been optimised to work on all machines, so you may experience some slow down]</p>
<p><span id="more-451"></span></p>
<h2>View Source</h2>
<p>
Below, I&#8217;ve included the source code of the demo. You can have a look through all of the code properly on <a href="http://github.com/markstar/CanvasPlay">GitHub</a>, but I&#8217;ll give a quick overview.
</p>
<p>
The <a href="http://markstar.co.uk/blog/?p=443" title="View Canvas Play 04: The Little Things">last</a> <a href="http://markstar.co.uk/blog/?p=414" title="View Canvas Play 03: Jittery Swimmers">two</a> demos had 1000 orbs jittering about on the canvas, but it would be really useful if we could encapsulate this behaviour into a reusable class. <strong>FixedVibration</strong> does this and allows you to set parameters to affect the behaviour.
</p>
<p>When the <strong>FixedVibration</strong> is created, you specify the target object and the property of that target to apply the behaviour to. This allows you to create multiple behaviours for multiple properties, or even multiple behaviours on the same property.</p>
<p>
In order for this behaviour to run I&#8217;ve created a <strong>BehaviourManager</strong>. When updated, the <strong>BehaviourManager</strong> loops through all added behaviours and runs them. You can see in the code below that the <strong>BehaviourManager</strong> is updated just before the <strong>CanvasController</strong>. I&#8217;ve also changed the colours for some variation on the previous demos! You can <a href="http://github.com/markstar/CanvasPlay">grab the source code from GitHub</a> and have a play.
</p>
<p><script src="https://gist.github.com/872194.js"> </script></p>
]]></content:encoded>
			<wfw:commentRss>http://markstar.co.uk/blog/?feed=rss2&#038;p=451</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Canvas Play 04: The Little Things</title>
		<link>http://markstar.co.uk/blog/?p=443</link>
		<comments>http://markstar.co.uk/blog/?p=443#comments</comments>
		<pubDate>Tue, 15 Mar 2011 11:00:11 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[Rectangle]]></category>

		<guid isPermaLink="false">http://markstar.co.uk/blog/?p=443</guid>
		<description><![CDATA[In the last demo I introduced object pooling, colour pooling and 1000 orbs. This demo shows how the little things can make a big difference. The small change in this demo is that a black rectangle is drawn over all of the orbs on every update to give the effect that they're leaving a trail behind them.]]></description>
			<content:encoded><![CDATA[<p>
In the <a href="http://markstar.co.uk/blog/?p=414" title="View Canvas Play 03: Jittery Swimmers">last demo</a> I introduced object pooling, colour pooling and 1000 orbs. This demo shows how the little things can make a big difference. The small change in this demo is that a black rectangle is drawn over all of the orbs on every update to give the effect that they&#8217;re leaving a trail behind them. Click the image below to see it in action.
</p>
<p style="text-align: center;"><a title="View the Canvas_04 demo" href="http://markstar.co.uk/html5/Canvas/Canvas_04.html" target="_blank"><img class="aligncenter size-full wp-image-445" title="Canvas_04" src="http://79.170.44.80/markstar.co.uk/blog/wp-content/uploads/2011/03/Canvas_04.jpg" alt="Canvas_04 Demo" width="592" height="370" /></a><br />
[Please note that this demo hasn't been optimised to work on all machines, so you may experience some slow down]</p>
<p><span id="more-443"></span></p>
<h2>View Source</h2>
<p>
Below, I&#8217;ve included the source code of the demo. You can have a look through all of the code properly on <a href="http://github.com/markstar/CanvasPlay">GitHub</a>, but I&#8217;ll give a quick overview.
</p>
<p>
As I mentioned before, the only change is the introduction of a black <strong>Rectangle</strong>, which is added to the <strong>CanvasController</strong>. To add the rectangle a <strong>Rectangle</strong> class was created. The <strong>Rectangle</strong> is created at the same dimensions as the <strong>Canvas</strong> and is added with 5% alpha, changing the alpha value will effect the length of the trail for each <strong>Orb</strong>. You can <a href="http://github.com/markstar/CanvasPlay">grab the source code from GitHub</a> and have a play.
</p>
<p><script src="https://gist.github.com/868152.js"> </script></p>
]]></content:encoded>
			<wfw:commentRss>http://markstar.co.uk/blog/?feed=rss2&#038;p=443</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Canvas Play 03: Jittery Swimmers</title>
		<link>http://markstar.co.uk/blog/?p=414</link>
		<comments>http://markstar.co.uk/blog/?p=414#comments</comments>
		<pubDate>Mon, 14 Mar 2011 11:00:37 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[Colour Pooling]]></category>
		<category><![CDATA[Object Pooling]]></category>

		<guid isPermaLink="false">http://markstar.co.uk/blog/?p=414</guid>
		<description><![CDATA[In the last demo I started to look at basic animation. This demo extends on this area by incorporating a couple of patterns I liked in the HYPE Framework; object pooling and colour pooling. This demo creates 1000 orbs that jitter about when the canvas is updated. The canvas isn't cleared between updates and so the result is an organic camouflage effect.]]></description>
			<content:encoded><![CDATA[<p>
In the <a href="http://markstar.co.uk/blog/?p=408" title="View Canvas Play 02: Stalking Circle">last demo</a> I started to look at basic animation. This demo extends on this area by incorporating a couple of patterns I liked in <a title="View the HYPE Framework website" href="http://www.hypeframework.org/">the HYPE Framework</a>; object pooling and colour pooling. This demo creates 1000 orbs that jitter about when the canvas is updated. The canvas isn&#8217;t cleared between updates and so the result is an organic camouflage effect, click the image below to see it in action.
</p>
<p style="text-align: center;"><a title="View the Canvas_03 demo" href="http://markstar.co.uk/html5/Canvas/Canvas_03.html" target="_blank"><img class="aligncenter size-full wp-image-416" title="Canvas_03" src="http://79.170.44.80/markstar.co.uk/blog/wp-content/uploads/2011/03/Canvas_03.jpg" alt="Canvas_03 Demo" width="592" height="370" /></a><br />
[Please note that this demo hasn't been optimised to work on all machines, so you may experience some slow down]</p>
<p><span id="more-414"></span></p>
<h2>View Source</h2>
<p>
Below, I&#8217;ve included the source code of the demo. You can have a look through all of the code properly on <a href="http://github.com/markstar/CanvasPlay">GitHub</a>, but I&#8217;ll give a quick overview.
</p>
<p>
If you&#8217;ve followed along with <a href="http://markstar.co.uk/blog/category/html5/canvas/" title="The Canvas Play series">the series</a> you would&#8217;ve seen that each demo creates a <strong>DisplayObject</strong> that has two <strong>Circle</strong>s added to it, well this is now consolidated into the <strong>Orb</strong> class. You may also noticed that I&#8217;m now using a <strong>Ticker</strong> object, this is encapsulating the <strong>setInterval</strong> functionality demonstrated in the <a href="http://markstar.co.uk/blog/?p=408" title="View Canvas Play 02: Stalking Circle">last demo</a>. The reason for this is so that there&#8217;s only ever one interval running at a time, but multiple listeners can be added to the same interval using the <strong>Ticker</strong> object.
</p>
<p>
The <strong>ColorPool</strong> is constructed by passing the colours you wish to be in the pool. The idea is that you have a pool of colours to choose from, calling the <strong>getColor</strong> method pulls a random colour from the pool, which is used to colour the <strong>Orb</strong>s. The color is never removed from the pool. This is different to the <strong>ObjectPool</strong>, which is constructed by specifying the class you wish to pool and the amount of &#8220;swimmers&#8221; (objects) you wish to be in the pool. The <strong>ObjectPool</strong> has a method you can set called <strong>onCreateObject</strong>, this method is called every time an object is created in the pool, in this current implementation an object is created when it&#8217;s requested.
</p>
<p>
When an <strong>Orb</strong> is created it is placed in a random position on the canvas, given a random alpha value and a random color generated by the <strong>ColorPool</strong>. It is then added to an <strong>Array</strong> of <strong>Orb</strong>s and added to the canvas. Every time the canvas is updated, when the <strong>update</strong> method is called the orbs have a random number between <strong>-2</strong> and <strong>2</strong> added to their <strong>x</strong> and <strong>y</strong> positions, which makes them jitter! You can <a href="http://github.com/markstar/CanvasPlay">grab the source code from GitHub</a> and have a play.
</p>
<p><script src="https://gist.github.com/867179.js"> </script></p>
]]></content:encoded>
			<wfw:commentRss>http://markstar.co.uk/blog/?feed=rss2&#038;p=414</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Canvas Play 02: Stalking Circle</title>
		<link>http://markstar.co.uk/blog/?p=408</link>
		<comments>http://markstar.co.uk/blog/?p=408#comments</comments>
		<pubDate>Sat, 12 Mar 2011 15:00:09 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[Mouse Interactivity]]></category>

		<guid isPermaLink="false">http://markstar.co.uk/blog/?p=408</guid>
		<description><![CDATA[The last demo looked at displaying more than one item at once, now it's time to make things move! This demo is pretty simple, the canvas is updated every 20ms and when it's updated the circle moves towards the mouse cursor.]]></description>
			<content:encoded><![CDATA[<p>
The <a href="http://markstar.co.uk/blog/?p=372" title="View Canvas Play 01: Trigonometric Functions">last demo</a> looked at displaying more than one item at once, now it&#8217;s time to make things move! This demo is pretty simple, the canvas is updated every 20ms and when it&#8217;s updated the circle moves towards the mouse cursor. Click the image below to try it out, don&#8217;t forget to press the &#8216;start&#8217; button to, well, make it start!
</p>
<p style="text-align: center;"><a title="View the Canvas_02 demo" href="http://markstar.co.uk/html5/Canvas/Canvas_02.html" target="_blank"><img class="aligncenter size-full wp-image-409" title="Canvas_02" src="http://79.170.44.80/markstar.co.uk/blog/wp-content/uploads/2011/03/Canvas_02.jpg" alt="Canvas_02 Demo" width="592" height="370" /></a></p>
<p><span id="more-408"></span></p>
<h2>View Source</h2>
<p>
Below, I&#8217;ve included the source code of the demo. You can have a look through all of the code properly on <a href="http://github.com/markstar/CanvasPlay">GitHub</a>, but I&#8217;ll give a quick overview.
</p>
<p>
The <strong>init</strong> function creates the circle and adds it to the canvas, as well as adding an event listener for the mouse move event on the canvas. The <strong>canvasOnMouseMove</strong> method is called every time the mouse moves over the canvas, this method sets the target position of the circle; i.e the point that it&#8217;s aiming to get to. The <strong>update</strong> method updates the canvas and moves the circle 5% of the way towards the target position, by moving the circle 5% on every update it creates a smooth ease towards the mouse position.
</p>
<p>
The <strong>start</strong> method sets an interval for calling the <strong>update</strong> method, this interval is cleared using the <strong>stop</strong> method. The <strong>reset</strong> method is simply there to reset the circle to the center of the canvas. You can <a href="http://github.com/markstar/CanvasPlay">grab the source code from GitHub</a> and have a play.
</p>
<p><script src="https://gist.github.com/867170.js"> </script></p>
]]></content:encoded>
			<wfw:commentRss>http://markstar.co.uk/blog/?feed=rss2&#038;p=408</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

