<?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>makemachine</title>
	<atom:link href="http://labs.makemachine.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://labs.makemachine.net</link>
	<description>things that make things that make</description>
	<lastBuildDate>Fri, 17 Feb 2012 05:06:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Processing with Jython and Eclipse</title>
		<link>http://labs.makemachine.net/2012/02/processing-with-jython-and-eclipse/</link>
		<comments>http://labs.makemachine.net/2012/02/processing-with-jython-and-eclipse/#comments</comments>
		<pubDate>Fri, 17 Feb 2012 05:01:31 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://labs.makemachine.net/?p=715</guid>
		<description><![CDATA[Instructions for setting up a Processing with Jython development environment from scratch]]></description>
			<content:encoded><![CDATA[<p>I am always looking for a reason to use Python more often, especially in situations where I&#8217;ll need to prototype rapidly, as is often the case when tasked with programming graphics. So, when a client proposed that I use Processing (Java) to build an up-coming project, I immediately thought it would be worth my time to investigate the possibility of writing a Processing app with the Java implementation of Python called Jython. In this post I&#8217;ll go through the steps I took to set up a development environment to facilitate this.</p>
<p>Note: I&#8217;m working on a Mac and have not tested this on a Windows machine. If anyone attempts to do so based on these instructions please send feedback or leave a comment. Also, this is a work in progress. I have not been able to test all of the features of Processing yet. Please see the caveat at the bottom of this page if you are expecting this to work seamlessly. Lastly, I am aware of the <a href="https://github.com/jdf/processing.py">existing pyprocessing project available on Github</a>. It is sweet and seems to work well. If you want to dive right into to using Jython with Processing, check it out. This post is more of a reminder to myself and anyone else of how to set it all up from scratch. </p>
<p>Setting it all up basically involves installing some dependencies and linking them together.</p>
<ul>
<li><a href="http://www.jython.org/" title="Jython home">Jython</a> &#8211; This the Java implementation of Python. Just download the installer and double click it. There are a couple of prompts but the most important one to take note of is where Jython is being installed. You can install it anywhere on your system. Mine, for example, is installed at:
<pre class="code">/Users/makemachine/development/libs/jython/2.5.2/</pre>
<p>Once Jython is installed, you can add it to your path and test it by typing <code>jython</code> into the Terminal. If all is well, you should see the familiar Python interactive shell, however it will actually be the Jython interactive shell. My .bash_profile looks something like this: </p>
<pre class="code">
PATH="/Users/makemachine/development/libs/jython/2.5.2/bin:${PATH}"
export PATH
</pre>
</li>
<li><a href="http://www.eclipse.org/downloads/packages/eclipse-ide-java-developers/indigosr1" title="Eclipse download page">Eclipse</a> &#8211; If you are not familiar with Eclipse, it is an IDE ( integrated development environment ) that allows you to run, launch, debug and profile code for many differently languages. I installed the &#8220;Eclipse IDE for Java Developers&#8221; version, which I believe is a fairly basic version of Eclipse.</li>
<li><a href="http://pydev.org/manual_101_install.html" title="PyDev install instructions">PyDev</a> &#8211; PyDev is a plugin for Eclipse that enables some really nice features for writing Python in Eclipse. It can be installed in a couple of different ways. I found that just using Eclipse&#8217;s built in plugin manager worked well. Once installed you should restart Eclipse. One way to verify that PyDev is installed is to go to Eclipse » Preferences and look for PyDev in the right hand menu.</li>
<li><a href="http://processing.org/">Processing</a> &#8211; Before you can get to writing a Processing app, you will need to actually download Processing. Once it is downloaded, copy it to your Applications directory. I decided to make a copy of the contents of the Processing.app file and save them to another location on my computer. I did this just so I would have the files sand-boxed so that in the event of something breaking, Processing will still work as normal. To do this, right-click the Processing app, choose Show Package Contents, navigate to Contents » Resources » Java. Copy and paste this Java folder somewhere on your system. I placed mine at:
<pre class="code">/Users/makemachine/development/libs/processing</pre>
</li>
</ul>
<p>Now that everything is installed you can start a project:</p>
<ul>
<li>Open Eclipse</li>
<li>Choose Window » Open Perspective » Other and choose PyDev</li>
<li>Right-click in the PyDev Package Explore on the left side of the screen</li>
<li>Choose New » Project</li>
<li>Choose PyDev Project from the menu</li>
<li>Set a name for your project and the place it should live on your computer</li>
<li>Choose &#8220;Jython&#8221; for project type</li>
<li>If this is the first time you&#8217;ve used PyDev and Jython in Eclipse you will need to set the path to Jython</li>
<ul>
<li>Click &#8220;Configure an interpreter&#8221;</li>
<li>Under Jython interpreters click the &#8220;New&#8221; button and browse to the location of the jython.jar file in the top level dir where you saved Jython in the first step.</li>
<li>Click &#8220;Ok&#8221;</li>
</ul>
<li>Click &#8220;Finish&#8221;</li>
<li>Next you need to link the Processing files to the project</li>
<li>Right-click the Project file in the PyDev Package Explorer and choose &#8220;Properties&#8221;</li>
<li>Under PyDev &#8211; PYTHONPATH, choose the External Libraries tab</li>
<li>Click the &#8220;Add zip/jar/egg&#8221; button</li>
<li>Navigate to the location where you saved the Processing libraries and select each of the following .jar files</li>
<ul>
<li>core.jar</li>
<li>modes/java/libraries/java/opengl/library/gluegen-rt.jar</li>
<li>modes/java/libraries/java/opengl/library/jogl.jar</li>
<li>modes/java/libraries/java/opengl/library/opengl.jar</li>
</ul>
<li>Click &#8220;Ok&#8221;</li>
<li>Right click the &#8220;src&#8221; folder in your project and choose New » PyDev module, name it main.py ( or whatever you want )</li>
<li>Choose &#8220;Module:Main&#8221; form the list</li>
<li>Click &#8220;Ok&#8221;</li>
</ul>
<p>Now you should be able to run compile and run a Processing app! Here is some boilerplate code. </p>
<pre class="code">
from processing.core import PApplet

class JythonProcessingApp( PApplet ):
    def setup(self):
        self.size(960, 540)
        pass

    def update(self, n):

        pass

    def draw(self):
        self.background(0)
        pass

if __name__ == '__main__':
    PApplet.runSketch( ['A Jython Processing App'], JythonProcessingApp() )
</pre>
<p>To run it, with main.py open in the editor, click the little green button with a white arrow in the toolbar at the top left of the screen. If everything is working you should see a Processing app open. Right now it is not doing anything except redrawing a black screen on every frame, but that is a good start!</p>
<p>If you want to use Processing in the OPENGL mode there is one last step. You must add the path to the native OpenGL libraries. This is pretty trivial but took me <a href="http://stackoverflow.com/questions/9233516/configuring-jython-processing-and-opengl-with-pydev">quite a while to figure it out</a>. </p>
<ul>
<li>Click the little down arrow next to the green run button and choose &#8220;Run Configurations&#8221;</li>
<li>Under &#8220;Jython Run&#8221;, choose your project</li>
<li>Selecte the &#8220;(x)=Arguments&#8221; tab</li>
<li>In the VM Arguments box add this:
<pre class="code">-Djava.library.path=YOUR PATH TO PROCESSING LIBS/Java/modes/java/libraries/opengl/library/macosx/</pre>
</li>
</ul>
<p><strong>CAVEAT:</strong></p>
<p>This will allow you to run Processing apps in OPENGL mode. That said, <a href="http://bit.ly/z137cF ">I have run into an issue where certain OPENGL commands seem to be failing</a>. Hence, there is more work to be done. </p>
<p>Looking at the instructions above, this seems like a daunting task, but I assure you, that it is nothing more than installing a few things and understanding how to link them together.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.makemachine.net/2012/02/processing-with-jython-and-eclipse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flying Low</title>
		<link>http://labs.makemachine.net/2011/12/flying-low/</link>
		<comments>http://labs.makemachine.net/2011/12/flying-low/#comments</comments>
		<pubDate>Sat, 10 Dec 2011 01:56:23 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://labs.makemachine.net/?p=710</guid>
		<description><![CDATA[A quick update on what I've been up to in the past couple of months]]></description>
			<content:encoded><![CDATA[<p>November was the first month, since starting this blog, that I haven&#8217;t posted any new material. ;{ </p>
<h2>What have I been doing?</h2>
<p>I have been flying low&#8230; researching, thinking and seeking new a direction for makemachine and my path in general.</p>
<p><strong>New Site</strong><br />
I did re-build my portfolio site! Check it out here: <a href="http://jeremynealbrown.com">http://jeremynealbrown.com</a>. A re-design is probably inevitable for makemachine too.</p>
<p><strong>Reading</strong><br />
I recently read a great book called &#8220;You Are Not a Gadget&#8221;, by Jaron Lanier, which inspired me in many ways. </p>
<p><a href="http://www.jaronlanier.com/"><img src="http://labs.makemachine.net/wp-content/uploads/2011/12/you_are_not_a_gadget.jpg" alt="" title="you_are_not_a_gadget" width="131" height="197" class="alignnone size-full wp-image-711" /></a> </p>
<p><strong>School</strong><br />
One of the first things that I did when I got back from my travels was sign up for college math courses. It&#8217;s been great, I&#8217;ve learned/re-learned a ton and I&#8217;m continuing with it next term. </p>
<p><strong>irl-social</strong><br />
<a href="http://labs.makemachine.net/2011/09/the-codex/">Starting the Codex</a> up has been a really interesting experience. We are now renting the space that we were previously only borrowing for the meetings. There is much room for growth there. </p>
<p><strong>Musix</strong><br />
Soundcloud has recently become a home to <a href="http://soundcloud.com/makemachine">some of my original music, released also under the makemachine moniker</a>.</p>
<p><iframe width="100%" height="166" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F30210971&amp;auto_play=false&amp;show_artwork=true&amp;color=00b5ff"></iframe></p>
<p><strong>Programming</strong><br />
From Clojure &#038; Haskell to Python &#038; C++, I&#8217;ve been trying out all sorts of languages and libraries and learning volumes. In a perfect world I would only need one language that was capable of every programming task. However, there are so many unique challenges and domains today, it is not likely that one can do it all. Poor Flash and it&#8217;s neatly built language ActionScript. It seems like many people have nothing nice to say about it these days. Well, I have held back my urge to contribute to the flames of forum and comment wars about it and I will continue to do so. I&#8217;m not a platform evangelist. I do wish it was not taking such a beating though. It is a great language and a fun platform to write code for. </p>
<p><strong>In Conclusion</strong><br />
It is not by mistake that this post is scattered and rambling. There are many irons in many fires, but one thing I am sure of is that there is much more in store for makemachine. </p>
]]></content:encoded>
			<wfw:commentRss>http://labs.makemachine.net/2011/12/flying-low/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Kinect SDK on a Mac</title>
		<link>http://labs.makemachine.net/2011/10/kinect-sdk-on-a-mac/</link>
		<comments>http://labs.makemachine.net/2011/10/kinect-sdk-on-a-mac/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 18:51:49 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Cinder]]></category>
		<category><![CDATA[Kinect]]></category>
		<category><![CDATA[bootcamp]]></category>
		<category><![CDATA[kinect-sdk]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[openGL]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://labs.makemachine.net/?p=703</guid>
		<description><![CDATA[Earlier this summer I picked up a freelance Kinect gig. The client was pretty adamant about using the official Kinect SDK from Microsoft. The SDK is only available for Windows and as a Mac user, I had to make the decision wether or not to purchase a new Windows machine, try a virtual machine solution [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://labs.makemachine.net/wp-content/uploads/2011/10/IMG_4557.jpg" alt="" title="IMG_4557" width="600" height="450" class="alignnone size-full wp-image-704" /></p>
<p>Earlier this summer I picked up a freelance Kinect gig. The client was pretty adamant about using <a href="http://research.microsoft.com/en-us/um/redmond/projects/kinectsdk/">the official Kinect SDK from Microsoft</a>. The SDK is only available for Windows and as a Mac user, I had to make the decision wether or not to purchase a new Windows machine, try a virtual machine solution or use Bootcamp. </p>
<p>Purchasing a dedicated Windows box was the least risky, but the thought of having two computers around was not that appealing. Add to that the fact that the hardware specs on most consumer PC laptops are pretty limited compared to a the Mac and it is becomes harder to make an argument in favor of making the new purchase. </p>
<p>Knowing that the Kinect SDK required quite a large number of dependencies including both drivers and frameworks and that it requires considerable integration with actual hardware, the virtual machine option seemed pretty uncertain.</p>
<p>The last option, partitioning my disk and running Windows via Bootcamp became the most desirable solution. Still for many of the same concerns as running a virtual machine, I was certain that all of the drivers and frameworks would play nicely with Windows running on my Mac. </p>
<p>Just for clarity, here are my laptop specs: </p>
<p>Unibody Mac Book Pro<br />
2.2 GHz Intel Core i7<br />
8 GB 1333 MHz DDR3 Ram<br />
128 GB Solid State HD</p>
<p>I ultimately ended up using Cinder and the KinectSDK block written by my friend Stephen Schieberl and documented here: <a href="http://forum.libcinder.org/topic/kinect-sdk-block">http://forum.libcinder.org/topic/kinect-sdk-block</a> and here: <a href="http://www.bantherewind.com/kinect-sdk-block-for-cinder">http://www.bantherewind.com/kinect-sdk-block-for-cinder</a>. </p>
<p>The point of this article is to broadcast that it is not only possible to run the <a href="http://research.microsoft.com/en-us/um/redmond/projects/kinectsdk/">Kinect SDK</a> on a Mac but that it works very well. I won&#8217;t go into detail about the installation process. Essentially you need to install Windows and then all of the dependencies for the SDK which are documented on the <a href="http://research.microsoft.com/en-us/um/redmond/projects/kinectsdk/">Kinect SDK website</a>.</p>
<p>If you are running into problems, feel free to leave a question in the comments section or e-mail me personally.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.makemachine.net/2011/10/kinect-sdk-on-a-mac/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Recursion Inspired Audio Sequencer</title>
		<link>http://labs.makemachine.net/2011/09/recursion-inspired-audio-sequencer/</link>
		<comments>http://labs.makemachine.net/2011/09/recursion-inspired-audio-sequencer/#comments</comments>
		<pubDate>Mon, 12 Sep 2011 15:10:07 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Audio]]></category>
		<category><![CDATA[Synthesis]]></category>
		<category><![CDATA[Visualizations]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[audio visualizer]]></category>
		<category><![CDATA[dynamic audio]]></category>
		<category><![CDATA[generative]]></category>
		<category><![CDATA[recursion]]></category>
		<category><![CDATA[self-similarity]]></category>

		<guid isPermaLink="false">http://labs.makemachine.net/?p=701</guid>
		<description><![CDATA[<a href="http://wp.me/pPFvc-bj"><img src="http://labs.makemachine.net/wp-content/uploads/2011/09/codex_recursion_index.jpg" alt="" title="codex_recursion_index" width="600" height="200" class="alignnone size-full wp-image-702" /></a>
A generative audio sequencer using inspired by the concepts of recursion, feedback and self-similarity]]></description>
			<content:encoded><![CDATA[
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_CodexRecursionApp_1152778054"
			class="flashmovie"
			width="620"
			height="400">
	<param name="movie" value="http://labs.makemachine.net/wp-content/uploads/2011/09/CodexRecursionApp.swf" />
	<param name="flashvars" value="root_url=http://labs.makemachine.net/wp-content/uploads/2011/09/" />
	<param name="scale" value="noscale" />
	<param name="salign" value="tl" />
	<param name="wmode" value="opaque" />
	<param name="allowfullscreen" value="true" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://labs.makemachine.net/wp-content/uploads/2011/09/CodexRecursionApp.swf"
			name="fm_CodexRecursionApp_1152778054"
			width="620"
			height="400">
		<param name="flashvars" value="root_url=http://labs.makemachine.net/wp-content/uploads/2011/09/" />
		<param name="scale" value="noscale" />
		<param name="salign" value="tl" />
		<param name="wmode" value="opaque" />
		<param name="allowfullscreen" value="true" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>This experiment uses the concept of recursion and feedback to generatively compose audio. Currently the compositions are composed of several pre-recorded audio files each with rhythms at 120 b.p.m. As the app runs, audio from each queued loop is pushed into an audio buffer and during that process by way of some randomness each loop has the possibility of spawning a new node. All spawning happens on one of 8 beats in each measure. This ensures that the tracks stay in time with one another.</p>
<p>None of the audio files are properly mastered so the output is a little low. Additionally, most of the sounds are muted or bass heavy and hence not very audible through laptop speakers. Headphones or speakers are recommended. Also, keep in mind that because each composition is based on recursion and randomness, so sometimes a composition will consist of only one or only a few loops. Just press play again.</p>
<p>Initially I built this app for The Codex, a collective of creative technologists here in Portland. <a href="http://codex.makemachine.net">Read more about The Codex here</a>. I plan to continue to develop this project. There are many directions this thing could go. To be continued&#8230; </p>
]]></content:encoded>
			<wfw:commentRss>http://labs.makemachine.net/2011/09/recursion-inspired-audio-sequencer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Codex</title>
		<link>http://labs.makemachine.net/2011/09/the-codex/</link>
		<comments>http://labs.makemachine.net/2011/09/the-codex/#comments</comments>
		<pubDate>Sun, 11 Sep 2011 23:35:04 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://labs.makemachine.net/?p=696</guid>
		<description><![CDATA[<a href="http://wp.me/pPFvc-be"><img src="http://labs.makemachine.net/wp-content/uploads/2011/09/codex_index.jpg" alt="" title="codex_index" width="600" height="200" class="alignnone size-full wp-image-698" /></a>

A group of creative thinkers and doers has emerged!]]></description>
			<content:encoded><![CDATA[<p>Hello friends of the internet. I&#8217;d like to introduce you to my friends of the physical world. </p>
<p><img src="http://labs.makemachine.net/wp-content/uploads/2011/09/code_meeting.jpg" alt="" title="code_meeting" width="600" height="400" class="alignnone size-full wp-image-699"/></p>
<p>Last year, before the grand adventure all over the globe, my friends and I started meeting up on a regular basis to exchange ideas about code and technology. Well, I&#8217;ve been back on the West Coast for a while and have decided that it is once again time to gather friends to share ideas.</p>
<p>However, this time I wanted things to be a little different. As opposed to the meetings we held last year, I was hoping that the next round of gatherings would be more open and inviting to disciplines outside of the world of software and programming. Artists, musicians, concept designers, IA, AI and many more creative minds would all be welcome. After a few e-mails, securing a meeting place and finding a projector to use, the plan was laid for a night of serious geek time. </p>
<p>The first meeting was a big success. You can read about it <a href="http://codex.makemachine.net">here on a new makemachine subdomain.</a> This is where you can stay up to date with whats happening with our group. The name of the group is &#8220;The Codex&#8221;, which has it&#8217;s roots in our original concept, as a code exchange.</p>
<p>The future of The Codex, is very open. We have begun to form a set of basic guidelines that will help inform our decisions as a group. Conversations have started about group projects and community outreach, but at the moment we are focussing smaller projects.</p>
<p>Check out the new site here: <a href="http://codex.makemachine.net/">http://codex.makemachine.net/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://labs.makemachine.net/2011/09/the-codex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UI Elements Customization</title>
		<link>http://labs.makemachine.net/2011/08/ui-elements-customization/</link>
		<comments>http://labs.makemachine.net/2011/08/ui-elements-customization/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 06:34:08 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Actionscript]]></category>

		<guid isPermaLink="false">http://labs.makemachine.net/?p=693</guid>
		<description><![CDATA[A quick example of customizing the look of the user interface lib I released last week]]></description>
			<content:encoded><![CDATA[<p>I just <a href="http://bit.ly/pxgVLv">committed a new sample project</a> demonstrating how to customize the appearance of the user interface components I released last week. </p>
<p>Here it is in action: </p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_UICustomizationApp_155234282"
			class="flashmovie"
			width="295"
			height="248">
	<param name="movie" value="http://labs.makemachine.net/wp-content/uploads/2011/08/UICustomizationApp.swf" />
	<param name="scale" value="noscale" />
	<param name="salign" value="tl" />
	<param name="wmode" value="opaque" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://labs.makemachine.net/wp-content/uploads/2011/08/UICustomizationApp.swf"
			name="fm_UICustomizationApp_155234282"
			width="295"
			height="248">
		<param name="scale" value="noscale" />
		<param name="salign" value="tl" />
		<param name="wmode" value="opaque" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>As you can see you can have multiple styles at the same time. Setting the styles couldn&#8217;t be much simpler. It just requires setting some static vars on the <code>Factory</code> class. </p>
<pre class="code">
// -- gray and green
Factory.BACKGROUND_COLOR = 0x333333;
Factory.METER_FILL_COLOR_1 = 0xb4ff00;
Factory.METER_FILL_COLOR_2 = 0x76a700;
Factory.TEXT_COLOR_1 = 0xb4ff00
Factory.TEXT_COLOR_2 = 0xffffff;
Factory.MOUSE_UP_COLOR = Factory.BACKGROUND_COLOR;
Factory.MOUSE_OVER_COLOR = 0x555555
Factory.BACKGROUND_CORNER_RADIUS = 0;
</pre>
<p>It is also possible to customize the fonts used, like so:</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_UICustomizationApp_font_341258256"
			class="flashmovie"
			width="295"
			height="248">
	<param name="movie" value="http://labs.makemachine.net/wp-content/uploads/2011/08/UICustomizationApp_font.swf" />
	<param name="scale" value="noscale" />
	<param name="salign" value="tl" />
	<param name="wmode" value="opaque" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://labs.makemachine.net/wp-content/uploads/2011/08/UICustomizationApp_font.swf"
			name="fm_UICustomizationApp_font_341258256"
			width="295"
			height="248">
		<param name="scale" value="noscale" />
		<param name="salign" value="tl" />
		<param name="wmode" value="opaque" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object> 
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_UICustomizationApp_font_2_1678650510"
			class="flashmovie"
			width="295"
			height="248">
	<param name="movie" value="http://labs.makemachine.net/wp-content/uploads/2011/08/UICustomizationApp_font_2.swf" />
	<param name="scale" value="noscale" />
	<param name="salign" value="tl" />
	<param name="wmode" value="opaque" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://labs.makemachine.net/wp-content/uploads/2011/08/UICustomizationApp_font_2.swf"
			name="fm_UICustomizationApp_font_2_1678650510"
			width="295"
			height="248">
		<param name="scale" value="noscale" />
		<param name="salign" value="tl" />
		<param name="wmode" value="opaque" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>All you need to do is change the source to the font in the embed state in the <code>makemachine/display/text/fonts/Fonts.as</code> class. </p>
<pre class="code">
[Embed(source="Droid_Sans/DroidSans.ttf", embedAsCFF="false", fontName="default", mimeType="application/x-font")]<br />
public static const DefaultFont:Class;<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://labs.makemachine.net/2011/08/ui-elements-customization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActionScript 3.0 UI Elements</title>
		<link>http://labs.makemachine.net/2011/08/as3-ui-elements/</link>
		<comments>http://labs.makemachine.net/2011/08/as3-ui-elements/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 18:39:19 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Audio]]></category>

		<guid isPermaLink="false">http://labs.makemachine.net/?p=687</guid>
		<description><![CDATA[<a href="http://wp.me/pPFvc-b5"><img src="http://labs.makemachine.net/wp-content/uploads/2011/08/index.png" alt="" title="index" width="620" height="130" class="alignnone size-full wp-image-691" /></a>
I've written and open sourced a lightweight user interface framework for rapid prototyping]]></description>
			<content:encoded><![CDATA[<p>Hello people. Fear not! makemachine lives!</p>
<p>After a short break to work on some client projects, I&#8217;ve re-immersed myself in audio programming with ActionScript. As a part of the re-entry, I&#8217;ve written a lightweight user interface framework for rapid prototyping. In this article I&#8217;ll walk through how the components are built and how to use them in your own code. I&#8217;ll cover the basic usage in this article. Expect future articles that explore the finer details of the framework.</p>
<p>As a preview, below is the &#8220;SpectrumApp&#8221; demo in the samples directory featuring the Spectrum, Slider, Toggle &#038; Button components.</p>
<p><strong>SpectrumApp</strong><br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_SpectrumApp_1656593534"
			class="flashmovie"
			width="423"
			height="145">
	<param name="movie" value="http://labs.makemachine.net/wp-content/uploads/2011/08/SpectrumApp.swf" />
	<param name="wmode" value="opaque" />
	<param name="bgcolor" value="#FFFFFF" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://labs.makemachine.net/wp-content/uploads/2011/08/SpectrumApp.swf"
			name="fm_SpectrumApp_1656593534"
			width="423"
			height="145">
		<param name="wmode" value="opaque" />
		<param name="bgcolor" value="#FFFFFF" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
<em>– press play button ( if other tabs contain flash content the audio visualizer may not work, close them and refresh this page )</em></p>
<p><strong>Source Code &#038; Examples</strong><br />
First of all, take a look at the new repo up on Github located here: <a href="https://github.com/makemachine/makemachine.actionscript">https://github.com/makemachine/makemachine.actionscript</a></p>
<p>The framework that we&#8217;ll be looking at is kept in the <code>makemachine/display/</code> directory. The class <code>InterfaceElement</code> is the base class for all components. It defines some basic functionality that you probably won&#8217;t need to concern yourself with in order to use the components. Though, it is important to note that the <code>InterfaceElement</code> does implement a render cycle to prevent re-drawing elements more than needed.</p>
<p>Next, take a look in the <code>/shapes/</code> directory. This code is used to draw basic shapes such as rectangles, polygons and circles. The shapes are used in virtually all of the user interface components. Shapes can have many of their graphical properties changed such as gradient fill colors, line style, bitmap fill &#038; corner radius ( on rectangles ). Below is the shapes demo from the samples folder.</p>
<p><strong>ShapesApp</strong><br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ShapesApp_695055878"
			class="flashmovie"
			width="620"
			height="208">
	<param name="movie" value="http://labs.makemachine.net/wp-content/uploads/2011/08/ShapesApp.swf" />
	<param name="wmode" value="opaque" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://labs.makemachine.net/wp-content/uploads/2011/08/ShapesApp.swf"
			name="fm_ShapesApp_695055878"
			width="620"
			height="208">
		<param name="wmode" value="opaque" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>You can see in the example above that there are all kinds of shapes, from circles to rounded rectangles and wedges. As it is for all <code>InterfaceElement</code> sub-classes the instantiation syntax is very simple. The following code will create and add a <code>WedgeShape</code> object to the supplied container. Note that the first parameter is the parent object and should be of type <code>DisplayObjectContainer</code>. If it is null, you will need to add the new object manually using <code>addChild()</code>, otherwise the object is added to the first constructor argument.</p>
<pre class="code">
var wedge:WedgeShape = new WedgeShape( container );
</pre>
<p>You can also define the position of the newly created object by specifying an x and y coordinate in the constructor. </p>
<pre class="code">
var wedge:WedgeShape = new WedgeShape( container, 100, 100 );
</pre>
<p>These shapes are used extensively in all of the user interface elements. There is another class that is also used extensively and this is the <code>BitmapText</code> class located in the <code>/display/text/</code> directory. <code>BitmapText</code> wraps a standard Flash <code>TextField </code>and exposes an API for all of it&#8217;s properties. The difference is that the <code>TextField</code> is rendered as a <code>Bitmap</code>. Wrapping the class and rendering it as bitmap allows for better control of when the text is re-drawn. <code>BitmapText</code> can be generated using the Factory class, like so:</p>
<pre class="code">
var text:BitmapText = Factory.singleLineField( container, xpos, ypos,
                                               "stylename", "initial text" );
</pre>
<p>Similarly a multi-line field can be create like so:</p>
<pre class="code">
var text:BitmapText = Factory.singleLineField( container, xpos, ypos, width,
                                               "stylename", "initial text" );
</pre>
<p>Next, let&#8217;s take a look at a few examples using actual components. </p>
<p><strong>HelloButtonApp</strong><br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_HelloButtonApp_1372752976"
			class="flashmovie"
			width="110"
			height="50">
	<param name="movie" value="http://labs.makemachine.net/wp-content/uploads/2011/08/HelloButtonApp.swf" />
	<param name="wmode" value="opaque" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://labs.makemachine.net/wp-content/uploads/2011/08/HelloButtonApp.swf"
			name="fm_HelloButtonApp_1372752976"
			width="110"
			height="50">
		<param name="wmode" value="opaque" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<pre class="code">
public function HelloButtonApp()
{
	var btn:Button = new Button( this, 10, 10 );
	btn.setText( "Hello Button" );
	btn.callback = helloButton;
	btn.data = "Generic data object attached to button";
}

protected function helloButton( btn:Button ):void
{
	trace( btn.data );
}
</pre>
<p>As you can see, this is not very complex. A <code>Button</code> object is created. The parent is defined with the first param and it will be positioned at ( 10, 10 ) according to the second and third params. The text is set using the <code>setText()</code> method. A callback is set to be triggered when the <code>Button</code> is pressed and some generic data is attached to the <code>Button</code>. You may have noticed that there is no call to <code>addChild()</code>. This is not necessary with you supply the parentContainer ( first ) parameter of any <code>InterfaceElement</code> sub-class. When this parameter is supplied the component is automatically added to the display list.</p>
<p><strong>ButtonBarApp</strong><br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ButtonBarApp_1204358733"
			class="flashmovie"
			width="295"
			height="50">
	<param name="movie" value="http://labs.makemachine.net/wp-content/uploads/2011/08/ButtonBarApp.swf" />
	<param name="wmode" value="opaque" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://labs.makemachine.net/wp-content/uploads/2011/08/ButtonBarApp.swf"
			name="fm_ButtonBarApp_1204358733"
			width="295"
			height="50">
		<param name="wmode" value="opaque" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<pre class="code">
public function ButtonBarApp()
{
	var btn:Button;
	var buttons:Vector.&#60;Button&#62; = new Vector.&#60;Button&#62;();
	bar = new ButtonBar( this, 10, 10 );
	var icons:Vector.<Class> = Vector.<Class>( [ Icons.SineWaveIcon,
						     Icons.TriangleWaveIcon,
   						     Icons.SquareWaveIcon,
						     Icons.SawtoothDownIcon,
						     Icons.SawtoothUpIcon,
						     Icons.BatmanIcon,
						     Icons.NoiseIcon ] );

	for( var i:int = 0; i < icons.length; i++ )
	{
		btn = new Button();
		btn.setIcon( new icons[i]() );
		buttons.push( btn );
	}

	bar.setContent( buttons );
        // -- buttons will auto size without setting an explicit size
	bar.setExplicitButtonSize( 30, 30 );
	bar.addEventListener( Event.SELECT, onButtonBarSelect );
}

protected function onButtonBarSelect( event:Event ):void
{
	trace( bar.selectedIndex );
}
</pre>
<p>This one requires a little more code. The <code>ButtonBar</code> component allows multiple buttons to be used as a selection box. Only one item in a button bar can be selected at a time. The generic <code>Button</code> class can have either a text or graphic label. Any graphic can be used with the <code>setIcon()</code> method, however, the above code is setting one of the built in icons as the label. The framework comes with a handful of built-in icons. I'll be adding more icons as time goes by. There is an Adobe Illustrator file included in the repo that contains the actual art for these icons.</p>
<p>One of the key concepts in the framework is the use of <code>Parameter</code> objects. Parameters wrap numerical values, can be given names and assigned a unit of measure. Below is example of how the <code>Parameter</code> object is used:</p>
<p><strong>HelloParametersApp</strong><br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_HelloParametersApp_1568781563"
			class="flashmovie"
			width="160"
			height="170">
	<param name="movie" value="http://labs.makemachine.net/wp-content/uploads/2011/08/HelloParametersApp.swf" />
	<param name="wmode" value="opaque" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://labs.makemachine.net/wp-content/uploads/2011/08/HelloParametersApp.swf"
			name="fm_HelloParametersApp_1568781563"
			width="160"
			height="170">
		<param name="wmode" value="opaque" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<pre class="code">
public function HelloParametersApp()
{
	var slider:Slider = new Slider( this, 10, 10 );

	// -- Notice how when the slider is adjusted the value turns from "Hz" to "kHz"
	var param1:Parameter = new Parameter( "Frequency", 200, 2000, 250 );
	param1.units = "Hz";
	param1.addEventListener( Event.CHANGE, onParamUpdate );
	slider.parameter = param1;
	slider.validate();

	var knob1:Knob = new Knob( this, slider.x, slider.y + slider.height + 5 );
	knob1.parameter = param1;
	knob1.validate();

	var knob2:Knob = new Knob( this, knob1.x + knob1.width + 1, knob1.y );
	var param2:Parameter = new Parameter( "Amplitude", 0.0, 1.0, .5 );
	knob2.parameter = param2;
	knob2.validate();
}

protected function onParamUpdate( event:Event ):void
{
	if( event.target is Parameter )
	{
		var param:Parameter = event.target as Parameter;
		trace( int( param.value ) );
	}
}
</pre>
<p>When a component such as a <code>Knob</code> or a <code>Slider</code> has it's <code>.parameter</code> property set, it automatically takes on the properties of that <code>Parameter</code>. It's label is changed to display the name of the <code>Parameter</code> and it's value field displays a value between the min and max values of the <code>Parameter</code>. Text for values is trimmed to the nearest two or three decimal places and if the value exceeds 1000 it is truncated and has a lower case "k" added it it.</p>
<p>In the audio library I'm working on, <code>Parameters</code> are used throughout many of the processors and filters. Being able to pass around references to parameters is really nice in that you are not bound to static class variables. The concept is a little abstract but it really speeds up development and has many advantages. I'll be writing more on the use of <code>Parameters</code> in future articles about sound programming.</p>
<p>No user interface framework is complete without some sort of auto-layout classes. There are two container classes, the <code>XBox</code>  and the <code>YBox</code>. These containers display <code>InterfaceElement</code> objects in either horizontal or vertical layouts. </p>
<p><strong>ContainersApp</strong><br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ContainersApp_1180120196"
			class="flashmovie"
			width="150"
			height="190">
	<param name="movie" value="http://labs.makemachine.net/wp-content/uploads/2011/08/ContainersApp.swf" />
	<param name="wmode" value="opaque" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://labs.makemachine.net/wp-content/uploads/2011/08/ContainersApp.swf"
			name="fm_ContainersApp_1180120196"
			width="150"
			height="190">
		<param name="wmode" value="opaque" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<pre class="code">
public function ContainersApp()
{
	var ybox:YBox = new YBox( this, 5, 5 );

	// -- label size is based on constant values in the Factory class
	var label:Label = new Label( ybox );
	label.setText( "Controls" );

	// -- notice how the two knobs fit nicely below the label
	var xbox:XBox = new XBox( ybox, 0, 0 );

	var knob1:Knob = new Knob( xbox );
	var knob2:Knob = new Knob( xbox );

	var slider:Slider = new Slider( ybox );
}
</pre>
<p>The above code is pretty straightforward. It is using a <code>YBox</code> to stack all of the elements vertically and an <code>XBox</code> horizontally stack the two knobs.</p>
<p>Well, this article is getting lengthy, so it shall now end. I'm really looking forward to developing this further as I use it in more sound programming experiments. I'll also be writing more posts soon about how to customize the components and other features as time permits.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.makemachine.net/2011/08/as3-ui-elements/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

