<?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>notebook</title>
	<atom:link href="http://www.lamberta.org/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lamberta.org/blog</link>
	<description>Just Playin' Around.</description>
	<lastBuildDate>Tue, 27 Oct 2009 05:41:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Doodle.js &#8212; A Sprite Library for Canvas</title>
		<link>http://www.lamberta.org/blog/doodle/</link>
		<comments>http://www.lamberta.org/blog/doodle/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 18:51:36 +0000</pubDate>
		<dc:creator>billy</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[doodle]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.lamberta.org/blog/?p=233</guid>
		<description><![CDATA[I&#8217;ve been having a lot of fun with the HTML Canvas element and really look forward to utilizing the next-gen Javascript engines the browsers are starting to roll out.
However the drawing commands for it are a bit&#8230; basic. It can be difficult to work creatively when you have to constantly handle the &#8220;low level&#8221; details&#8201;&#8212;&#8201;that&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p style="text-indent:0em;">I&#8217;ve been having a lot of fun with the <a href="http://www.whatwg.org/specs/web-apps/current-work/#the-canvas-element" target="_blank"><span class="caps">HTML</span> Canvas</a> element and really look forward to utilizing the next-gen Javascript engines the browsers are starting to roll out.<br />
However the drawing commands for it are a bit&#8230; basic. It can be difficult to work creatively when you have to constantly handle the &#8220;low level&#8221; details&thinsp;&#8212;&thinsp;that&#8217;s why I wanted to create a library that did it for&nbsp;me.</p>
<p style="text-indent:0em;"><em>Doodle.js</em> attempts to create a fun and easy way to interact with the Canvas that is lightweight, flexible, and functional. While it contains a few shape primitives it is not meant to be a full-fledged drawing api, rather a framework that allows you to build sprites and interact with them in an expressive&nbsp;way.</p>
<p><br/></p>
<p style="text-indent:0em;">This is a 0.1 development release so please treat it accordingly. Bugs are sure to crop up so it&#8217;s best to test things out with your browser&#8217;s debug console open. I&#8217;ve been trying it on Chrome, Firefox 3.0.8, and <span class="caps">IE</span> 8 (using <a href="http://code.google.com/p/explorercanvas/" target="_blank">excanvas</a>). <em>Doodle.js</em> is open source software and has been released under the <a href="http://www.opensource.org/licenses/mit-license.php" target="_blank"><span class="caps">MIT</span> license</a>, please feel free to poke around and submit code fixes&nbsp;:)</p>
<ul>
<li><a href="http://cloud.github.com/downloads/biilly/doodle.js/doodle-0.1.1.js" target="_blank">doodle-0.1.1.js</a>&nbsp;(41k)</li>
<li><a href="http://cloud.github.com/downloads/biilly/doodle.js/doodle-0.1.1.min.js" target="_blank">doodle-0.1.1.min.js</a>&nbsp;(21k)</li>
<li><a href="http://github.com/biilly/doodle.js/tree/master" target="_blank">github&nbsp;project</a></li>
</ul>
<p>Here are a few demos I put together that you might want to take a look at before reading&nbsp;on.</p>
<ul>
<li><a href="http://www.lamberta.org/demo/js/doodle/examples/01/spiral.html" target="_blank">Spiral Pattern</a> (drawing multiple times to&nbsp;canvas)</li>
<li><a href="http://www.lamberta.org/demo/js/doodle/examples/01/bouncy.html" target="_blank">Some Bouncy Balls</a> (a little&nbsp;physics)</li>
<li><a href="http://www.lamberta.org/demo/js/doodle/examples/01/facespin.html" target="_blank">Girl Comin&#8217; to Get Ya</a> (using images&thinsp;&#8212;&thinsp;no <span class="caps">IE</span>,&nbsp;sorry)</li>
<li><a href="http://www.lamberta.org/demo/js/doodle/examples/01/hearts.html" target="_blank">Hearts a Flutter</a> (custom&nbsp;shapes)</li>
<li><a href="http://www.lamberta.org/demo/js/doodle/examples/01/rotate.html" target="_blank">Marbles in Space</a> (simulating&nbsp;3D)</li>
</ul>
<p><span id="more-233"></span></p>
<p style="text-indent:0em;">This is the setup for a basic <span class="caps">HTML</span> file that we&#8217;ll use for the rest of the examples. You&#8217;ll see that it includes a link to <a href="http://code.google.com/p/explorercanvas/" target="_blank">excanvas.js</a> (for <span class="caps">IE</span>) and the <a href="http://www.lamberta.org/demo/js/doodle/doodle-0.1.js" target="_blank"><em>Doodle</em></a> library. In the body of the document we have a canvas element with an id of <em>&#8220;my_canvas&#8221;</em>. If your browser doesn&#8217;t support canvas then some fall back content will appear&nbsp;instead.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!<span class="caps">DOCTYPE</span> <span class="caps">HTML</span> <span class="caps">PUBLIC</span> &quot;-//<span class="caps">W3C</span>//<span class="caps">DTD</span> <span class="caps">HTML</span> 4.01//<span class="caps">EN</span>&quot; &quot;http://www.w3.org/<span class="caps">TR</span>/html4/strict.dtd&quot;&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
  <span style="color: #808080; font-style: italic;">&lt;!--[if <span class="caps">IE</span>]&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;http://explorercanvas.googlecode.com/svn/trunk/excanvas.js&quot;&gt;&lt;/script&gt;&lt;![endif]--&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;./doodle-0.1.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
    function init() {
      //we'll be putting the rest of our javascript here!
&nbsp;
    };
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
  <span style="color: #808080; font-style: italic;">&lt;!--init() is called when the canvas is ready for us.--&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span> <span style="color: #000066;">onload</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript:init();&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;my_canvas&quot;</span> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;600&quot;</span> <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;400&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Fallback: Canvas element is not supported in this browser!<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>canvas&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<p>With the basics in place we can add some Javascript to draw a&nbsp;square.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>oo<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  oo.<span style="color: #660066;">canvas</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#my_canvas'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  oo.<span style="color: #660066;">rect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>x<span style="color: #339933;">:</span><span style="color: #CC0000;">25</span><span style="color: #339933;">,</span> y<span style="color: #339933;">:</span><span style="color: #CC0000;">25</span><span style="color: #339933;">,</span> width<span style="color: #339933;">:</span><span style="color: #CC0000;">50</span><span style="color: #339933;">,</span> height<span style="color: #339933;">:</span><span style="color: #CC0000;">50</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">draw</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>$doodle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p style="text-indent:0em;"><img style="float:left; margin:0 0 0 0;" src="http://www.lamberta.org/demo/js/doodle/examples/01/img/blog/example01.jpg"/></p>
<p style="text-indent:0em;">To avoid cluttering up the namespace, when you import the <em>Doodle</em> library it will create a single global object named <em>$doodle</em> . Everything in the library can be accessed through this variable, but to save some keystrokes we&#8217;re going wrap it up in anonymous function call using a popular Javascript idiom.. The <em>&#8220;oo&#8221;</em> variable was picked because it&#8217;s easy to type, easy to remember (d-oo-dle), and easy for our eyes to parse when we look over the code (it only takes a very cursory knowledge of male psychology to understand that).<br />
Now that we can access the library, we&#8217;ll first feed it the id of our html canvas. We then create a rectangle with <em>oo.rect()</em> by passing it a Javascript object that contains our named parameters. We want a square 50 pixels wide that is situated at the coordinates (25, 25), which starts from the top-left point of our canvas element. Finally we render the rectangle to the canvas element by making a call to <em>.draw()</em>.<br />
Pretty easy eh? Well let&#8217;s say we want to draw our little box again, this time starting exactly in the middle of our first box. Let&#8217;s take a&nbsp;look:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>oo<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  oo.<span style="color: #660066;">canvas</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#my_canvas'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  oo.<span style="color: #660066;">rect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>x<span style="color: #339933;">:</span><span style="color: #CC0000;">25</span><span style="color: #339933;">,</span> y<span style="color: #339933;">:</span><span style="color: #CC0000;">25</span><span style="color: #339933;">,</span> width<span style="color: #339933;">:</span><span style="color: #CC0000;">50</span><span style="color: #339933;">,</span> height<span style="color: #339933;">:</span><span style="color: #CC0000;">50</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">draw</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
      .<span style="color: #660066;">modify</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>x<span style="color: #339933;">:</span><span style="color: #3366CC;">'+= 25'</span><span style="color: #339933;">,</span>
               y<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>o<span style="color: #339933;">,</span>p<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> p<span style="color: #339933;">*</span><span style="color: #CC0000;">2</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
               fill<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;blue&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">draw</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>$doodle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p style="text-indent:0em;"><img style="float:left; margin:0 0 0 0;" src="http://www.lamberta.org/demo/js/doodle/examples/01/img/blog/example02.jpg" /></p>
<p style="text-indent:0em;">So what did we do here? You&#8217;ll notice that we made a call to <em>.draw()</em> twice, but unlike our first example where <em>.draw()</em> ends with a semicolon; we omit that and instead make a call to the objects <em>.modify()</em> method. We can do this because the methods of a <em>doodle</em> object return the same object that called it. This allows us to chain functions together creating complex behavior in relatively few lines of code.<br />
Now how do you reference a value from an object that hasn&#8217;t been created yet? (Well the object <em>has</em> been created, it just hasn&#8217;t been assigned to a variable yet.) Once inside the <em>.modify()</em> method we demonstrated two ways of referencing our previously declared values. With the <em>x</em> property we pass it a string (surrounded by quotes) and start it with the relative assignment operator &#8220;+=&#8221;. This adds 25 to what was previously stored in <em>x</em> (25), so now <em>x</em> holds the value of 50. It&#8217;s important to know that <em>Doodle</em> knows quite a few of these relative assignment operators, but you can&#8217;t simply pass any code here. This code is not being evaluated in a Javascript sense (that&#8217;d be dangerous), instead it&#8217;s just looking for the operator. Also note that it does not support passing variables here.<br />
When we modify the <em>y</em> property we are passing it an anonymous function that is called with itself as the arguments and the return value is assigned back to <em>y</em>. This is a very flexible and powerful way to in-line functions and return the results of any equation. The function is called from within the object, passing itself as the first argument, in this case assigned to <em>&#8220;o&#8221;</em>. The second argument is the property you are modifying, in this example <em>&#8220;p&#8221;</em>. You don&#8217;t have to use these but they are there for convenience.<br />
Finally we change the fill color to blue and then make a call to <em>.draw()</em> a second time. So we&#8217;ve created a box, drawn it, moved it, then drawn it again. Keep in mind that this is the <em>same</em> box, not a separate object, so we can&#8217;t change the order they appear on screen after they have been drawn. For that you&#8217;d need to create 2 separate objects and assign them to a new group: <em>oo.group().add(box1, box2).draw()</em>. The order they are drawn depends on the value of each object&#8217;s <em>&#8220;z&#8221;</em>&nbsp;property.</p>
<h3>Transforms</h3>
<p>All transformations to an object are represented as a 2d matrix and stored in  it&#8217;s <em>obj.matrix</em> property. If your interested about how they work I will point you to a <a href="http://www.senocular.com/flash/tutorials/transformmatrix/" target="_blank">nice tutorial</a> on the subject. Doodle objects support a number of methods for transforming it&#8217;s matrix: translate, rotate, scale, transform&thinsp;&#8212;&thinsp;or you may operate on the matrix&nbsp;itself.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>oo<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 oo.<span style="color: #660066;">canvas</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#my_canvas'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">var</span> box <span style="color: #339933;">=</span> oo.<span style="color: #660066;">rect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>x<span style="color: #339933;">:</span><span style="color: #CC0000;">25</span><span style="color: #339933;">,</span> y<span style="color: #339933;">:</span><span style="color: #CC0000;">25</span><span style="color: #339933;">,</span>
                    width<span style="color: #339933;">:</span><span style="color: #CC0000;">50</span><span style="color: #339933;">,</span> height<span style="color: #339933;">:</span><span style="color: #CC0000;">50</span><span style="color: #339933;">,</span> fill<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;#ff0000&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 box.<span style="color: #660066;">draw</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//draw a red box with initial parameters</span>
&nbsp;
 box.<span style="color: #660066;">modify</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>fill<span style="color: #339933;">:</span><span style="color: #3366CC;">'rgb(0,255,0)'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">translate</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">50</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">draw</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 box.<span style="color: #660066;">modify</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>fill<span style="color: #339933;">:</span><span style="color: #3366CC;">'purple'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">rotate</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #CC0000;">45</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">draw</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 box.<span style="color: #660066;">modify</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>fill<span style="color: #339933;">:</span><span style="color: #3366CC;">'yellow'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">translate</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">50</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">scale</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1.5</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">draw</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 box.<span style="color: #660066;">modify</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>fill<span style="color: #339933;">:</span><span style="color: #3366CC;">'blue'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">transform</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1.5</span><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><span style="color: #CC0000;">1.5</span><span style="color: #339933;">,</span><span style="color: #CC0000;">50</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">draw</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>$doodle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p style="text-indent: 0em"><img style="float:right; margin:0 0 0 0;" src="http://www.lamberta.org/demo/js/doodle/examples/01/img/blog/example03.jpg" /></p>
<p style="text-indent:0em;">In this example we have created a box and drawn it 5 times, changing it&#8217;s color each time to better illustrate the effects of the applied transforms. Our box is first drawn at an initial position of (25, 25) and given the color red (in hexadecimal notation).<br />
We then change it&#8217;s color to green (this time in rgb notation), move it right 50 pixels on the x axis and draw it again. Next, we change to purple and rotate 45 degrees before drawing again. Notice it rotates around the default axis point which is it&#8217;s top-left point, or in local space at (0,0). [This would correspond to it&#8217;s position in global space on the canvas which is now (75, 25).]<br />
Next we perform 2 transformations by chaining them together. First we move the box 50 pixels along it&#8217;s now rotated x axis. We then multiply it&#8217;s scale by 1.5 along it&#8217;s x and y (the single parameter we passed here is short for <em>.scale(1.5, 1.5)</em> ) and draw the now yellow box.<br />
Finally, we change it&#8217;s color to blue, and do the same thing as we did in the previous line&thinsp;&#8212;&thinsp;translating 50 pixels on x and increasing it&#8217;s scale by 1.5, the difference being that we are now applying the transform at the <em>same time</em> by using matrix&nbsp;notation.</p>
<h3>Loops</h3>
<p>To loop over an object you must give it some parameters to change&thinsp;&#8212;&thinsp;otherwise it will continue to write the same thing over and over again, looking like a static image. In this example we will draw a circle at the center of our canvas, then draw it 24 more times rotating around this point&thinsp;&#8212;&thinsp;each time adjusting it&#8217;s position and assigning it a random color. We&#8217;ll do this with a traditional &#8220;for-loop&#8221; to start and then look at some built-in methods for accomplishing the same&nbsp;task.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>oo<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 oo.<span style="color: #660066;">canvas</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#my_canvas'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">var</span> cx <span style="color: #339933;">=</span> oo.<span style="color: #660066;">canvas</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #339933;">/</span><span style="color: #CC0000;">2</span><span style="color: #339933;">;</span>  <span style="color: #006600; font-style: italic;">//horizontal center of canvas</span>
 <span style="color: #003366; font-weight: bold;">var</span> cy <span style="color: #339933;">=</span> oo.<span style="color: #660066;">canvas</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">height</span><span style="color: #339933;">/</span><span style="color: #CC0000;">2</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//vertical center of canvas</span>
&nbsp;
 <span style="color: #003366; font-weight: bold;">var</span> dot <span style="color: #339933;">=</span> oo.<span style="color: #660066;">circle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>x<span style="color: #339933;">:</span>cx<span style="color: #339933;">,</span> y<span style="color: #339933;">:</span>cy<span style="color: #339933;">,</span> radius<span style="color: #339933;">:</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span> fill<span style="color: #339933;">:</span><span style="color: #3366CC;">'#ff0000'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 dot.<span style="color: #660066;">draw</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//initial red circle in the center</span>
&nbsp;
 <span style="color: #003366; font-weight: bold;">var</span> r <span style="color: #339933;">=</span> <span style="color: #CC0000;">100</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//radius of our outside circle</span>
 <span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>   <span style="color: #006600; font-style: italic;">//angle of rotation in degrees</span>
&nbsp;
 <span style="color: #006600; font-style: italic;">//function to convert degrees to radians</span>
 <span style="color: #003366; font-weight: bold;">var</span> radians <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>deg<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> deg <span style="color: #339933;">*</span> Math.<span style="color: #660066;"><span class="caps">PI</span></span><span style="color: #339933;">/</span><span style="color: #CC0000;">180</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #006600; font-style: italic;">//function to generate a random color</span>
 <span style="color: #003366; font-weight: bold;">var</span> random_color <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <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> color <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>0xffffff <span style="color: #339933;">*</span> Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">16</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">return</span> color.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\./i</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slice</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">6</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #006600; font-style: italic;">//a traditional for-loop, called 24 times</span>
 <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">24</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #006600; font-style: italic;">//give dot some new coordinates and a random color</span>
   dot.<span style="color: #660066;">modify</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>x<span style="color: #339933;">:</span> cx <span style="color: #339933;">+</span> Math.<span style="color: #660066;">cos</span><span style="color: #009900;">&#40;</span>radians<span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> r<span style="color: #339933;">,</span>
               y<span style="color: #339933;">:</span> cy <span style="color: #339933;">+</span> Math.<span style="color: #660066;">sin</span><span style="color: #009900;">&#40;</span>radians<span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> r<span style="color: #339933;">,</span>
               fill<span style="color: #339933;">:</span> random_color<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   dot.<span style="color: #660066;">draw</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//draw to canvas</span>
   a <span style="color: #339933;">+=</span> <span style="color: #CC0000;">15</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//increment angle by 15 degrees</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>$doodle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p style="text-indent:0em;"><img style="float:left; margin:0 0 0 0;" src="http://www.lamberta.org/demo/js/doodle/examples/01/img/blog/example04.jpg"/></p>
<p style="text-indent:0em;">Now we&#8217;re going to draw the exact same thing except we&#8217;ll utilize the object&#8217;s built-in <em>.loop()</em> method. It&#8217;s up to you which way you feel comfortable with, but this is a more <a href="http://www.defmacro.org/ramblings/fp.html" target="_blank">functional way</a> of doing things if you&#8217;re into that sort of thing. It also demonstrates some of the flexibility you have when assigning values to object properties in <em>Doodle</em>. You&#8217;ll notice that the first <em>dot.draw()</em> call has been omitted in this example. The reason is a <em>.loop()</em> takes a modification parameter that will be assigned on subsequent iterations. Meaning the first call to loop will always draw the object in it&#8217;s current state, additional loops will apply the modifications. There is also a special property in the loop parameter object, <em>.on_update</em>. This is a function that will be run after each iteration of the loop allowing you to increment variables or alter properties. You could modify everything from within this function if you really wanted to, but that might be a bit&nbsp;confusing.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>oo<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #006600; font-style: italic;">//change background color</span>
 oo.<span style="color: #660066;">canvas</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#my_canvas'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bgcolor</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#<span class="caps">FFCC33</span>'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #003366; font-weight: bold;">var</span> cx <span style="color: #339933;">=</span> oo.<span style="color: #660066;">canvas</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #339933;">/</span><span style="color: #CC0000;">2</span><span style="color: #339933;">;</span>  <span style="color: #006600; font-style: italic;">//horizontal center of canvas</span>
 <span style="color: #003366; font-weight: bold;">var</span> cy <span style="color: #339933;">=</span> oo.<span style="color: #660066;">canvas</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">height</span><span style="color: #339933;">/</span><span style="color: #CC0000;">2</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//vertical center of canvas</span>
&nbsp;
 <span style="color: #003366; font-weight: bold;">var</span> dot <span style="color: #339933;">=</span> oo.<span style="color: #660066;">circle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>x<span style="color: #339933;">:</span>cx<span style="color: #339933;">,</span> y<span style="color: #339933;">:</span>cy<span style="color: #339933;">,</span> radius<span style="color: #339933;">:</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span> fill<span style="color: #339933;">:</span><span style="color: #3366CC;">'#ff0000'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #003366; font-weight: bold;">var</span> r <span style="color: #339933;">=</span> <span style="color: #CC0000;">100</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//radius of our outside circle</span>
 <span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>   <span style="color: #006600; font-style: italic;">//angle of rotation in degrees</span>
&nbsp;
 <span style="color: #006600; font-style: italic;">//for converting degrees to radians</span>
 <span style="color: #003366; font-weight: bold;">var</span> radians <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>deg<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> deg <span style="color: #339933;">*</span> Math.<span style="color: #660066;"><span class="caps">PI</span></span> <span style="color: #339933;">/</span> <span style="color: #CC0000;">180</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #006600; font-style: italic;">//our equations for circle positions</span>
 <span style="color: #003366; font-weight: bold;">var</span> circle_x <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> cx<span style="color: #339933;">+</span>Math.<span style="color: #660066;">cos</span><span style="color: #009900;">&#40;</span>radians<span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span>r<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">var</span> circle_y <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> cy<span style="color: #339933;">+</span>Math.<span style="color: #660066;">sin</span><span style="color: #009900;">&#40;</span>radians<span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span>r<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #006600; font-style: italic;">//generate a random color</span>
 <span style="color: #003366; font-weight: bold;">var</span> random_color <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <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> color <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>0xffffff <span style="color: #339933;">*</span> Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">16</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">return</span> color.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\./i</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slice</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">6</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #006600; font-style: italic;">//these are evaluated on updates</span>
 dot.<span style="color: #660066;">loop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>x<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> circle_x<span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
           y<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> circle_y<span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
           fill<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> random_color<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
           on_update<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> a <span style="color: #339933;">+=</span> <span style="color: #CC0000;">15</span> <span style="color: #009900;">&#125;</span>
          <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">25</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//initial center draw + 24 increments around</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>$doodle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Another option for the <em>.loop()</em> method is to pass it a function instead of an object and to use <em>.modify()</em> within&nbsp;it.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"> dot.<span style="color: #660066;">loop</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
              obj.<span style="color: #660066;">modify</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>x<span style="color: #339933;">:</span>circle_x<span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                          y<span style="color: #339933;">:</span>circle_y<span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                          fill<span style="color: #339933;">:</span>random_color<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
              a <span style="color: #339933;">+=</span> <span style="color: #CC0000;">15</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">25</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now let&#8217;s take a look at this&nbsp;loop:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"> <span style="color: #003366; font-weight: bold;">var</span> r <span style="color: #339933;">=</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">var</span> frame <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
&nbsp;
 dot.<span style="color: #660066;">loop</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
              obj.<span style="color: #660066;">modify</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>x<span style="color: #339933;">:</span>circle_x<span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                          y<span style="color: #339933;">:</span>circle_y<span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                          fill<span style="color: #339933;">:</span>random_color<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
              frame <span style="color: #339933;">+=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//update frame count</span>
              a <span style="color: #339933;">+=</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//update angle rotation</span>
              r <span style="color: #339933;">+=</span> <span style="color: #CC0000;">0.3</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//update radius</span>
&nbsp;
              <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>a <span style="color: #339933;">%</span> <span style="color: #CC0000;">15</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> dot.<span style="color: #660066;">fill</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'#000000'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
              <span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span> dot.<span style="color: #660066;">fill</span> <span style="color: #339933;">=</span> random_color<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: #006600; font-style: italic;">//clear canvas every 800th frame, reset radius</span>
              <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>frame <span style="color: #339933;">%</span> <span style="color: #CC0000;">800</span><span style="color: #339933;">==</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>oo.<span style="color: #660066;">canvas</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">clear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> r <span style="color: #339933;">=</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
&nbsp;
          <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'48fps'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//loop indefinitely at 48 frames/sec</span></pre></div></div>

<p style="text-indent:0em;"><a href="http://www.lamberta.org/demo/js/doodle/examples/01/spiral.html" target="_blank"><img style="margin:0 0 8px 0;" src="http://www.lamberta.org/demo/js/doodle/examples/01/img/blog/spiral01.jpg"/></a></p>
<p style="text-indent:0em;">This loop runs indefinitely and will completely clear the canvas every 800th frame. We&#8217;ve added a <em>framerate</em> parameter to the loop which dictates how fast it&#8217;s run; this can take a numeric value in the measure of milliseconds or  as we can see here as a string with <em>&#8220;fps&#8221;</em>&nbsp;appended.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"> <span style="color: #003366; font-weight: bold;">var</span> frame <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
 dot.<span style="color: #660066;">loop</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
              obj.<span style="color: #660066;">modify</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>x<span style="color: #339933;">:</span>circle_x<span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                          y<span style="color: #339933;">:</span>circle_y<span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
              a <span style="color: #339933;">+=</span> <span style="color: #CC0000;">15</span><span style="color: #339933;">;</span>
              frame <span style="color: #339933;">+=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
          <span style="color: #006600; font-style: italic;">//run indefinitely, clearing after every frame</span>
          <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'24fps'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In this loop we are starting to get an idea of the animation capabilities inherent. By changing the <em>count</em> to <em>zero</em> and setting the <em>clear every frame</em> parameter to <em>true</em> we can put our little circle in motion.<br />
In fact all sprites have an <em>.animate(params, framerate)</em> method that is just a <em>.loop()</em> that runs forever and clears every frame.<br />
Animation is very experimental at this point, especially when working with multiple objects since clearing the canvas will have conflicts. A safer way is to use the global <em>animate</em> function in&nbsp;<em>Doodle</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"> oo.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><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;">//check wall collision</span>
     <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> numballs<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #003366; font-weight: bold;">var</span> ball <span style="color: #339933;">=</span> balls<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
         ball.<span style="color: #660066;">modify</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>x<span style="color: #339933;">:</span>ball.<span style="color: #660066;">x</span> <span style="color: #339933;">+</span> ball.<span style="color: #660066;">vx</span><span style="color: #339933;">,</span>
                      y<span style="color: #339933;">:</span>ball.<span style="color: #660066;">y</span> <span style="color: #339933;">+</span> ball.<span style="color: #660066;">vy</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         Bouncy.<span style="color: #660066;">check_walls</span><span style="color: #009900;">&#40;</span>ball<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
     <span style="color: #006600; font-style: italic;">//check other ball collision</span>
     <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> numballs <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #003366; font-weight: bold;">var</span> ball_a <span style="color: #339933;">=</span> balls<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
         <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> j <span style="color: #339933;">=</span> i <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> numballs<span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
             <span style="color: #003366; font-weight: bold;">var</span> ball_b <span style="color: #339933;">=</span> balls<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
             Bouncy.<span style="color: #660066;">check_collision</span><span style="color: #009900;">&#40;</span>ball_a<span style="color: #339933;">,</span> ball_b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">&#125;</span>
         balls<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">draw</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//and render</span>
     <span style="color: #009900;">&#125;</span>
&nbsp;
 <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'24fps'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #006600; font-style: italic;">/*optional*/</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//clears every frame by default</span></pre></div></div>

<p style="text-indent:0em;"><a href="http://www.lamberta.org/demo/js/doodle/examples/01/bouncy.html" target="_blank" ><img style="margin:0 0 8px 0;" src="http://www.lamberta.org/demo/js/doodle/examples/01/img/blog/bouncy01.jpg"/></a></p>
<h3>Images</h3>
<p>You can import images and draw them as normal shapes. Though since they take time to load it can be a little tricky sometimes having them interact with the rest of your program. You can pass a function to it&#8217;s <em>on_load</em> parameter that will be called when it&#8217;s ready to use. The below example worked fine for me in Chrome and Firefox, but unfortunately I&#8217;ve had difficulties in <span class="caps">IE</span> applying matrix transforms to&nbsp;images.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"> <span style="color: #003366; font-weight: bold;">var</span> cx <span style="color: #339933;">=</span> oo.<span style="color: #660066;">canvas</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #339933;">/</span><span style="color: #CC0000;">2</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">var</span> cy <span style="color: #339933;">=</span> oo.<span style="color: #660066;">canvas</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">height</span><span style="color: #339933;">/</span><span style="color: #CC0000;">2</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">var</span> img_w <span style="color: #339933;">=</span> <span style="color: #CC0000;">271</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">var</span> img_h <span style="color: #339933;">=</span> <span style="color: #CC0000;">365</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">var</span> img <span style="color: #339933;">=</span> oo.<span style="color: #660066;">image</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>src<span style="color: #339933;">:</span><span style="color: #3366CC;">'./img/face_271x365.png'</span><span style="color: #339933;">,</span>
                     x<span style="color: #339933;">:</span>cx <span style="color: #339933;">-</span> img_w<span style="color: #339933;">/</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span>
                     y<span style="color: #339933;">:</span>cy <span style="color: #339933;">-</span> img_h<span style="color: #339933;">/</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span>
                     axis<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>x<span style="color: #339933;">:</span>img_w<span style="color: #339933;">/</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span>
                           y<span style="color: #339933;">:</span>img_h<span style="color: #339933;">/</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span>
                           coord<span style="color: #339933;">:</span><span style="color: #3366CC;">'local'</span><span style="color: #339933;">,</span>
                           visible<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span> <span style="color: #009900;">&#125;</span>
&nbsp;
                     <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">loop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>rotate<span style="color: #339933;">:</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'24fps'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p style="text-indent:0em;"><a href="http://www.lamberta.org/demo/js/doodle/examples/01/facespin.html" target="_blank" ><img style="margin:0 0 8px 0;" src="http://www.lamberta.org/demo/js/doodle/examples/01/img/blog/face01.jpg" /></a></p>
<p style="text-indent:0em;">This example also illustrates a problematic bug I haven&#8217;t figured out yet&thinsp;&#8212;&thinsp;after extended animation the matrix will inexplicably scale. I&#8217;m still hunting around for that one, probably due to rounding&nbsp;errors.</p>
<h3>Custom&nbsp;Shapes</h3>
<p>Doodle is not meant to be a full-fledged drawing library, rather a way to better group and organize your own shapes. To that end it&#8217;s easy to create custom objects and assign them shapes using the <a href="https://developer.mozilla.org/en/Canvas_tutorial/Drawing_shapes">canvas drawing api</a>. We&#8217;ll use the <em>$doodle.gfx</em> object to access these commands and assign them to the shape function of an extended sprite&nbsp;object.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"> <span style="color: #006600; font-style: italic;">//shape is a function called at draw time</span>
 <span style="color: #003366; font-weight: bold;">var</span> heart_shape <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     oo.<span style="color: #660066;">gfx</span>.<span style="color: #660066;">fillStyle</span> <span style="color: #339933;">=</span> random_color<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     oo.<span style="color: #660066;">gfx</span>.<span style="color: #660066;">beginPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     oo.<span style="color: #660066;">gfx</span>.<span style="color: #660066;">moveTo</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">75</span><span style="color: #339933;">,</span><span style="color: #CC0000;">40</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     oo.<span style="color: #660066;">gfx</span>.<span style="color: #660066;">bezierCurveTo</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">75</span><span style="color: #339933;">,</span><span style="color: #CC0000;">37</span><span style="color: #339933;">,</span><span style="color: #CC0000;">70</span><span style="color: #339933;">,</span><span style="color: #CC0000;">25</span><span style="color: #339933;">,</span><span style="color: #CC0000;">50</span><span style="color: #339933;">,</span><span style="color: #CC0000;">25</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     oo.<span style="color: #660066;">gfx</span>.<span style="color: #660066;">bezierCurveTo</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">20</span><span style="color: #339933;">,</span><span style="color: #CC0000;">25</span><span style="color: #339933;">,</span><span style="color: #CC0000;">20</span><span style="color: #339933;">,</span><span style="color: #CC0000;">62.5</span><span style="color: #339933;">,</span><span style="color: #CC0000;">20</span><span style="color: #339933;">,</span><span style="color: #CC0000;">62.5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     oo.<span style="color: #660066;">gfx</span>.<span style="color: #660066;">bezierCurveTo</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">20</span><span style="color: #339933;">,</span><span style="color: #CC0000;">80</span><span style="color: #339933;">,</span><span style="color: #CC0000;">40</span><span style="color: #339933;">,</span><span style="color: #CC0000;">102</span><span style="color: #339933;">,</span><span style="color: #CC0000;">75</span><span style="color: #339933;">,</span><span style="color: #CC0000;">120</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     oo.<span style="color: #660066;">gfx</span>.<span style="color: #660066;">bezierCurveTo</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">110</span><span style="color: #339933;">,</span><span style="color: #CC0000;">102</span><span style="color: #339933;">,</span><span style="color: #CC0000;">130</span><span style="color: #339933;">,</span><span style="color: #CC0000;">80</span><span style="color: #339933;">,</span><span style="color: #CC0000;">130</span><span style="color: #339933;">,</span><span style="color: #CC0000;">62.5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     oo.<span style="color: #660066;">gfx</span>.<span style="color: #660066;">bezierCurveTo</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">130</span><span style="color: #339933;">,</span><span style="color: #CC0000;">62.5</span><span style="color: #339933;">,</span><span style="color: #CC0000;">130</span><span style="color: #339933;">,</span><span style="color: #CC0000;">25</span><span style="color: #339933;">,</span><span style="color: #CC0000;">100</span><span style="color: #339933;">,</span><span style="color: #CC0000;">25</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     oo.<span style="color: #660066;">gfx</span>.<span style="color: #660066;">bezierCurveTo</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">85</span><span style="color: #339933;">,</span><span style="color: #CC0000;">25</span><span style="color: #339933;">,</span><span style="color: #CC0000;">75</span><span style="color: #339933;">,</span><span style="color: #CC0000;">37</span><span style="color: #339933;">,</span><span style="color: #CC0000;">75</span><span style="color: #339933;">,</span><span style="color: #CC0000;">40</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     oo.<span style="color: #660066;">gfx</span>.<span style="color: #660066;">fill</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">var</span> heart <span style="color: #339933;">=</span> oo.<span style="color: #660066;">sprite</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>x<span style="color: #339933;">:</span>i<span style="color: #339933;">*</span><span style="color: #CC0000;">75</span><span style="color: #339933;">,</span>
                        y<span style="color: #339933;">:</span>j<span style="color: #339933;">*</span><span style="color: #CC0000;">65</span><span style="color: #339933;">,</span>
                        shape<span style="color: #339933;">:</span>heart_shape<span style="color: #339933;">,</span>
                        scale<span style="color: #339933;">:</span><span style="color: #CC0000;">0.5</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p style="text-indent:0em;"><a href="http://www.lamberta.org/demo/js/doodle/examples/01/hearts.html" target="_blank" ><img style="margin:0 0 8px 0;" src="http://www.lamberta.org/demo/js/doodle/examples/01/img/blog/heart01.jpg" /></a></p>
<h3>Groups</h3>
<p>Objects can be grouped together and transformed around a common axis. The order an object is drawn in a group is determined by it&#8217;s <em>z</em> property. A higher number means it will appear &#8220;on top&#8221; of another object. You can change the way a group composes it&#8217;s objects by assigning a composite operation to the group.composite property. A list of these can be found <a href="https://developer.mozilla.org/En/Canvas_tutorial/Compositing" target="_blank" >here</a>. Groups haven&#8217;t been fully implemented yet, so your mileage will&nbsp;vary.</p>
<h3>Interaction</h3>
<p>To get the mouse coordinates I find it easiest to use <a href="http://jquery.com/" target="_blank">jQuery</a>, but you could use any of the great Javascript libraries out&nbsp;there.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> mouse_x<span style="color: #339933;">,</span> mouse_y<span style="color: #339933;">;</span>
&nbsp;
 $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#my_canvas'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">mousemove</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #006600; font-style: italic;">//store mouse positions from jquery event</span>
     mouse_x <span style="color: #339933;">=</span> e.<span style="color: #660066;">pageX</span> <span style="color: #339933;">-</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">offsetLeft</span><span style="color: #339933;">;</span>
     mouse_y <span style="color: #339933;">=</span> e.<span style="color: #660066;">pageY</span> <span style="color: #339933;">-</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">offsetTop</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
oo.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><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;">//and use</span>
     angle_x <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>mouse_y <span style="color: #339933;">-</span> vp_y<span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> .001<span style="color: #339933;">;</span>
     angle_y <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>mouse_x <span style="color: #339933;">-</span> vp_x<span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> .001<span style="color: #339933;">;</span>
     <span style="color: #006600; font-style: italic;">//...</span>
     <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> length<span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> balls<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">draw</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: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'24fps'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p style="text-indent:0em;"><a href="http://www.lamberta.org/demo/js/doodle/examples/01/rotate.html" target="_blank" ><img style="margin:0 0 8px 0;" src="http://www.lamberta.org/demo/js/doodle/examples/01/img/blog/rotate01.jpg" /></a></p>
<h3>Conclusion</h3>
<p>Like I said before, this is the first development release so I&#8217;m still hunting bugs. If you find something and can help out, please shoot me a message. I&#8217;ll get some more extensive docs once the <span class="caps">API</span> settles down, until then just punch around the source&nbsp;code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lamberta.org/blog/doodle/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Emacs todo-list-mode</title>
		<link>http://www.lamberta.org/blog/todo-list-mode/</link>
		<comments>http://www.lamberta.org/blog/todo-list-mode/#comments</comments>
		<pubDate>Sat, 17 Jan 2009 07:40:59 +0000</pubDate>
		<dc:creator>billy</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[emacs]]></category>

		<guid isPermaLink="false">http://www.lamberta.org/blog/?p=184</guid>
		<description><![CDATA[Although it wasn&#8217;t on my todo-list, I really had a hankering to add some auto-color highlighting to mine. So I created a pretty basic major-mode for Emacs which I call todo-list-mode. My list is just a plain text file that I can sort the lines based on the assigned number in the first column. I [...]]]></description>
			<content:encoded><![CDATA[<p>Although it wasn&#8217;t on my todo-list, I really had a hankering to add some auto-color highlighting to mine. So I created a pretty basic major-mode for Emacs which I call <a href="http://github.com/biilly/scripts/blob/master/emacs/lisp/todo-list-mode.el">todo-list-mode</a>. My list is just a plain text file that I can sort the lines based on the assigned number in the first column. I created a few regexp&#8217;s to pick out these and change the formatting based on priority. It&#8217;s pretty simple and easy to extend, so if you want to add more numbers or change the colors&thinsp;&#8212;&thinsp;go nuts. It also supports hash style comments to tack on the end of a line.<br/><br />
Grab it:&nbsp;<a href="http://github.com/biilly/scripts/raw/master/emacs/lisp/todo-list-mode.el">todo-list-mode.el</a></p>
<p><img src="http://www.lamberta.org/blog/wp-content/uploads/2009/01/todolistscreenshot01.jpg" alt="My current todo-list." /><br />
<span id="more-184"></span><br />
To include this mode automatically, add to your <code>.emacs</code>&nbsp;:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>add-to-<span style="color: #b1b100;">list</span> 'load-path <span style="color: #ff0000;">&quot;~/emacs/lisp/&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">;my lisp dir</span>
<span style="color: #66cc66;">&#40;</span>autoload 'todo-list-mode <span style="color: #ff0000;">&quot;todo-list-mode&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">;load when needed</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;a simple function that opens the file,</span>
<span style="color: #808080; font-style: italic;">;and switches to todo-list-mode.</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defun</span> open-todo-<span style="color: #b1b100;">list</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>interactive<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>find-file <span style="color: #ff0000;">&quot;~/notes/<span class="caps">TODO</span>&quot;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>todo-list-mode<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;then bind to control-f12 so i can call it with one keystroke</span>
<span style="color: #808080; font-style: italic;">;this works well for me because i also bind calendar to f12</span>
<span style="color: #66cc66;">&#40;</span>global-set-key <span style="color: #66cc66;">&#91;</span>C-f12<span style="color: #66cc66;">&#93;</span> 'open-todo-<span style="color: #b1b100;">list</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>The format for a given line is:<br />
<em>number (0-4), [optional lower case letter], [<span class="caps">TAB</span>], task&nbsp;text.</em></p>
<p>If you want to add more numbers, change the colors, or change the delimiter, it&#8217;s fairly easy to open up the elisp file and do a little copying and&nbsp;pasting. </p>
<p>To sort I just use some standard Emacs commands;<br />
Select a region (<code>C-x h</code> for entire buffer), then <code>M-x sort-lines</code> .<br />
<em>To note, the regular expression that does the coloring looks for a tab delineator between the priority number and the task text. If you&#8217;d rather not use tabs you&#8217;ll have to change it to a couple of spaces or&nbsp;something.</em></p>
<p style="text-indent: 1em">
This style works for me because I really need something minimal and easy to access if I&#8217;m going to use it. Sure there&#8217;s <a href="http://orgmode.org/">org-mode</a> and other more complicated variants but I need simplicity. There&#8217;s too many other things to worry about that I can&#8217;t justify spending extra brain activity trying to operate a todo list. This ordering system is something I got from <a href="http://www.cs.cmu.edu/~pausch/">Randy Pausch</a>, which is based on Stephen Covey&#8217;s <a href="http://en.wikipedia.org/wiki/First_Things_First_(book)">quadrant&nbsp;system</a>.</p>
<p style="text-indent: 1em">It&#8217;s a little weird to post my current todo-list (well maybe guide is more accurate), but I haven&#8217;t posted in a while and maybe some of you are wondering where the heck I&#8217;ve been. Busy, busy, but it&#8217;s winter so I&#8217;m spending the time in the lab and concocting all sorts of new experiments. Hopefully by spring I&#8217;ll be ready to start putting some of this stuff&nbsp;together.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lamberta.org/blog/todo-list-mode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Joy is an Insufferable Strain of Control</title>
		<link>http://www.lamberta.org/blog/joy-is-an-insufferable-strain-of-control/</link>
		<comments>http://www.lamberta.org/blog/joy-is-an-insufferable-strain-of-control/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 00:47:09 +0000</pubDate>
		<dc:creator>billy</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[pv3d]]></category>

		<guid isPermaLink="false">http://www.lamberta.org/blog/?p=160</guid>
		<description><![CDATA[
Typographic demo combining physics and 3D. A creative variation on the Papervision3D/Box2D method I demonstrated here.
]]></description>
			<content:encoded><![CDATA[<p style="text-indent: 0em"><a href="http://www.lamberta.org/demo/pv3d/joyStrain/" target="_blank"><img src="http://www.lamberta.org/blog/wp-content/uploads/2008/10/joystrain.jpg" alt="link to joyStrain demo"/></a></p>
<p style="text-indent: 1em">Typographic <a href="http://www.lamberta.org/demo/pv3d/joyStrain/" target="_blank">demo</a> combining physics and 3D. A creative variation on the Papervision3D/Box2D method I demonstrated <a href="http://www.lamberta.org/blog/paperbox2d/">here</a>.</></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lamberta.org/blog/joy-is-an-insufferable-strain-of-control/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Papervision3D + Box2D</title>
		<link>http://www.lamberta.org/blog/paperbox2d/</link>
		<comments>http://www.lamberta.org/blog/paperbox2d/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 00:24:52 +0000</pubDate>
		<dc:creator>billy</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[pv3d]]></category>

		<guid isPermaLink="false">http://www.lamberta.org/blog/?p=147</guid>
		<description><![CDATA[
In a recent project I wanted to incorporate some physics with a 3D environment. I decided on Box2DFlash (a port of Box2D), which is a great engine even if the syntax is a little awkward for an Actionscript 3&#160;library.
See the PaperBox2D demo, and the source is available (or right-click on the demo). Hit the &#8216;d&#8217; [...]]]></description>
			<content:encoded><![CDATA[<p style="text-indent:0em"><a href="http://www.lamberta.org/demo/pv3d/paperbox2d/" target="_blank"><img src="http://www.lamberta.org/blog/wp-content/uploads/2008/10/paperbox2d.jpg" alt="PaperBox2D image" /></a></p>
<p style="text-indent:1em">In a <a href="http://danielskrok.com/">recent project</a> I wanted to incorporate some physics with a 3D environment. I decided on <a href="http://box2dflash.sourceforge.net/">Box2DFlash</a> (a port of <a href="http://www.box2d.org/">Box2D</a>), which is a great engine even if the syntax is a little awkward for an Actionscript 3&nbsp;library.</p>
<p style="text-indent:1em">See the <a href="http://www.lamberta.org/demo/pv3d/paperbox2d/" target="_blank">PaperBox2D demo</a>, and the <a href="http://www.lamberta.org/demo/pv3d/paperbox2d/srcview/" target="_blank">source is available</a> (or right-click on the demo). Hit the &#8216;d&#8217; button during the simulation to toggle the debug regions for the 2d calculations and see how they are mapped to the objects in 3d&nbsp;space.</p>
<p><br/></p>
<p style="text-indent:0em"><em>Updated 11.20.08, recent api changes in&nbsp;Box2DFlash.</em></p>
<p><br/></p>
<p style="text-indent:0em"><em>Larry Lague has done <a href="http://www.kneecapslap.com/blog/?p=10">a port</a> of this demo using <a href="http://away3d.com/">Away3D</a>. Very&nbsp;nice!</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lamberta.org/blog/paperbox2d/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Type Around the Neighborhood</title>
		<link>http://www.lamberta.org/blog/type-around-the-neighborhood/</link>
		<comments>http://www.lamberta.org/blog/type-around-the-neighborhood/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 00:47:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[buffalo]]></category>
		<category><![CDATA[photos]]></category>
		<category><![CDATA[typography]]></category>

		<guid isPermaLink="false">http://www.lamberta.org/blog/?p=134</guid>
		<description><![CDATA[
I brought my camera along for my daily constitutional and decided to take in some of the local signage. Gill Sans (aka &#8220;England&#8217;s Helvetica&#8221;) seems to be a popular typeface around Buffalo, which is fine but can be a bit tiresome. Kinda like a girl you had a fling with once and for some reason [...]]]></description>
			<content:encoded><![CDATA[<p style="text-indent: 1em">
I brought my camera along for my daily constitutional and decided to take in some of the local signage. Gill Sans (aka &#8220;England&#8217;s Helvetica&#8221;) seems to be a popular typeface around Buffalo, which is fine but can be a bit tiresome. Kinda like a girl you had a fling with once and for some reason keeps popping up&thinsp;&#8212;&thinsp;you don&#8217;t really regret anything, but you&#8217;d rather try something&nbsp;else.</p>
<p style="text-indent: 0em">
<a href="http://www.flickr.com/photos/billy2/2882958401/"><img src="http://farm4.static.flickr.com/3188/2882958401_c499874441.jpg" width="450"/></a></p>
<p><span id="more-134"></span></p>
<p style="text-indent: 0em">
<a href="http://www.flickr.com/photos/billy2/2882958405/"><img src="http://farm4.static.flickr.com/3210/2882958405_145b981727_o.jpg" width="450" /></a></p>
<p style="text-indent: 0em">
<a href="http://www.flickr.com/photos/billy2/2882958411/"><img src="http://farm4.static.flickr.com/3285/2882958411_99c17b08f2.jpg" width="450"/></a></p>
<p style="text-indent: 0em">
<a href="http://www.flickr.com/photos/billy2/2882958413/"><img src="http://farm4.static.flickr.com/3063/2882958413_5cf7e39671.jpg" width="450"/></a></p>
<p style="text-indent: 0em">
<a href="http://www.flickr.com/photos/billy2/2882958421/"><img src="http://farm4.static.flickr.com/3141/2882958421_b7f5082c20_o.jpg" width="450"/></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lamberta.org/blog/type-around-the-neighborhood/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Better Bend Than Break</title>
		<link>http://www.lamberta.org/blog/better-bend-than-break/</link>
		<comments>http://www.lamberta.org/blog/better-bend-than-break/#comments</comments>
		<pubDate>Fri, 19 Sep 2008 20:58:57 +0000</pubDate>
		<dc:creator>billy</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[pv3d]]></category>

		<guid isPermaLink="false">http://www.lamberta.org/blog/?p=128</guid>
		<description><![CDATA[


Another Papervision3D demo, this time using VectorVision and the AS3Dmod libraries to manipulate a vector image. Source code is&#160;available.
]]></description>
			<content:encoded><![CDATA[<p style="text-indent: 0em">
<a href="http://www.lamberta.org/demo/pv3d/betterBend/"><img src="http://www.lamberta.org/blog/wp-content/uploads/2008/09/betterbend.jpg" alt="Better bend than break." width="450"/></a></p>
<p style="text-indent: 1em">
Another <a href="http://code.google.com/p/papervision3d/">Papervision3D</a> demo, <a href="http://www.lamberta.org/demo/pv3d/betterBend/">this time</a> using <a href="http://code.google.com/p/vectorvision/">VectorVision</a> and the <a href="http://code.google.com/p/as3dmod/">AS3Dmod</a> libraries to manipulate a vector image. <a href="http://www.lamberta.org/demo/pv3d/betterBend/VectorBend.as" onclick="javascript: pageTracker._trackPageview('/downloads/VectorBend.as'); ">Source code is&nbsp;available</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lamberta.org/blog/better-bend-than-break/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Arrive</title>
		<link>http://www.lamberta.org/blog/arrive/</link>
		<comments>http://www.lamberta.org/blog/arrive/#comments</comments>
		<pubDate>Mon, 15 Sep 2008 18:19:19 +0000</pubDate>
		<dc:creator>billy</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[pv3d]]></category>

		<guid isPermaLink="false">http://www.lamberta.org/blog/?p=115</guid>
		<description><![CDATA[
Hmm, I need to update this blog&#160;more.

Well I just finished a little interactive demo using Actionscript 3, Papervision3D, and some models I created in Maya. I used a song by Ehma who in his infinite wisdom released the music on Jamendo. I suggest you to check it out, it&#8217;s&#160;nice!
]]></description>
			<content:encoded><![CDATA[<p style="text-indent: 0em"><a href="http://www.lamberta.org/demo/pv3d/arrive/"><img src="http://farm4.static.flickr.com/3010/2857920435_042d1071a2_o.jpg" width="450"></a></p>
<p style="text-indent: 0em">Hmm, I need to update this blog&nbsp;more.</p>
<p style="text-indent: 1em">
Well I just finished a little <a href="http://www.lamberta.org/demo/pv3d/arrive/">interactive demo</a> using Actionscript 3, Papervision3D, and some models I created in Maya. I used a song by <a href="http://blane-est.net/ehma/">Ehma</a> who in his infinite wisdom released <a href="http://www.jamendo.com/en/artist/ehma">the music on Jamendo</a>. I suggest you to check it out, it&#8217;s&nbsp;nice!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lamberta.org/blog/arrive/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One PaperKing to Rule Them All</title>
		<link>http://www.lamberta.org/blog/see-invisible-demo/</link>
		<comments>http://www.lamberta.org/blog/see-invisible-demo/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 03:08:52 +0000</pubDate>
		<dc:creator>billy</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[pv3d]]></category>

		<guid isPermaLink="false">http://www.lamberta.org/blog/?p=67</guid>
		<description><![CDATA[
The Papervision3D guys are running a nice little contest for the title of &#8220;PaperKing3D&#8221;. I thought this would be good chance to show an example of some of the recent stuff I&#8217;ve been working on. Here&#8217;s the demo, and here&#8217;s the source&#160;code.

Read on for more detail about the code and some of the inspiration.




First a [...]]]></description>
			<content:encoded><![CDATA[<p style="text-indent: 0em"><a href="http://www.lamberta.org/demo/pv3d/seeinvisible/" target="_blank"><img src="http://www.lamberta.org/blog/wp-content/uploads/2008/08/seeinvisscreen.jpg" alt="See the Invisible screenshot" /></a></p>
<p style="text-indent: 1em">The Papervision3D guys are running a nice <a href="http://blog.papervision3d.org/2008/07/02/paperking3d-the-papervision3d-contest/" target="_blank">little contest</a> for the title of &#8220;PaperKing3D&#8221;. I thought this would be good chance to show an example of some of the recent stuff I&#8217;ve been working on. Here&#8217;s <a href="http://www.lamberta.org/demo/pv3d/seeinvisible/" target="_blank">the demo</a>, and here&#8217;s <a href="http://www.lamberta.org/demo/pv3d/seeinvisible/SeeInvisible.as" target="_blank" onclick="javascript: pageTracker._trackPageview('/downloads/SeeInvisible.as'); ">the source&nbsp;code</a>.</p>
<p><br/></p>
<p style="text-indent: 0em">Read on for more detail about the code and some of the inspiration.<br />
<span id="more-67"></span>
</p>
<p><br/></p>
<p style="text-indent: 1em">
First a word on the inspiration. I come from a photography background so it shouldn&#8217;t come as much surprise that in my design work I tend to think of things like a photographer&thinsp;&#8212;&thinsp;using space, composition, and cameras. This is why engines such as Papervision3D are exciting to me; they give me a chance to combine all of my interests in photography, graphic design, and programming into one medium. There are also a lot of parallels between programming and photography, namely that they are both fairly technical and require a bit of pre-visualization. The majority of your effort is spent constructing an implementation towards that imaginary goal&thinsp;&#8212;&thinsp;manipulating code very much like manipulating light to achieve a photograph. So with those similarities in mind I wanted to highlight the use of light in this demo. I also began thinking of the physical design of cameras themselves and some of the old classics. It almost seems silly that the machine designed to create art becomes a work of art itself, but this happens with code as well. Things of such complexity can be studied and studied creating their own following. So looking around flickr for old cameras I came across a picture of this little&nbsp;gem&#8230;</p>
<p style="text-indent: 0em"><img src="http://www.lamberta.org/blog/wp-content/uploads/2008/08/kodakgift.jpg" alt="Gift Kodak No. 1A" /></p>
<p style="text-indent: 1em">
One of Walter Dorwin Teague&#8217;s modernist designs for the &#8220;Gift No. 1A&#8221; during his time at Kodak (a Western New York icon btw). Quite the sporty little accessory to have around your neck in the early 1930&#8217;s. This became a good place to start laying out the scene&#8217;s look and&nbsp;structure.</p>
<p><br/></p>
<h2>The&nbsp;Code</h2>
<p style="text-indent: 1em">
More than likely you&#8217;re visiting this page and could probably care less about any background inspiration and want to see how the example works. As I mentioned before, <a href="http://www.lamberta.org/demo/pv3d/seeinvisible/SeeInvisible.as" target="_blank" onclick="javascript: pageTracker._trackPageview('/downloads/SeeInvisible.as'); ">the source code</a> is available so I won&#8217;t go through everything, but just highlight some of the more trickier&nbsp;issues.</p>
<p style="text-indent: 1em">
In a nutshell this scene is just a collada model that I exported from Maya and baked textures onto. Papervision is a fantastic 3D engine but since we are working in a browser with Flash we are very limited by what a software renderer can do. With that in mind we have to create a very low-poly mesh and reduce our triangles count as much as we can. (Pop quiz, what do 3D modeling and type design have in common? Both require that you achieve the maximum expression of a shape with a minimum amount of points.) But, and this is a big but, when modeling the ground and wall planes you&#8217;ll be tempted to get rid of all the extra polygons&thinsp;&#8212;&thinsp;this is a mistake. We need those extra polys to hold the texture position correctly. [If we didn&#8217;t we could turn on precision for the material, but that would slow everything up.] So you may want to do some experimenting with count versus performance, I found a 10 x 10 plane to be a satisfactory&nbsp;compromise.</p>
<p style="text-indent: 1em">
Another concern in the modeling stage is how the objects are grouped. Before you export your model be sure to combine the meshes you want as one texture and give it an easy name to remember (simply grouping the objects is not enough). This will make it more convenient when assigning your model parts to separate viewport layers later on. Apply a simple lambert shader to the objects and change the shaders name, it&#8217;ll be quicker to locate when you&#8217;re searching through the collada xml&nbsp;later.</p>
<p style="text-indent: 1em">
Model, light, render, bake, and export your textures as you normally would. Make sure your models have been <span class="caps">UV</span> mapped and keep in mind your textures should be 512 x 512 (1024 if you really need it) for performance&nbsp;reasons.</p>
<p style="text-indent: 1em">
When loading the images as materials you&#8217;ll need to replace the shader name that it&#8217;s given within the collada xml. Doing a search for &#8220;instance_material&#8221; will give you something that looks&nbsp;like:</p>
<p><br/></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">&lt;instance_material symbol=&quot;lambert1SG&quot; target=&quot;#myShaderName&quot;/&gt;</pre></div></div>

<p style="text-indent: 0em">You&#8217;ll be looking for the symbol name that we&#8217;ll add to the material list so we can swap in our&nbsp;texture:</p>
<p><br/></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">//create material list</span>
<span style="color: #000000; font-weight: bold;">var</span> matList:MaterialsList = <span style="color: #000000; font-weight: bold;">new</span> MaterialsList<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">//convert to a bitmap</span>
<span style="color: #000000; font-weight: bold;">var</span> textureBitmap:Bitmap = <span style="color: #000000; font-weight: bold;">new</span> myTexture<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> as Bitmap;
<span style="color: #808080; font-style: italic;">//now swap our bitmap material into the shader name that we found in the collada</span>
matList.<span style="color: #006600;">addMaterial</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> BitmapMaterial<span style="color: #66cc66;">&#40;</span>textureBitmap.<span style="color: #006600;">bitmapData</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #ff0000;">&quot;lambert1SG&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">//once you have your collada loaded then apply the material list</span>
model.<span style="color: #006600;">materials</span> = matList;</pre></div></div>

<p style="text-indent: 1em">
Now we still may get flickering polys with the model and the ground plane. This is a z-sorting issue that we can fix by using Papervision&#8217;s ViewportLayers. Andy Zupko has a <a href="http://blog.zupko.info/?p=129" target="_blank">much better explanation</a> of using them with effects so I won&#8217;t repeat that, I&#8217;ll just show the relevant parts in my&nbsp;code:</p>
<p><br/></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">viewport.<span style="color: #006600;">getChildLayer</span><span style="color: #66cc66;">&#40;</span>model.<span style="color: #006600;">getChildByName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;floor&quot;</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> wordLayer:ViewportLayer = viewport.<span style="color: #006600;">getChildLayer</span><span style="color: #66cc66;">&#40;</span>model.<span style="color: #006600;">getChildByName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;words&quot;</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
wordLayer.<span style="color: #006600;">alpha</span> = <span style="color: #cc66cc;">0.8</span>;</pre></div></div>

<p style="text-indent: 0em">
The names &#8220;floor&#8221; and &#8220;words&#8221; are the names I gave the objects when I combined their meshes earlier. Since in my demo I wanted to simulate caustics I needed to make the model a little transparent. Since you can&#8217;t adjust the alpha of a BitmapMaterial I added the model to a separate viewport layer and adjusted it&#8217;s transparency there. And since both the floor and the words are being rendered on separate layers we can eliminate the&nbsp;&#8220;z-fighting&#8221;.</p>
<p style="text-indent: 1em">
Well I hope that helps someone. The Papervision team are doing a fantastic job but you&#8217;ll need to help yourself as well. It&#8217;s up to careful modeling and texture optimization that will give you the biggest performance&nbsp;gains.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lamberta.org/blog/see-invisible-demo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Few Post-Panel Thoughts on Web Fonts</title>
		<link>http://www.lamberta.org/blog/typecon-thoughts-on-web-fonts/</link>
		<comments>http://www.lamberta.org/blog/typecon-thoughts-on-web-fonts/#comments</comments>
		<pubDate>Sat, 26 Jul 2008 14:55:32 +0000</pubDate>
		<dc:creator>billy</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[typography]]></category>

		<guid isPermaLink="false">http://www.lamberta.org/blog/?p=61</guid>
		<description><![CDATA[There was a lively panel discussion at TypeCon 2008 on the issue of embedded fonts on the web [an overview can be found here]. A pretty controversial subject because there are 2 problems that need to be solved&#8201;&#8212;&#8201;the web designer&#8217;s desire to use typography, and the type designer&#8217;s desire to be paid for their work. [...]]]></description>
			<content:encoded><![CDATA[<p>There was a lively panel discussion at <a href="http://www.typecon.com/">TypeCon 2008</a> on the issue of embedded fonts on the web [an overview can be found <a href="http://typophile.com/node/47629">here</a>]. A pretty controversial subject because there are 2 problems that need to be solved&thinsp;&#8212;&thinsp;the web designer&#8217;s desire to use typography, and the type designer&#8217;s desire to be paid for their work. However these are not technical problems, like every other content provider coming to grips with modern computing the questions are not &#8220;how can we do it&#8221;, but have rather become &#8220;how do we prevent the piracy of our work.&#8221;<br />
<span id="more-61"></span></p>
<p style="text-indent: 1em">A number of solutions were discussed, notable was the announcement of Ascender Corp.&#8217;s <a href="http://www.fontembedding.com/">FontEmbedding.com</a> and Ted Harrison&#8217;s (of FontLab) <a href="http://www.eeulaa.org/"><span class="caps">EEULAA</span></a>. Unfortunately the current wave of discussion seems to be following the music industries failed attempts at Digital Rights Management (<span class="caps">DRM</span>). I say failed, as previous attempts have been, but what I mean is fundamentally flawed. The premise being that you can control what someone&#8217;s remote machine reads and stores, but the technical reality is that only someone with physical access (with applicable knowledge) has the capacity for absolute dominion over the machine. Or to try and apply it more succinctly to the world of fonts&thinsp;&#8212;&thinsp;if my eyes can see the typeface on the screen, the computer can also see the typeface. If the computer can see it, it can scrape it, produce outlines, look up a kerning table and write it out to a different name. All of which may even be legal because you cannot currently copyright a letter form, only the &#8220;software package&#8221; it comes bundled in. There is no format that can overcome this, just like in the &#8220;real world&#8221; where you cannot stop someone from cutting out letters in a magazine and creating new&nbsp;words.</p>
<p>But to me it seems there is a difference between music, which is format based, and with something like fonts, which is more application based. Let&#8217;s say we look a little more upstream to where designers are actually making choices and making typeface decisions. The vast majority are using applications like InDesign, Illustrator, Flash, Photoshop, etc, in short Adobe. So my question is, if Adobe, or any large application developer is effectively acting as a host system for interaction with copyrighted material, don&#8217;t they have a certain obligation to restrict offending material? If YouTube gets a complaint about a video infringing on copyright they take it down. MySpace has certain systems in place that will prevent you from uploading a song that matches the metrics of a known song, can&#8217;t such a measure be implemented by Adobe? What if there was a look-up system where they could evaluate the metrics of a particular font being used against those listed in a licensed based registry? Even if they did not want to go that route with enforcement, would they not also be in a better position to gauge usage statistics? They could effectively become the primary means of distribution, payment, and royalties&thinsp;&#8212;&thinsp;effectively becoming what iTunes is to&nbsp;music.</p>
<p>Of course this is not a perfect system, there will continue to be technical paths around this.  But if you are looking at ways to stop the &#8220;casual&#8221; pirate then I think looking upstream at the choke points is a better philosophy then trying to use your finger to plug all the leaks that sprout up. You&#8217;re going to have offenders, but the question should be how do I make the best out of the current situation by making the most money off regular customers without restricting and alienating&nbsp;them?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lamberta.org/blog/typecon-thoughts-on-web-fonts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Website Update</title>
		<link>http://www.lamberta.org/blog/website-update/</link>
		<comments>http://www.lamberta.org/blog/website-update/#comments</comments>
		<pubDate>Fri, 25 Jul 2008 21:00:48 +0000</pubDate>
		<dc:creator>billy</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.lamberta.org/blog/?p=54</guid>
		<description><![CDATA[The main page has been updated&#8201;&#8212;&#8201;click around, break things, and please send me any errors you&#160;find.
There has been a &#8220;temporary&#8221; page up for the past week in a mad rush to have something done by TypeCon2008. It was functional and highlighted some of the skills I&#8217;m trying to showcase. But now that I&#8217;ve had another [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.lamberta.org">main page</a> has been updated&thinsp;&#8212;&thinsp;click around, break things, and please send me any errors you&nbsp;find.</p>
<p>There has been a &#8220;temporary&#8221; page up for the past week in a mad rush to have something done by <a href="http://www.typecon.com/">TypeCon2008</a>. It was functional and highlighted some of the skills I&#8217;m trying to showcase. But now that I&#8217;ve had another week I&#8217;ve reworked the design and interactive code which I think makes it a bit more interesting. It&#8217;s definitely a bit hard on the ole&#8217; cpu but I&#8217;ve tried to optimize where possible, and really it&#8217;s not a site that&#8217;s designed to be accessible to everyone on every&nbsp;browser.</p>
<p>I&#8217;m going to be adding new stuff to the &#8220;portfolio&#8221; as I get I can. It&#8217;s mostly photography and motion videos at this point but more Flash stuff is in the works. Questions, comments, work?&nbsp;Holla.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lamberta.org/blog/website-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
