<?php 


include("../../../../../site-common/common-functions.php");


set_title("November 15, 2007 : Jeremiah Oeltjen's Blog");

page_start();
?>
<div class="breadcrumb">
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="/" itemprop="url"><span itemprop="title">Home</span></a> &#x203a; 
</div>

<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="/blog/" itemprop="url"><span itemprop="title">Blog</span></a> &#x203a; 
</div>


<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="/blog/archives/2007/" itemprop="url"><span itemprop="title">2007</span></a> &#x203a; 
</div>
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="/blog/archives/2007/11/" itemprop="url"><span itemprop="title">November</span></a> &#x203a; 
</div>
<div class="this-node">
<span class="title">15</span>
</div>


</div>

<div class="blog">

<div id="menu">

<a href="https://jeremiah.oeltjen.us/blog/archives/2007/11/01/">&laquo; November  1, 2007</a> &#x2039;

<a href="https://jeremiah.oeltjen.us/blog/">Main</a>

&#x203a; <a href="https://jeremiah.oeltjen.us/blog/archives/2007/11/21/">November 21, 2007 &raquo;</a>

</div>

</div>

<div class="blog">




<h2 class="date">November 15, 2007</h2>


<div class="blogbody">
<a name="000130"></a>
<h3 class="title">Sierpinski Triangle</h3>

<p>Inspired by Sam Ruby's <a href="http://www.intertwingly.net/blog/2006/07/06/Penrose-Tiling">Penrose Tiling</a> demonstration this week's <a href="http://jeremiah.oeltjen.us/hacks/sierpinski.xml">programming exercise</a> has been an implementation of a <a href="http://en.wikipedia.org/wiki/Sierpinski_triangle">Sierpinski Gasket</a> drawn as an <abbr title="Scalable Vector Graphics">SVG</abbr> graphic using an <a href="http://en.wikipedia.org/wiki/L-system">L-system</a> in ECMAScript.</p>

<p>To get the progressive drawing effect I made each recursive call to the drawing function via the <em>setTimeout</em> function. With that I found that because setTimeout returns immediately and does not block execution I couldn't pass the operational state of the algorithm via the function's parameters or I would wind up with concurrency issues. This also meant I could not simply iterate through all of the steps in a given rule within one call of the function. I had to actually make successive calls to the drawing function for each element in the current rule. See the source code for the details.</p>



<div class="posted">
Posted by <a href="http://jeremiah.oeltjen.us/" rel="author">Jeremiah Oeltjen</a> at <a href="https://jeremiah.oeltjen.us/blog/archives/2007/11/15/sierpinski-triangle"><time datetime="2007-11-15T21:16:12-06:00"> 9:16 PM</time></a>

<!--
| <a href="https://jeremiah.oeltjen.us/mt/mt-comments.cgi?entry_id=130" onclick="OpenComments(this.href); return false">Comments (0)</a>
-->
| <a href="https://jeremiah.oeltjen.us/blog/archives/2007/11/15/sierpinski-triangle#comments">Comments (0)</a>


</div>

</div>


</div>
<?php
page_end();
?>
