<?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>The paperCrane's view from the reverseFold</title>
	<atom:link href="http://www.reversefold.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.reversefold.com/blog</link>
	<description>Flex, PHP, and anything else I care to talk about</description>
	<lastBuildDate>Thu, 16 Jul 2009 10:17:37 +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>More Fractal Letters</title>
		<link>http://www.reversefold.com/blog/2009/02/10/more-fractal-letters/</link>
		<comments>http://www.reversefold.com/blog/2009/02/10/more-fractal-letters/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 19:16:03 +0000</pubDate>
		<dc:creator>papercrane</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Fractal]]></category>

		<guid isPermaLink="false">http://www.reversefold.com/blog/?p=123</guid>
		<description><![CDATA[I&#8217;ve continued adding bits to my fractal letters over the past few weeks and have finally finished everything to print out my full e-mail address. The @ symbol was particularly interesting and I think it turned out pretty nice.

The pictures link to the updated app. Enjoy, and as usual, don&#8217;t slide the slider up to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve continued adding bits to my <a title="Fractal Letters" href="http://www.reversefold.com/blog/2009/01/20/fractal-letters/">fractal letters</a> over the past few weeks and have finally finished everything to print out my full e-mail address. The @ symbol was particularly interesting and I think it turned out pretty nice.</p>
<div id="attachment_125" class="wp-caption aligncenter" style="width: 560px"><img class="size-full wp-image-125" title="Fractal Email - first iteration" src="http://www.reversefold.com/blog/wp-content/uploads/2009/02/fractal_email_11.png" alt="fractal_email_11" width="550" height="298" /><p class="wp-caption-text">Fractal Email - first iteration</p></div>
<p style="text-align: left;">
<div id="attachment_127" class="wp-caption aligncenter" style="width: 560px"><img class="size-full wp-image-127" title="Fractal Email - third iteration" src="http://www.reversefold.com/blog/wp-content/uploads/2009/02/fractal_email_3.png" alt="Fractal Email - third iteration" width="550" height="295" /><p class="wp-caption-text">Fractal Email - third iteration</p></div>
<div id="attachment_128" class="wp-caption aligncenter" style="width: 560px"><img class="size-full wp-image-128" title="Fractal Email - fifth iteration" src="http://www.reversefold.com/blog/wp-content/uploads/2009/02/fractal_email_5.png" alt="Fractal Email - fifth iteration" width="550" height="294" /><p class="wp-caption-text">Fractal Email - fifth iteration</p></div>
<p>The pictures link to the updated app. Enjoy, and as usual, don&#8217;t slide the slider up to the max unless you&#8217;re willing to wait while your entire browser hangs for several minutes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.reversefold.com/blog/2009/02/10/more-fractal-letters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASCIIMathML Wordpress Plugin</title>
		<link>http://www.reversefold.com/blog/2009/02/06/asciimathml-wordpress-plugin/</link>
		<comments>http://www.reversefold.com/blog/2009/02/06/asciimathml-wordpress-plugin/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 07:57:55 +0000</pubDate>
		<dc:creator>papercrane</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[MathML]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.reversefold.com/blog/?p=121</guid>
		<description><![CDATA[I&#8217;ve updated my ASCIIMathML plugin so that it doesn&#8217;t have quite so many security holes and abuse vectors. I&#8217;ve put it up for download at http://www.reversefold.com/blog/asciimathml_0.2.tgz. Please note that this requires command-line access to run, requires python and inkscape to be installed, and has been tested only on linux. There may also be security problems [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve updated my ASCIIMathML plugin so that it doesn&#8217;t have quite so many security holes and abuse vectors. I&#8217;ve put it up for download at <a href="http://www.reversefold.com/blog/asciimathml_0.2.tgz">http://www.reversefold.com/blog/asciimathml_0.2.tgz</a>. Please note that this requires command-line access to run, requires <a href="http://www.python.org/">python</a> and <a href="http://www.inkscape.org/">inkscape</a> to be installed, and has been tested only on linux. There may also be security problems and bugs. I take no responsibility for anything that may happen if you should use this. The code is released under the LGPL for now.</p>
<p>With the disclaimers out of the way, I hope this is useful to you. Let me know if you have any issues with it or any suggestions for improvements.</p>
<p>This is an update of a <a href="http://www.reversefold.com/blog/2008/11/27/pretty-equations-in-html/">previous post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.reversefold.com/blog/2009/02/06/asciimathml-wordpress-plugin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fractal Letters</title>
		<link>http://www.reversefold.com/blog/2009/01/20/fractal-letters/</link>
		<comments>http://www.reversefold.com/blog/2009/01/20/fractal-letters/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 08:08:23 +0000</pubDate>
		<dc:creator>papercrane</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[FlexBuilder]]></category>
		<category><![CDATA[Fractal]]></category>
		<category><![CDATA[Papervision3D]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[l-system]]></category>

		<guid isPermaLink="false">http://www.reversefold.com/blog/?p=116</guid>
		<description><![CDATA[On the way home last Thursday I decided to try creating fractal letters. The idea was to replace each &#8220;line&#8221; in a simple version of a letter with a copy of itself but allow for the aspect ratio of its dimensions to change so that the result is still recognizable as a letter. This is [...]]]></description>
			<content:encoded><![CDATA[<p>On the way home last Thursday I decided to try creating fractal letters. The idea was to replace each &#8220;line&#8221; in a simple version of a letter with a copy of itself but allow for the aspect ratio of its dimensions to change so that the result is still recognizable as a letter. This is something like an <a title="L-system" href="http://en.wikipedia.org/wiki/L-system">L-system</a>, of which the <a title="Dragon curve" href="http://en.wikipedia.org/wiki/Dragon_curve">Dragon curve</a> is one. After a weekend&#8217;s worth of work I have what amounts to thirteen different fractal letter algorithms for six different letters. 1 P, 3 A, 2 E, 2 R, 2 C, 3 N. Yes, those spell PAPERCRANE. Here is the first iteration (just the letters).</p>
<div id="attachment_117" class="wp-caption alignnone" style="width: 510px"><a href="http://www.reversefold.com/flex/fractalLetters/"><img class="size-full wp-image-117" title="Fractal Letters, iteration 1" src="http://www.reversefold.com/blog/wp-content/uploads/2009/01/fractalletters_1.png" alt="Fractal Letters, iteration 1" width="500" height="234" /></a><p class="wp-caption-text">Fractal Letters, iteration 1</p></div>
<p>And here is the fifth iteration:</p>
<div id="attachment_118" class="wp-caption alignnone" style="width: 510px"><a href="http://www.reversefold.com/flex/fractalLetters/"><img class="size-full wp-image-118" title="Fractal Letters, iteration 5" src="http://www.reversefold.com/blog/wp-content/uploads/2009/01/fractalletters_5.png" alt="Fractal Letters, iteration 5" width="500" height="251" /></a><p class="wp-caption-text">Fractal Letters, iteration 5</p></div>
<p>Some letters have variations in how they are drawn or how they repeat, or both (hence the 2 lines). The bottom N uses an algorithm I worked out which didn&#8217;t change the aspect ratio and had only one repetition per line. Both of the N variants in the words use two repetitions per line and constrict the width faster than the height, which leaves the N recognizable. The idea here, after all, was to make letters which had a cool fractal look but could still be read.</p>
<p>Click either of the pictures to view the flex app and play with the iterations yourself. Just drag (or click on) the slider on the bottom of the app to change the iteration.</p>
<p>Stay tuned, I have another blog post coming up soon specifically about that N on the bottom, the math required to create the algorithm, and some interesting (and beautiful) results I got when implementing a test program.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.reversefold.com/blog/2009/01/20/fractal-letters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>μ-reversefold</title>
		<link>http://www.reversefold.com/blog/2009/01/07/%ce%bc-reversefold/</link>
		<comments>http://www.reversefold.com/blog/2009/01/07/%ce%bc-reversefold/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 18:58:23 +0000</pubDate>
		<dc:creator>papercrane</dc:creator>
				<category><![CDATA[Origami]]></category>
		<category><![CDATA[reversefold]]></category>

		<guid isPermaLink="false">http://www.reversefold.com/blog/?p=109</guid>
		<description><![CDATA[Over the Christmas break I went to Chinatown in San Francisco and got some new origami paper which is smaller than any of my other paper. I quickly decided to make one of my signature reversefolds with the new paper. I started creasing the paper and got to the sane point, which would have given [...]]]></description>
			<content:encoded><![CDATA[<p>Over the Christmas break I went to Chinatown in San Francisco and got some new origami paper which is smaller than any of my other paper. I quickly decided to make one of my signature reversefolds with the new paper. I started creasing the paper and got to the sane point, which would have given me 4 rows of reversefolds. This would have been small, but not small enough for me. I like my folds to be more complicated.</p>
<div class="wp-caption alignnone" style="width: 510px"><a href="http://www.flickr.com/photos/reversefold/3163437415/in/set-72157612124977697/"><img title="Finished creases, back side" src="http://farm2.static.flickr.com/1143/3163437415_4630acb71c.jpg?v=0" alt="Finished creases, back side" width="500" height="375" /></a><p class="wp-caption-text">Finished creases, back side</p></div>
<div class="wp-caption alignnone" style="width: 510px"><a href="http://www.flickr.com/photos/reversefold/3163442179/in/set-72157612124977697/"><img title="Finished creases, front side" src="http://farm2.static.flickr.com/1006/3163442179_449e713f2f.jpg?v=0" alt="Finished creases, front side" width="500" height="375" /></a><p class="wp-caption-text">Finished creases, front side</p></div>
<p>Yes, that paper is less than 2 quarters wide. Of course, going one more level took a lot of careful and precise folding which took the rest of the night. The next day I started the accordion folds which are the base of the final product.</p>
<div class="wp-caption alignnone" style="width: 510px"><a href="http://www.flickr.com/photos/reversefold/3163444651/in/set-72157612124977697/"><img title="Accordion halfway done" src="http://farm2.static.flickr.com/1036/3163444651_435af70c4c.jpg?v=0" alt="Accordion halfway done" width="500" height="375" /></a><p class="wp-caption-text">Accordion halfway done</p></div>
<div class="wp-caption alignnone" style="width: 510px"><a href="http://www.flickr.com/photos/reversefold/3163451773/in/set-72157612124977697/"><img title="Accordion finished" src="http://farm2.static.flickr.com/1106/3163451773_897441ae5f.jpg?v=0" alt="Accordion finished" width="500" height="375" /></a><p class="wp-caption-text">Accordion finished</p></div>
<p>That took several hours. The last step is to pop in the reverse folds, one row at a time. This is the most time consuming part of the process and for this fold it took me several nights with a small crafting tool. Here it is with five rows finished.</p>
<div class="wp-caption alignnone" style="width: 510px"><a href="http://www.flickr.com/photos/reversefold/3164284164/in/set-72157612124977697/"><img title="Five rows finished" src="http://farm2.static.flickr.com/1192/3164284164_c859b551a5.jpg?v=0" alt="Five rows finished" width="500" height="375" /></a><p class="wp-caption-text">Five rows finished</p></div>
<p>And after many painstaking hours of work, here is the finished product:</p>
<div class="wp-caption alignnone" style="width: 510px"><a href="http://www.flickr.com/photos/reversefold/3163461881/in/set-72157612124977697/"><img title="Finished fold" src="http://farm2.static.flickr.com/1130/3163461881_24c3366def.jpg?v=0" alt="Finished fold" width="500" height="375" /></a><p class="wp-caption-text">Finished fold</p></div>
<div class="wp-caption alignnone" style="width: 510px"><a href="http://www.flickr.com/photos/reversefold/3163459109/in/set-72157612124977697/"><img title="Finished fold, side view" src="http://farm2.static.flickr.com/1024/3163459109_0baea22192.jpg?v=0" alt="Finished fold, side view" width="500" height="375" /></a><p class="wp-caption-text">Finished fold, side view</p></div>
<div class="wp-caption alignnone" style="width: 510px"><a href="http://www.flickr.com/photos/reversefold/3163456711/in/set-72157612124977697/"><img title="Finished fold, 3/4 view" src="http://farm2.static.flickr.com/1087/3163456711_c642e49b18.jpg?v=0" alt="Finished fold, 3/4 view" width="500" height="375" /></a><p class="wp-caption-text">Finished fold, 3/4 view</p></div>
<p>And for a little perspective here is a shot of the finished fold compared to the original paper:</p>
<div class="wp-caption alignnone" style="width: 510px"><a href="http://www.flickr.com/photos/reversefold/3163466807/in/set-72157612124977697/"><img title="Finished fold vs. unfolded paper" src="http://farm4.static.flickr.com/3262/3163466807_08ca8fa83e.jpg?v=0" alt="Finished fold vs. unfolded paper" width="500" height="375" /></a><p class="wp-caption-text">Finished fold vs. unfolded paper</p></div>
<p>And just in case the quarter wasn&#8217;t enough, here&#8217;s the finished fold in my palm. Yes, it is that small. No, I won&#8217;t make you one. ;-)</p>
<div class="wp-caption alignnone" style="width: 510px"><a href="http://www.flickr.com/photos/reversefold/3164303556/in/set-72157612124977697/"><img title="Finished fold in the palm of my hand" src="http://farm4.static.flickr.com/3075/3164303556_d8fecc1739.jpg?v=0" alt="Finished fold in the palm of my hand" width="500" height="375" /></a><p class="wp-caption-text">Finished fold in the palm of my hand</p></div>
<p>All of these photos link to <a href="http://www.flickr.com/photos/reversefold/">my newly created flickr account</a>. The entire set is up there along with higher quality versions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.reversefold.com/blog/2009/01/07/%ce%bc-reversefold/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pretty equations in HTML</title>
		<link>http://www.reversefold.com/blog/2008/11/27/pretty-equations-in-html/</link>
		<comments>http://www.reversefold.com/blog/2008/11/27/pretty-equations-in-html/#comments</comments>
		<pubDate>Fri, 28 Nov 2008 02:25:53 +0000</pubDate>
		<dc:creator>papercrane</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[ASCIIMathML]]></category>
		<category><![CDATA[DHTML]]></category>
		<category><![CDATA[MathML]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.reversefold.com/blog/?p=79</guid>
		<description><![CDATA[You may have seen the nice looking equations in my last post. As part of the process of writing that post I researched MathML as a way of embedding the equations in the post. it turned out to be a complex markup language which renders very nicely but has a few big drawbacks. The first [...]]]></description>
			<content:encoded><![CDATA[<p>You may have seen the nice looking equations in <a href="/blog/2008/11/24/fitting-circles-within-a-larger-circle/">my last post</a>. As part of the process of writing that post I researched <a href="http://www.w3.org/Math/">MathML</a> as a way of embedding the equations in the post. it turned out to be a complex markup language which renders very nicely but has a few big drawbacks. The first is that only Firefox supports MathML in its core so far. There is a plugin for Internet Explorer which supports it but I doubt it&#8217;s widely installed. The second problem is that you can&#8217;t just put MathML in your web page and have Firefox interpret it. It turns out you need <a href="http://www1.chapman.edu/~jipsen/mathml/mathhtml/">a bit of Javascript</a> to make it pick up and render the MathML. This is great and makes equations render very well in Firefox but writing the MathML is a pain.</p>
<p>Enter <a href="http://www1.chapman.edu/~jipsen/mathml/asciimathsyntax.html">ASCIIMathML</a>, a JavaScript library which converts a simple ASCII format to MathML for rendering in MathML compliant browsers. The syntax is pretty much what you would expect with a few tricks up its sleeve. A simple equation, such as `y=x^2` is written as <tt>y=x^2</tt>. A more complicated example from my last post such as:<br />
`arc=2*cos^-1(1-r_2^2/(2*r_1^2))*r_1`<br />
is written as:</p>
<pre>arc=2*cos^-1(1-r_2^2/(2*r_1^2))*r_1</pre>
<p>Another example with a square root:<br />
`y=(+-r_2*sqrt(4*r_1^2-r_2^2))/(2*r_1)`</p>
<pre>y=(+-r_2*sqrt(4*r_1^2-r_2^2))/(2*r_1)</pre>
<p>Now, those if you viewing these posts in a non-Firefox browser are probably wondering why you are also seeing pretty equations here. The short answer is that you&#8217;re seeing images imstead of MathML rendered by your browser. The long answer involves a four part toolchain. The first piece is ASCIIMathML, slightly altered to insert an image tag instead of MathML. The images are generated by a PHP script which first runs the ASCII through <a href="http://www.oldschool.com.sg/index.php/module/Shared/action/Static/tmpl/ASCIIMathPHP">ASCHIIMathPHP</a>, a version of ASCIIMathML.js to PHP. The resulting MathML has the times symbol replace by one which the later tools understand (replace &amp;#8901; with &amp;#183;). The resulting MathML is then passed to <a href="http://www.grigoriev.ru/svgmath/">svgmath</a>, a python script which converts MathML to SVG. SVG would be great but Internet Explorer still doesn&#8217;t support it without a plugin. Because of this the SVG is then passed through inkscape via command-line to render out a png which is what you see in your browser.<br />
Here&#8217;s some sample PHP to run these commands:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$ascii</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'y=(+-r_2*sqrt(4*r_1^2-r_2^2))/(2*r_1)'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$pngFile</span> <span style="color: #339933;">=</span> <span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ascii</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.png'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pngFile</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">require</span> <span style="color: #0000ff;">'ASCIIMathPHP-2.0.cfg.php'</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">require</span> <span style="color: #0000ff;">'ASCIIMathPHP-2.0.class.php'</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$ascii_math</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ASCIIMathPHP<span style="color: #009900;">&#40;</span><span style="color: #000088;">$symbol_arr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$ascii_math</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setExpr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ascii</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$ascii_math</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>genMathML<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$mathml</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ascii_math</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getMathML<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$mathml</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'⋅'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'·'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$mathml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$mathmlFile</span> <span style="color: #339933;">=</span> <span style="color: #990000;">tempnam</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">sys_get_temp_dir</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mathml'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$td</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mathmlFile</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'w'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$td</span><span style="color: #339933;">,</span> <span style="color: #000088;">$mathml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$svgFile</span> <span style="color: #339933;">=</span> <span style="color: #990000;">tempnam</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">sys_get_temp_dir</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'svg'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">system</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/usr/bin/env python math2svg.py -s <span style="color: #006699; font-weight: bold;">$mathmlFile</span> &amp;gt; <span style="color: #006699; font-weight: bold;">$svgFile</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #990000;">system</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;inkscape -f <span style="color: #006699; font-weight: bold;">$svgFile</span> -e <span style="color: #006699; font-weight: bold;">$pngFile</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content-Type: image/png'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pngFile</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>All of this is also wrapped up in a Wordpress plugin which includes the JS file in the header. Unfortunately, I don&#8217;t have an easy way to package this up as it requires python and inkscape but if you would like to get more info just let me know and I&#8217;ll send you more information.</p>
<p><strong>UPDATE</strong>: I finally did update the plugin to be useful for others and <a href="http://www.reversefold.com/blog/2009/02/06/asciimathml-wordpress-plugin/">posted it</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.reversefold.com/blog/2008/11/27/pretty-equations-in-html/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Fitting circles within a larger circle</title>
		<link>http://www.reversefold.com/blog/2008/11/24/fitting-circles-within-a-larger-circle/</link>
		<comments>http://www.reversefold.com/blog/2008/11/24/fitting-circles-within-a-larger-circle/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 20:38:25 +0000</pubDate>
		<dc:creator>papercrane</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[algorithms]]></category>

		<guid isPermaLink="false">http://www.reversefold.com/blog/?p=62</guid>
		<description><![CDATA[I have been working on an internal graphical tool at work and had an interesting problem arise. How can I know how many smaller circles I can fit within a larger circle? The best way to lay them out that I came up with was to put the smaller circles in an arc inside of [...]]]></description>
			<content:encoded><![CDATA[<p>I have been working on an internal graphical tool at work and had an interesting problem arise. How can I know how many smaller circles I can fit within a larger circle? The best way to lay them out that I came up with was to put the smaller circles in an arc inside of the larger circle, just one smaller circle&#8217;s radius in from the edge of the large circle. This looks something like this:</p>
<div id="attachment_63" class="wp-caption alignleft" style="width: 261px"><a href="http://www.reversefold.com/blog/wp-content/uploads/2008/11/circles-within-a-circle.png"><img class="size-medium wp-image-63" title="circles-within-a-circle" src="http://www.reversefold.com/blog/wp-content/uploads/2008/11/circles-within-a-circle.png" alt="Circles within a circle" width="251" height="250" /></a><p class="wp-caption-text">Circles within a circle</p></div>
<p>When the first arc is filled up you then move to an arc which is the diameter of the small circles further within the large circle. The problem, however, is how to know how many circles can fit along that arc. I started originally with a simplistic realization that the arc length would be similar to the diameter of the small circles. This works out ok but ends up creating problems especially when you get close to the center of the larger circle (i.e. when the radius of the arc is close to the radius of the small circles). The correct solution is to calculate the exact angle along the arc that the circle takes up. After a few false starts with incorrect assumptions regarding tangent lines and their lengths I came up with the following.</p>
<div id="attachment_88" class="wp-caption alignnone" style="width: 406px"><a href="http://www.reversefold.com/blog/wp-content/uploads/2008/11/geometry1.png"><img src="http://www.reversefold.com/blog/wp-content/uploads/2008/11/geometry1.png" alt="Geometric definition" title="Geometric definition" width="396" height="343" class="size-full wp-image-88" /></a><p class="wp-caption-text">Geometric definition</p></div>
<ul>
<li>The large circle is centered at the origin</li>
<li>`r_1` is the radius of the large circle</li>
<li>`C` is the center of the small circle</li>
<li>`r_2` is the radius of the large circle</li>
<li>`I` are the interseciton points between the circles</li>
<li>`theta` is the angle between the x axis and the line from the origin to `I`</li>
<li>`arc` is the length of the arc between the two interseciton points (`I`)</li>
</ul>
<h3>Given</h3>
<p>`C=(r_1,0)`<br />
`I=(x,+-y)`<br />
`theta=cos^-1(x/r_1)`<br />
`arc=2*theta*r_1`</p>
<h3>Circle Equations</h3>
<p>`x^2+y^2=r_1^2`<br />
`(x-r_1)^2+y^2=r_2^2`</p>
<h3>Solve for `y^2`</h3>
<p>`y^2=r_1^2-x^2`<br />
`y^2=r_2^2-(x-r_1)^2`</p>
<h3>Set equal and solve for `x`</h3>
<p>`r_2^2-(x-r_1)^2=r_1^2-x^2`<br />
`x^2-(x^2-2*x*r_1+r_1^2)=r_1^2-r_2^2`<br />
`2*x*r_1-r_1^2=r_1^2-r_2^2`<br />
`2*x*r_1=2*r_1^2-r_2^2`<br />
`x=(2*r_1^2-r_2^2)/(2*r_1)`<br />
`x=r_1-r_2^2/(2*r_1)`</p>
<h3>`theta` is then:</h3>
<p>`theta=cos^-1((r_1-r_2^2/(2*r_1))/r_1)`<br />
`theta=cos^-1(1-r_2^2/(2*r_1^2))`</p>
<p>You could then use `theta` directly but this will leave you with a remainder of space that&#8217;s empty in the arc. To make the circles equally spaced you need the arc length.</p>
<h3>Replace values for a full `arc` formula</h3>
<p>`arc=2*cos^-1(1-r_2^2/(2*r_1^2))*r_1`</p>
<p>You can then divide the large circle&#8217;s circumfrence by the arc length to get the actual number of circles that will fit. You then divide the circle into that many pieces and voila, you get equally spaced circles like the first image above.</p>
<h3>`y` is not needed for the solution, but comes out to be:</h3>
<p>`y=(+-r_2*sqrt(4*r_1^2-r_2^2))/(2*r_1)`</p>
]]></content:encoded>
			<wfw:commentRss>http://www.reversefold.com/blog/2008/11/24/fitting-circles-within-a-larger-circle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Falling Away</title>
		<link>http://www.reversefold.com/blog/2008/10/28/falling-away/</link>
		<comments>http://www.reversefold.com/blog/2008/10/28/falling-away/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 18:33:06 +0000</pubDate>
		<dc:creator>papercrane</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[bitmapdata]]></category>
		<category><![CDATA[flash 10]]></category>

		<guid isPermaLink="false">http://www.reversefold.com/wordpress/?p=49</guid>
		<description><![CDATA[I had a new idea last night on my way home for a simple use of Flash 10&#8217;s 3D to do a simple visualization. Imagine that you are looking down at the ground from high up. Suddenly the screen falls away and starts falling to the ground. Then the ground you were looking at falls [...]]]></description>
			<content:encoded><![CDATA[<p>I had a new idea last night on my way home for a simple use of Flash 10&#8217;s 3D to do a simple visualization. Imagine that you are looking down at the ground from high up. Suddenly the screen falls away and starts falling to the ground. Then the ground you were looking at falls away and you rezlize that it was only a screen. Repeat.</p>
<p><a href="http://www.reversefold.com/flash/falling_away/"><img class="alignnone" title="Falling Away Screenshot" src="http://www.reversefold.com/flash/falling_away/screenshot.jpg" alt="" width="440" height="331" /></a></p>
<p>This screenshot shows the app running with a flickr satellite photo feed displaying on each falling plane. Unfortunately, since my code uses <tt>BitmapData.draw()</tt>, this won&#8217;t work from the web as I don&#8217;t want to run a flickr proxy. The linked version simply colors the planes, but you can get the idea from it. Right click the movie to view its code. If you run it locally with <tt>USE_FLICKR = true</tt> you can see the full effect.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.reversefold.com/blog/2008/10/28/falling-away/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash 10 Camp, 3D, Sound Creation, and IK</title>
		<link>http://www.reversefold.com/blog/2008/10/12/flash-10-camp-3d-sound-creation-and-ik/</link>
		<comments>http://www.reversefold.com/blog/2008/10/12/flash-10-camp-3d-sound-creation-and-ik/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 04:54:02 +0000</pubDate>
		<dc:creator>papercrane</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[flash 10]]></category>
		<category><![CDATA[flashcamp]]></category>
		<category><![CDATA[ik]]></category>
		<category><![CDATA[sound]]></category>

		<guid isPermaLink="false">http://www.reversefold.com/wordpress/?p=45</guid>
		<description><![CDATA[I&#8217;ve just come home from Flash(10)Camp and am winding down. I had a lot of fun, saw some coll stuff, and even won Best Audio (with my team) with our app Flash Tones.

I was actually very surprised, there were a lot of well done apps, including others that generated sound but I guess we just [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just come home from <a title="FlashCamp" href="http://www.flashcamp.org/">Flash(10)Camp</a> and am winding down. I had a lot of fun, saw some coll stuff, and even won Best Audio (with my team) with our app <a title="Flash Tones" href="http://www.reversefold.com/flashCamp/flashTones/">Flash Tones</a>.</p>
<p><a href="http://www.reversefold.com/flashCamp/flashTones/"><img class="alignnone" title="Flash Tones" src="http://www.reversefold.com/flashCamp/flashTones/screenshot.png" alt="" width="438" height="318" /></a></p>
<p>I was actually very surprised, there were a lot of well done apps, including others that generated sound but I guess we just had the app polished well enough. Thanks to Rod for that, he gave us the last few bits that really made it look nice. You&#8217;ll need Flash Player 10 and a web cam if you want to try it out.</p>
<p>All of the features I saw in Flash Player 10 were ones I&#8217;d seen before, except for the sound generation. Things were more in depth and better put together this time, though. The sound generation is nice, but complicated and hard to make it do what you&#8217;re expecting. Of course, I&#8217;m assuming you know almost nothing about the specifics of sound, like I do.</p>
<p>IK is fun, but I I focused on the other 2 as I didn&#8217;t have any IK idea that seemed particularly interesting.</p>
<p>The 3D is very nice, being able to move and rotate objects in all three dimensions opens up a lot of new possibilities. I had a lot of fun creating some simple squares and rotating them, then applying various blend modes and filters. Here are 2 of my favorites:</p>
<p><a href="http://www.reversefold.com/flashCamp/knockoutSquares/"><img class="alignnone" title="Knockout Squares" src="http://www.reversefold.com/flashCamp/knockoutSquares/screenshot.png" alt="" width="437" height="316" /></a></p>
<p><a href="http://www.reversefold.com/flashCamp/redSquares/"><img class="alignnone" title="Red Squares" src="http://www.reversefold.com/flashCamp/redSquares/screenshot.png" alt="" width="435" height="318" /></a></p>
<p>Those were fun but then someone mentioned webcams. I successfully connected up webcam video to my project and then spent several hours getting the video mapped to each of the rotating squares then getting it all matched up with the video behind it. I then added edge detection (thanks to <a title="Sobel Edge Detection" href="http://lukewalsh.co.uk/blog/2008/06/sobel-edge-detection-in-flash.html">Luke Walsh&#8217;s post</a>), added some more blending and filters and voila!</p>
<p><a href="http://www.reversefold.com/flashCamp/blueSquares/"><img class="alignnone" title="Blue Squares" src="http://www.reversefold.com/flashCamp/blueSquares/screenshot.png" alt="" width="437" height="316" /></a></p>
<p>I was quite proud of that and still think it looks cool. I wish I&#8217;d shown it earlier at the Hackathon but then again we won an award so I guess I&#8217;m just being greedy.</p>
<p>As an added bonus, here&#8217;s an earlier version of Flash Tones which warbled in an interesting way. Try putting your hand up at the very right edge of the screen.</p>
<p><a href="http://www.reversefold.com/flashCamp/flashTones/warble/"><img class="alignnone" title="Warbling Flash Tones" src="http://www.reversefold.com/flashCamp/flashTones/warble/screenshot.png" alt="" width="437" height="317" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.reversefold.com/blog/2008/10/12/flash-10-camp-3d-sound-creation-and-ik/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex Bug: Icon shadows in a TabNavigator&#8217;s Tabs</title>
		<link>http://www.reversefold.com/blog/2008/05/27/flex-bug-icon-shadows-in-a-tabnavigators-tabs/</link>
		<comments>http://www.reversefold.com/blog/2008/05/27/flex-bug-icon-shadows-in-a-tabnavigators-tabs/#comments</comments>
		<pubDate>Wed, 28 May 2008 01:59:36 +0000</pubDate>
		<dc:creator>papercrane</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[icon]]></category>
		<category><![CDATA[tabnavigator]]></category>

		<guid isPermaLink="false">http://www.reversefold.com/wordpress/?p=42</guid>
		<description><![CDATA[This is likely a generic problem with anything that uses a Button but I have found this issue with Tabs in a TabNavigator specifically. When you have a TabNavigator with multiple complicated children that take a while to load, clicking one tab then clicking another quickly can lead to a &#8220;shadow&#8221; icon at the top-left [...]]]></description>
			<content:encoded><![CDATA[<p>This is likely a generic problem with anything that uses a Button but I have found this issue with Tabs in a TabNavigator specifically. When you have a TabNavigator with multiple complicated children that take a while to load, clicking one tab then clicking another quickly can lead to a &#8220;shadow&#8221; icon at the top-left of the tabs. See the bug for more: <a href="https://bugs.adobe.com/jira/browse/SDK-15656">SDK-15656</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.reversefold.com/blog/2008/05/27/flex-bug-icon-shadows-in-a-tabnavigators-tabs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running JavaScript when the page finishes loading</title>
		<link>http://www.reversefold.com/blog/2008/05/23/running-javascript-when-the-page-finishes-loading/</link>
		<comments>http://www.reversefold.com/blog/2008/05/23/running-javascript-when-the-page-finishes-loading/#comments</comments>
		<pubDate>Fri, 23 May 2008 21:54:29 +0000</pubDate>
		<dc:creator>papercrane</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[onload]]></category>

		<guid isPermaLink="false">http://www.reversefold.com/wordpress/?p=41</guid>
		<description><![CDATA[I know what you&#8217;re thinking. window.onload and &#60;body onload&#62; already let you run javascript when the page loads. Why do I need something more? The answer is that the standard onload only runs when the entire page and its dependencies are finished loading. This means that if you have multiple images (such as tracking tags) [...]]]></description>
			<content:encoded><![CDATA[<p>I know what you&#8217;re thinking. <tt>window.onload</tt> and <tt>&lt;body onload&gt;</tt> already let you run javascript when the page loads. Why do I need something more? The answer is that the standard <tt>onload</tt> only runs when the entire page <strong>and its dependencies</strong> are finished loading. This means that if you have multiple images (such as tracking tags) or scripts or a large swf, the <tt>onload</tt>ed code will only run once all of those pieces load. The point of the following is to run some JavaScript once the page itself has loaded and been parsed. This allows you to do things like set the background color, add additional elements, or start loading other dependencies while the rest of the page&#8217;s depdencies are loading. This is particularly useful if you need to do something on a page while a large swf is loading.</p>
<p>The following is a combination of <a href="http://dean.edwards.name/weblog/2005/09/busted/">several</a> <a href="http://dean.edwards.name/weblog/2006/06/again/">posts</a> on <a href="http://dean.edwards.name/weblog/">Dean Edwards&#8217; blog</a> as well as an <tt>onload</tt> handler for those browsers that don&#8217;t support this kind of solution that I found elsewhere. This may not work in Opera, I am not sure. According to the second post Opera supports <tt>DOMContentLoaded</tt> but I don&#8217;t know if this code will catch Opera properly.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> init<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;">// quit if this function has already been called</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>arguments.<span style="color: #660066;">callee</span>.<span style="color: #660066;">done</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
  <span style="color: #006600; font-style: italic;">// flag this function so we don't do the same thing twice</span>
  arguments.<span style="color: #660066;">callee</span>.<span style="color: #660066;">done</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #006600; font-style: italic;">//CODE TO RUN GOES HERE</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// for Mozilla browsers</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  document.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;DOMContentLoaded&quot;</span><span style="color: #339933;">,</span> init<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span>
<span style="color: #006600; font-style: italic;">// for Safari</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/WebKit/i</span>.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>navigator.<span style="color: #660066;">userAgent</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// sniff</span>
  <span style="color: #003366; font-weight: bold;">var</span> _timer <span style="color: #339933;">=</span> setInterval<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: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/loaded|complete/</span>.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">readyState</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      clearInterval<span style="color: #009900;">&#40;</span>_timer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// call the onload handler</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span>
<span style="color: #006600; font-style: italic;">//for those other poor souls</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">function</span> addLoadEvent<span style="color: #009900;">&#40;</span>func<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> oldonload <span style="color: #339933;">=</span> window.<span style="color: #000066;">onload</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> window.<span style="color: #000066;">onload</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">'function'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      window.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> func<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>
      window.<span style="color: #000066;">onload</span> <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>
        oldonload<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        func<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: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  addLoadEvent<span style="color: #009900;">&#40;</span>init<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #006600; font-style: italic;">// for Internet Explorer (using conditional comments)</span>
<span style="color: #009966; font-style: italic;">/*@cc_on @*/</span>
<span style="color: #006600; font-style: italic;">/*@if (@_win32)
document.write(&quot;&lt;script id='__ie_onload' src='javascript:void(0)'&gt;&lt;/script&gt;&quot;);
var script = document.getElementById(&quot;__ie_onload&quot;);
script.onreadystatechange = function() {
  if (this.readyState == &quot;complete&quot;) {
    init(); // call the onload handler
  }
};
/*@end @*/</span></pre></div></div>

<p>UPDATE: fixed the code above. Wordpress was screwing up the last bit due to its insistence on changing the preformatted HTML in the code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.reversefold.com/blog/2008/05/23/running-javascript-when-the-page-finishes-loading/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
