<?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>toxiclibs &#187; General</title>
	<atom:link href="http://toxiclibs.org/category/general/feed/" rel="self" type="application/rss+xml" />
	<link>http://toxiclibs.org</link>
	<description>Building blocks for computational design</description>
	<lastBuildDate>Tue, 20 Dec 2011 17:03:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The road ahead</title>
		<link>http://toxiclibs.org/2011/09/the-road-ahead/</link>
		<comments>http://toxiclibs.org/2011/09/the-road-ahead/#comments</comments>
		<pubDate>Mon, 26 Sep 2011 19:21:19 +0000</pubDate>
		<dc:creator>toxi</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://toxiclibs.org/?p=503</guid>
		<description><![CDATA[I thought it will be very useful to give a better overview of the current development tasks (and challenges) for the near future. The diagram hopefully visualizes this current state quite well and this mega post discusses the most important points in more detail.]]></description>
			<content:encoded><![CDATA[<p>As I&#8217;m using any spare moment to continue working on getting the next release ready for public consumption, I thought it will be very useful to give a better overview of the current development tasks (and challenges) for the near future. The diagram below hopefully visualizes this current state quite well and maybe even encourages one or two brave souls to lend a helping hand as toxiclibs is slowly but steadily breaking out of its initial Java shell and starts integrating more publicly into other languages and application contexts other than Processing.</p>
<div class="wp-caption aligncenter" style="width: 650px"><a href="http://www.flickr.com/photos/toxi/6173214240/sizes/o/" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/6173214240/sizes/o/?referer=');"><img class=" " title="toxiclibs roadmap Q4/2011 - Q2/2012" src="http://farm7.static.flickr.com/6175/6173214240_80a07fb1f5_z.jpg" alt="roadmap diagram" width="640" height="358" /></a><p class="wp-caption-text">toxiclibs roadmap Q4/2011 - Q2/2012 (click to enlarge)</p></div>
<h2>A bit of philosophy</h2>
<p>From the very outset, the creation of design oriented, composable and reusable data structures and algorithms for manipulating them has been the main aim of this project and also one of the most obvious counter approaches to the way people traditionally work with Processing (hitherto the most used environment for the libs). Even though the majority of classes provided by toxiclibs can have a visual representation, there&#8217;s a strict exclusion of any rendering related code in the core packages of the library, since these often carry a vast amount of secondary dependencies, eventually binding the library to a large, rigid environment. Me not likey. Almost all toxiclibs classes are &#8220;pure&#8221; models which can be queried, transformed, combined and otherwise manipulated as abstract entities. They&#8217;re usable as a tool for solving (design) problems, not only for drawing. They are the M in <a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Model_E2_80_93view_E2_80_93controller?referer=');">MVC</a>. If one of them ever needs to be drawn/rendered, a 3rd party component is required (the V in MVC, e.g. Processing or straight OpenGL), but toxiclibs does not prescribe how this drawing should be done (but it provides optional tools to support that task). This separation of concerns really has been the #1 feature aimed at making it as easy as possible (and encouraging) to enter this next stage of the project: systematically porting to other languages.</p>
<h2>Polyglot toxiclibs</h2>
<p><strong>JavaScript</strong></p>
<p>In the past, myself and other people have done half-baked attempts to port selected classes to other languages (ActionScript, JavaScript, C++). However, all of them were just isolated fragments needed for specific projects and never approached general library status even closely. As most people are surely aware of by now, since the beginning of the year Mr. <a href="http://haptic-data.com/" onclick="pageTracker._trackPageview('/outgoing/haptic-data.com/?referer=');">Kyle Philips</a> has been doing a stellar effort systematically <a href="http://haptic-data.com/toxiclibsjs/" onclick="pageTracker._trackPageview('/outgoing/haptic-data.com/toxiclibsjs/?referer=');">porting large parts of the toxiclibs core and physics classes to JavaScript</a> and due to the popularity of that language this port is gaining huge traction. That&#8217;s exactly what I&#8217;ve been hoping for to happen as an eventual consequence of the above design points, so I&#8217;m super happy to see this effect kicking in. JavaScript however does not only mean in-browser usage, even though in combination with WebGL and libraries like <a href="https://github.com/mrdoob/three.js/" onclick="pageTracker._trackPageview('/outgoing/github.com/mrdoob/three.js/?referer=');">three.js</a> &amp; <a href="http://processingjs.org/" onclick="pageTracker._trackPageview('/outgoing/processingjs.org/?referer=');">Processing.js</a> the number of potential use cases is huge (I&#8217;d say even more so than in the traditional Processing tied context). JavaScript&#8217;s reach is massive and it also has deservedly gained traction outside the browser as general purpose language (largely thanks to <a href="http://code.google.com/p/v8/" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/v8/?referer=');">V8</a> based platforms, like <a href="http://nodejs.org/" onclick="pageTracker._trackPageview('/outgoing/nodejs.org/?referer=');">Node.js</a>, but also <a href="http://www.deanmcnamee.com/" onclick="pageTracker._trackPageview('/outgoing/www.deanmcnamee.com/?referer=');">Dean McNamee</a>&#8216;s <a href="http://plask.org" onclick="pageTracker._trackPageview('/outgoing/plask.org?referer=');">Plask</a> as a more related example). I think toxiclibs can contribute and actively support new developments on these platforms.</p>
<p>In terms of similarity and porting, JavaScript is one of the closest things to Java there is, but it also has unique deployment issues and there&#8217;s some substantial organizational effort needed to create a better system for splitting the codebase into modules and integrating the JS port with existing coding standards (<a href="http://commonjs.org/" onclick="pageTracker._trackPageview('/outgoing/commonjs.org/?referer=');">CommonJS</a>) and module managers/loaders (e.g. <a href="http://npmjs.org/" onclick="pageTracker._trackPageview('/outgoing/npmjs.org/?referer=');">NPM</a>, <a href="http://requirejs.org/" onclick="pageTracker._trackPageview('/outgoing/requirejs.org/?referer=');">RequireJS</a>), incl. to start thinking about adopting <a href="http://code.google.com/closure/" onclick="pageTracker._trackPageview('/outgoing/code.google.com/closure/?referer=');">Google Closure</a> conventions to harness the optimizations achievable by that compiler (e.g. <a href="http://en.wikipedia.org/wiki/Dead_code_elimination" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Dead_code_elimination?referer=');">dead code removal</a>, a huge benefit for large libraries as this).</p>
<p>Good API design requires a clean, consistent ethos, a worldview and opinion which not only is carried through and made visible throughout a project, but also leads users of that API to write their own software in a certain/similar manner. To achieve that goal is often a long, winding road and takes much longer to get right than writing actual code, but I think by now, toxiclibs does provide a decent set of consistently used patterns (excluding a few edge cases). Having such a familiar set of classes &amp; APIs available in multiple languages is a serious benefit for users and makes it much easier to experiment &amp; switch between environments, and that without forcing users to stay in a sandbox of sorts (e.g. as ProcessingJS does). I think, having a familiar API too needs to be complimented &amp; balanced with the unique features, idioms and development practices of the host language to allow both code &amp; coder live up to their full potential. For JS these differences are still relatively harmless, but even there we should embrace them more.</p>
<p><strong>Clojure</strong></p>
<p>Ever since college, I had an ongoing, if usually fleeting, fascination with <a href="http://en.wikipedia.org/wiki/Lisp_(programming_language)" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Lisp_programming_language?referer=');">Lisp</a> and its seemingly alien, stripped down approach to syntax, its obsession with brackets and generally doing things &#8220;the way round&#8221;, at least compared to common (imperative) languages. I never considered Lisp as a serious contender for my own development arsenal until earlier this summer, when I stumbled across <a href="http://clojure.org/" onclick="pageTracker._trackPageview('/outgoing/clojure.org/?referer=');">Clojure</a>, a modern dialect of Lisp running on the JVM (get a detailed feature overview on their website, it&#8217;s worth reading). This time I immediately was struck by its elegance, the resulting concise code and the many other features this language brings to the table, especially for working with collections, data processing &amp; concurrency. Many data munging tasks can be solved in approx. 30-50% code than in Java/Processing, very useful for dataviz. So I made an effort to get into it more seriously. Then I read <a href="http://www.defmacro.org/ramblings/lisp.html" onclick="pageTracker._trackPageview('/outgoing/www.defmacro.org/ramblings/lisp.html?referer=');">this article</a> and when I hit this quote, I felt in very similar shoes:</p>
<blockquote><p>&#8220;Many extremely intelligent people I knew and had much respect for were praising Lisp with almost religious dedication. There had to be something there, something I couldn&#8217;t afford not to get my hands on! Eventually my thirst for knowledge won me over. I took the plunge, bit the bullet, got my hands dirty, and began months of mind bending exercises. It was a journey on an endless lake of frustration. I turned my mind inside out, rinsed it, and put it back in place. I went through seven rings of hell and came back. And then I got it.</p>
<p>The enlightenment came instantaneously. One moment I understood nothing, and the next moment everything clicked into place. I&#8217;ve achieved nirvana.&#8221;</p></blockquote>
<p>Similar to <a href="http://www.scala-lang.org/" onclick="pageTracker._trackPageview('/outgoing/www.scala-lang.org/?referer=');">Scala</a>, Clojure compiles directly into JVM byte code and therefore provides comparable speed and can easily interoperate with the vast amount of Java libraries available. Unlike Java, Clojure is focused on immutable data and provides a functional approach to computing, an antidote to living a <a href="http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html" onclick="pageTracker._trackPageview('/outgoing/steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html?referer=');">kingdom of nouns</a>. Common to all Lisps also is the <a href="http://en.wikipedia.org/wiki/Read-eval-print_loop" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Read-eval-print_loop?referer=');">REPL</a>, offering livecoding features as part of the core development process. Lisp/Clojure code is data is code. I don&#8217;t need to point out, how exciting this is for people in our field. Besides that though, my main excitement is about the forward thinking take on concurrency/multicore support (agents/futures/atoms/refs) and the ability to easily create domain specific languages. Community activity around the language seems to be glowing hot and is sporting an impressive ecosystem of libraries and amazing support tools, making open source development true fun. Some noteworthy introductory links, should you feel inclined to give it a spin too:</p>
<ul>
<li><a href="http://java.ociweb.com/mark/clojure/article.html" onclick="pageTracker._trackPageview('/outgoing/java.ociweb.com/mark/clojure/article.html?referer=');">Clojure &#8211; Functional programming for the JVM</a></li>
<li><a href="http://joyofclojure.com/" onclick="pageTracker._trackPageview('/outgoing/joyofclojure.com/?referer=');">The Joy of Clojure</a></li>
<li><a href="http://www.lisperati.com/clojure-spels/casting.html" onclick="pageTracker._trackPageview('/outgoing/www.lisperati.com/clojure-spels/casting.html?referer=');">Casting Spels in Clojure</a></li>
<li><a href="http://learn-clojure.com/" onclick="pageTracker._trackPageview('/outgoing/learn-clojure.com/?referer=');">learn-clojure.com</a></li>
<li><a href="http://4clojure.com/" onclick="pageTracker._trackPageview('/outgoing/4clojure.com/?referer=');">4clojure</a></li>
</ul>
<p><strong>ClojureScript</strong></p>
<p><a href="https://github.com/clojure/clojurescript" onclick="pageTracker._trackPageview('/outgoing/github.com/clojure/clojurescript?referer=');">ClojureScript</a> is a recent addition to the Clojure ecosystem and potentially something to keep watching closely for the purposes of porting: Clojure compiled into JavaScript. I know it sounds like herasy, but in some respects it seems ClojureScript does &#8220;better&#8221; JavaScript than the original, providing all the intelligent language features of Clojure (e.g. namespaces, <a href="http://clojure.org/special_forms#Special Forms--(let [bindings* ] exprs*)" onclick="pageTracker._trackPageview('/outgoing/clojure.org/special_forms_Special_Forms--_let_bindings_exprs?referer=');">destructuring</a>, <a href="http://java.ociweb.com/mark/clojure/article.html#DefiningFunctions" onclick="pageTracker._trackPageview('/outgoing/java.ociweb.com/mark/clojure/article.html_DefiningFunctions?referer=');">function overloading</a>, <a href="http://clojure.org/atoms" onclick="pageTracker._trackPageview('/outgoing/clojure.org/atoms?referer=');">atoms</a>, <a href="http://java.ociweb.com/mark/clojure/article.html#Macros" onclick="pageTracker._trackPageview('/outgoing/java.ociweb.com/mark/clojure/article.html_Macros?referer=');">macros</a>) and generating JavaScript in a format targeted to <a href="http://code.google.com/closure/compiler/docs/gettingstarted_ui.html" onclick="pageTracker._trackPageview('/outgoing/code.google.com/closure/compiler/docs/gettingstarted_ui.html?referer=');">Google&#8217;s Closure compiler</a>, allowing for vastly better optimizations of large applications than handwritten JavaScript (which can only fully utilize the compiler if you stick to the necessary conventions in ALL your code). I&#8217;m in no position yet to actually back any of that with my own experience so far, but it&#8217;s an exciting development for sure. Here&#8217;s also a video of the launch event of ClojureScript at Google: <a href="http://blip.tv/clojure/rich-hickey-unveils-clojurescript-5399498" onclick="pageTracker._trackPageview('/outgoing/blip.tv/clojure/rich-hickey-unveils-clojurescript-5399498?referer=');">Rich Hickey (creator of Clojure) unveils ClojureScript</a> and the <a href="http://clojure.com/blog/2011/07/22/introducing-clojurescript.html" onclick="pageTracker._trackPageview('/outgoing/clojure.com/blog/2011/07/22/introducing-clojurescript.html?referer=');">official announcement with more links</a>.</p>
<h2>Keeping in sync &amp; documentation</h2>
<p>The next major set of tasks related to porting is figuring out ways to keep the different ports in sync or at least better document which parts of the library are available in which port. For that purpose, I started prototyping a new web app (<a href="http://webnoir.org" onclick="pageTracker._trackPageview('/outgoing/webnoir.org?referer=');">WebNoir</a> + <a href="http://couchbase.org/" onclick="pageTracker._trackPageview('/outgoing/couchbase.org/?referer=');">CouchDB</a>) which will collect metadata from the different source codes and automatically produce a port coverage/sync report. Kyle started manually producing a top-level version of this for his JS port, but its <a href="https://github.com/hapticdata/toxiclibsjs/blob/master/README.md" onclick="pageTracker._trackPageview('/outgoing/github.com/hapticdata/toxiclibsjs/blob/master/README.md?referer=');">granularity is only at class level</a>, whereas we really do need that information per function/method to be truly useful. This is also because there are still some areas of the original Java version, which will receive further updates and bug fixes and at current there&#8217;s no system to mark those places in the code as needing to be reflected in the other ports. Serious development of this tool is top priority after v0021 is out.</p>
<p>Related to that also is documentation, the historically slowest evolving aspect of the whole project. One of the comments I hear most often is <em>&#8220;Javadocs suck&#8221;</em>. They suck even more so, since for many library classes they&#8217;re not even existing or if so only superficially. So in a way I couldn&#8217;t agree more, but then again, for the past four years these libraries have largely evolved around my own needs and client projects and I&#8217;ve relied on users to consult the <a href="http://hg.postspectacular.com/toxiclibs/src/tip/examples/" onclick="pageTracker._trackPageview('/outgoing/hg.postspectacular.com/toxiclibs/src/tip/examples/?referer=');">95+ examples bundled with each release</a> (or attend my workshops) in order to learn the basic usage patterns. Whilst I still believe the latter (learning by example) is by far the most efficient way of learning (having done so my entire career), I also think things can be vastly improved by offering documentation in several formats, all cross-referenced between: actual running examples with source code, a literate programming style doc system (e.g. <a href="http://jashkenas.github.com/docco/" onclick="pageTracker._trackPageview('/outgoing/jashkenas.github.com/docco/?referer=');">Docco</a>/<a href="http://fogus.me/fun/marginalia/" onclick="pageTracker._trackPageview('/outgoing/fogus.me/fun/marginalia/?referer=');">Marginalia</a> based, very good for workshops) and the traditional javadoc style, for integrating the docs in an IDE setup.</p>
<div id="attachment_515" class="wp-caption aligncenter" style="width: 690px"><img class="size-full wp-image-515 " title="marginalia_toxicore" src="http://toxiclibs.org/wp-content/uploads/2011/09/marginalia_toxicore.png" alt="" width="680" height="740" /><p class="wp-caption-text">Example output of running an early(ier) Clojure porting effort through Marginalia to produce nice, easy to read documentation next to source code.</p></div>
<p>IMHO the reason Javadocs are soooo unsuccessful amongst Processing users is actually largely down to the lack of Javadoc support in the Processing PDE. If people would use IDEs like <a href="http://eclipse.org/" onclick="pageTracker._trackPageview('/outgoing/eclipse.org/?referer=');">Eclipse</a> showing Javadocs in-situ within the editor context by simply hovering over class names, I believe people would see them for what they really are: kind of awesome!</p>
<div id="attachment_533" class="wp-caption aligncenter" style="width: 690px"><img class="size-full wp-image-533" title="javadocs_eclipse" src="http://toxiclibs.org/wp-content/uploads/2011/09/javadocs_eclipse1.png" alt="" width="680" height="200" /><p class="wp-caption-text">Eclipse screenshot with Javadocs in editor context.</p></div>
<p>So in conjunction with the task of <em>adding metadata to every method of every public class</em> in the codebase, all methods will also be receiving full documentation. These docs will then also link to existing examples using the particular method. This will be the second main focal point of the v0022 release (the one after next).</p>
<h2>Versioning &amp; repositories</h2>
<p>Speaking of version numbers: Again, due to the organic and isolated growth of this project and my own past development practice, the linear versioning scheme was quite sufficient for now. As we all learn new things and our development tactics change, so too will the versioning for this project have to change to something more meaningful. Enter <a href="http://semver.org/" onclick="pageTracker._trackPageview('/outgoing/semver.org/?referer=');">semantic versioning</a>. The idea is nothing new and I&#8217;ve been using it for most other projects in the past, but I think this time the reasoning behind it is somewhat different:</p>
<ol>
<li>Currently there&#8217;s toxiclibs support for 2.1 languages (the Clojure port is not quite there yet to fully count)</li>
<li>Development outside the Processing IDE is far more dependent on build management tools, open source repositories and module managers (e.g. <a href="http://maven.apache.org/" onclick="pageTracker._trackPageview('/outgoing/maven.apache.org/?referer=');">Maven</a>, <a href="http://npmjs.org/" onclick="pageTracker._trackPageview('/outgoing/npmjs.org/?referer=');">NPM</a>, <a href="https://github.com/technomancy/leiningen" onclick="pageTracker._trackPageview('/outgoing/github.com/technomancy/leiningen?referer=');">Leiningen</a>)</li>
<li>Different projects are created at different times and might require different versions of the libraries and</li>
<li>I&#8217;d really love to get to a point where there&#8217;ll be synchronised releases in order to reduce build &amp; documentation complexity and avoid confusion for users so that they can assume v1.0.0 of a module will contain the same features in all (sup)ported languages.</li>
</ol>
<p>Semantic versioning is the lowest common denominator between all current module managers/repositories and hence will be introduced with the next release. As a result, users will have a much easier way to integrate the libraries into their own (non-Processing) projects, since they will also be available via the major existing open source repositories for the various languages (<a href="https://repository.sonatype.org/" onclick="pageTracker._trackPageview('/outgoing/repository.sonatype.org/?referer=');">Sonatype</a> [Java/Maven], <a href="http://npmjs.org/doc/registry.html" onclick="pageTracker._trackPageview('/outgoing/npmjs.org/doc/registry.html?referer=');">NPM registry</a> (JS), <a href="http://clojars.org" onclick="pageTracker._trackPageview('/outgoing/clojars.org?referer=');">Clojars</a> [Clojure/Leiningen]). Apparently, Processing 2.0 will feature its own centralized library management system, but from what I gather it will not offer any integration with any of these existing open source repositories.</p>
<h2>New website &amp; tutorials</h2>
<p>The current WordPress based setup is not the best platform for integrating all the planned new documentation, tutorials and other features like the bundled example &amp; user galleries. I&#8217;ve been test driving <a href="http://atlassian.com/software/confluence/" onclick="pageTracker._trackPageview('/outgoing/atlassian.com/software/confluence/?referer=');">Confluence</a> on a private dev server and found this more promising (at least for the documentation &amp; tutorial side), so I might adopt this in the near future. The other (more appealing) alternative is to extend the new CouchDB based sync/doc tool into a more generic web app and add wiki &amp; blogging features. The main issue for that will be increased hosting costs, which I will need to think about more how they can be better balanced. The new website will also host as many of the bundled examples as possible, effectively deprecating the current gallery on <a href="http://openprocessing.org/portal/userID=4530" onclick="pageTracker._trackPageview('/outgoing/openprocessing.org/portal/userID=4530?referer=');">openprocessing.org</a>, which is impossible to batch update and therefore can&#8217;t reflect any API changes in older examples (which causes unnecessary comments). To better integrate community contributions, that new system will also be used to provide a user gallery.</p>
<p><strong>Furthermore, if you&#8217;re like the amazing <a href="http://amnonp5.wordpress.com/" onclick="pageTracker._trackPageview('/outgoing/amnonp5.wordpress.com/?referer=');">Amnon Owed</a>, and feel like creating super useful tutorials for the libraries, please start doing so. Any help on increasing the number of learning resources would be an amazing contribution to this project and will play a major role on the new site.</strong> Speaking of tutorials, I really do think there also is a <strong>big need</strong> for a general knowledge tutorial about how to make the most of open source libraries like this from a user perspective and encourage people to contribute (even if in the most indirect ways). Much of the feedback and comments I receive, hints at a large knowledge gap about how to even go about finding out (in a self guided manner) about existing resources, updates, work with the source code, work with issue trackers etc. This generally seems to be a far bigger problem with users in the Processing camp than I&#8217;m aware of from other environments. Food for thought!</p>
<h2>Summary &amp; next steps</h2>
<p>Well, this is the closest thing to a sharable master plan as I could get to for now. Before most of these things will/can be addressed, other minor tasks need to be completed to get 0021 out of the door first. A brief, non-exhaustive overview of new features is here:</p>
<ul>
<li>Initial support for NURBS curves and surfaces is the biggest new addition and still requires some more testing and internal restructuring. Supported operations are:
<ul>
<li>Curve builders for circles, arcs and creating curves from a list of points, joining curves</li>
<li>Surface builders: extrude curve, revolve curve, construct surface from a grid of points/control mesh</li>
<li>Convert surface into TriangleMesh instance (variable resolution &amp; UV coordinate generation)</li>
</ul>
</li>
<li>Several important additions to the Polygon2D class:
<ul>
<li>construct regular polygons from a given base line segment (useful for creating tesselations)</li>
<li>rotate/scale/translate polygons</li>
<li>pick random points within a polygon (useful for color sampling)</li>
<li>retrieving edge list</li>
</ul>
</li>
<li>Tesselate polygons using Delaunay triangulation with flexible grid resolutions</li>
<li>Addition of ConvexPolygonClipper to clip a polygon to the shape of another</li>
<li>New BezierCurve2D/3D classes in addition to existing Spline2D/3D</li>
<li>Implementing Visitor pattern for PointQuadtree/PointOctree</li>
<li>Adding UV coordinate generation to SurfaceMeshBuilder</li>
<li>Adding PLYWriter for exporting 3D meshes in Standard Polygon format</li>
<li>ToxiclibsSupport line drawing now supports decorators for dashed lines and arrow heads (customizable)</li>
<li>Custom DXFWriter for 2D shapes with DXF layer support</li>
<li>Improving precision/reducing rounding errors for VolumetricBrush</li>
<li>Adding FluidSolver3D</li>
</ul>
<p>There&#8217;re also a ton of other smaller additions and bug fixes plus approx. 10-15 new examples. Let me also point you again to the repository of workshop projects at <a href="http://learn.postspectacular.com/hg/" onclick="pageTracker._trackPageview('/outgoing/learn.postspectacular.com/hg/?referer=');">learn.postspectacular.com</a>, which contains also several larger projects than the examples bundled with the release.</p>
<h2>Showreel</h2>
<p>A few people have been asking about sending in stuff for this year&#8217;s showreel. Of course, I do intend to produce one again (it&#8217;s one of the highlights of the year), though I can only realistically get to this in Nov/Dec, hopefully making it a nice video for the Holiday season. I will send out a proper call for submissions in the next month, but if you have stuff ready, please send it along already. Specs will be the same as previously: Video assets 1280&#215;720 (if possible), still images are fine too and of course please add some brief description &amp; credits.</p>
<p>Any feedback, suggestions &amp; help offers are highly appreciated! So long&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://toxiclibs.org/2011/09/the-road-ahead/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>toxiclibs-0020</title>
		<link>http://toxiclibs.org/2011/01/toxiclibs-0020/</link>
		<comments>http://toxiclibs.org/2011/01/toxiclibs-0020/#comments</comments>
		<pubDate>Mon, 03 Jan 2011 14:50:00 +0000</pubDate>
		<dc:creator>toxi</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Release notes]]></category>

		<guid isPermaLink="false">http://toxiclibs.org/?p=454</guid>
		<description><![CDATA[Six months in the making and at least three months delayed, the anniversary 0020 release of toxiclibs was finally released today. A little Happy-New-Year present for you &#38; me. Before getting into the details of the countless things which have been changed &#38; added with this release, please first go forth and download the bundle [...]]]></description>
			<content:encoded><![CDATA[<p>Six months in the making and at least three months delayed, the anniversary 0020 release of toxiclibs was finally released today. A little Happy-New-Year present for you &amp; me. Before getting into the details of the countless things which have been changed &amp; added with this release, please first go forth and <a href="http://hg.postspectacular.com/toxiclibs/downloads/" onclick="pageTracker._trackPageview('/outgoing/hg.postspectacular.com/toxiclibs/downloads/?referer=');">download the bundle</a> of ALL library modules from here: <a href="http://hg.postspectacular.com/toxiclibs/downloads/toxiclibs-complete-0020.zip" onclick="pageTracker._trackPageview('/outgoing/hg.postspectacular.com/toxiclibs/downloads/toxiclibs-complete-0020.zip?referer=');">toxiclibs-0020</a></p>
<p style="text-align: center;"><a href="http://openprocessing.org/portal/?userID=4530" onclick="pageTracker._trackPageview('/outgoing/openprocessing.org/portal/?userID=4530&amp;referer=');"><img class="size-full wp-image-463 aligncenter" title="demos" src="http://toxiclibs.org/wp-content/uploads/2011/01/demos.png" alt="" width="500" height="400" /></a></p>
<p>In the past few days I&#8217;ve uploaded 20 new demos (many of them using new functionality) to <a href="http://openprocessing.org/portal/?userID=4530" onclick="pageTracker._trackPageview('/outgoing/openprocessing.org/portal/?userID=4530&amp;referer=');">OpenProcessing</a>. The release contains now 95 demos(!) in total, incl. several complete exercises of workshops I&#8217;ve taught throughout the past years. So let&#8217;s please also say thank you to the universities &amp; institutions which made these possible!</p>
<p>Here&#8217;s also a quick list of some key additions &amp; updates (some were already quietly introduced with the 0019 release in summer, but never documented). A complete &amp; detailed changelog is bundled with each library module.</p>
<ul>
<li>3D mesh construction &amp; processing:
<ul>
<li>New Winged-Edge mesh class for structured 3D data &amp; enabling complex mesh operations/navigation</li>
<li>Adding mesh subdivision strategies, vertex selectors &amp; mesh filter classes (e.g. for modeling, smoothing)</li>
<li>New BezierPatch class for constructing 3D surfaces from 4&#215;4 control points</li>
<li>Added .toMesh() methods for all 3D geometry primitives: AABB, Cone, Cylinder, Sphere, Plane, Terrain, BezierPatch</li>
</ul>
</li>
<li>Revamped architecture of all voxel based modeling classes:
<ul>
<li>VolumetricSpace is now an abstract class with array or HashMap based implementations</li>
<li>IsoSurface is now an interface with array or HashMap based implementations</li>
<li>HashMap implementations able to produce much higher resolution meshes</li>
</ul>
</li>
<li>Major refactoring of core geometry classes:
<ul>
<li>Introduction of immutable vectors (ReadonlyVec2D/3D)</li>
<li>Introduction of Shape2D/3D interfaces for more polymorphic client code</li>
<li>Support for barycentric coordinates in Triangle2D/3D</li>
<li>Added Sutherland-Hodgeman polygon clipping algorithm (useful for laser cutting tasks)</li>
</ul>
</li>
<li>Behavioral physics:
<ul>
<li>Massive refactoring of internal force handling &amp; introduction of ParticleBehaviour implementations</li>
<li>Added Attraction and ConstantForce (Gravity) behaviours</li>
<li>Behaviours can be dynamically added globally (for entire sim) or to individual particles</li>
</ul>
</li>
<li>More maths:
<ul>
<li>Added bezier, exponential, threshold and decimated interpolation classes</li>
<li>SinCosLUT not a static class anymore, but can be instantiated with different precisions</li>
</ul>
</li>
<li>More utils:
<ul>
<li>Added FileSequenceDescriptor class for working with file sequences</li>
<li>Added FileUtils for file chooser dialogs, stream wrappers etc.</li>
<li>Added DateUtils for creating timestamps (with optional timezone support)</li>
<li>Added generic pluggable EventDispatcher helper to easily implement Observer pattern in client code</li>
</ul>
</li>
<li>Image based color palettes using new Histogram class in toxi.color package</li>
<li>More simulations:
<ul>
<li>Added 2D heightfield erosion strategies: TalusAngleErosion, ThermalErosion (still lacking good demos)</li>
<li>Integrated optimized Jos Stam 2D fluid solver (from old 2006 demo, also still lacking bundled demo)</li>
</ul>
</li>
</ul>
<p>A lot of these above additions are in dire need for more documentation &amp; tutorials. I will do my best to rectify this situation ASAP, but do hope the supplied demos do give you a jump start in the meantime. A lot of time went into creating &amp; documenting them.</p>
<p>Likewise, to ensure the ongoing quality of the libraries and examples, please submit a bug report or enhancement request via the issue tracker&#8230;</p>
<p>Finally, another kind request, largely addressed to recent developments in the open source world around creative coding tools like this one: Please give credit where credit is due. If you&#8217;re using these libraries with Processing, please also list them in the tools used in your documentation (this is a separate project). Same goes for porting parts of these libraries to other languages. This social link back is hugely important and essential for this culture to exist and grow in the future.</p>
<p>Thank you &amp; all the best for 2011!!</p>
]]></content:encoded>
			<wfw:commentRss>http://toxiclibs.org/2011/01/toxiclibs-0020/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Upcoming: The Winged-Edge mesh class</title>
		<link>http://toxiclibs.org/2010/08/wingededge-mesh/</link>
		<comments>http://toxiclibs.org/2010/08/wingededge-mesh/#comments</comments>
		<pubDate>Sat, 07 Aug 2010 12:02:56 +0000</pubDate>
		<dc:creator>toxi</dc:creator>
				<category><![CDATA[core]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://toxiclibs.org/?p=406</guid>
		<description><![CDATA[Just earlier this week I finished a project for which I needed to work with quite large 3D meshes (2 million+ triangles). The meshes needed to be stored in such a way that one can efficiently navigate from a given vertex to its various neighbours and so forth (e.g. for use in a steering system)&#8230; [...]]]></description>
			<content:encoded><![CDATA[<p>Just earlier this week I finished a project for which I needed to work with quite large 3D meshes (2 million+ triangles). The meshes needed to be stored in such a way that one can efficiently navigate from a given vertex to its various neighbours and so forth (e.g. for use in a steering system)&#8230; So a <a href="http://en.wikipedia.org/wiki/Breadth-first_search" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Breadth-first_search?referer=');">traversal graph</a> was needed and I&#8217;ve finally implemented the <a href="http://en.wikipedia.org/wiki/Polygon_mesh#Winged-Edge_Meshes" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Polygon_mesh_Winged-Edge_Meshes?referer=');">Winged-Edge structure</a> on top the existing <a href="http://hg.postspectacular.com/toxiclibs/src/tip/src.core/toxi/geom/mesh/TriangleMesh.java" onclick="pageTracker._trackPageview('/outgoing/hg.postspectacular.com/toxiclibs/src/tip/src.core/toxi/geom/mesh/TriangleMesh.java?referer=');">TriangleMesh class in toxiclibs</a>, something I&#8217;ve been meaning to do for a long while.</p>
<p>Having connectivity information for each vertex, edge and face of the mesh allows for a whole wide range of new, exciting applications and my first exploration on this front deals with various subdivision and mesh smoothing strategies and their use as generative modeling tools&#8230; I&#8217;m currently developing an extensible architecture to make this system as flexible as possible and you&#8217;ll be able to create your own custom strategies to decide about the location of new vertices, but without having to deal with any of the actual subdivision complexities itself, like splitting edges &#038; faces. The same interface pattern thinking is also applied to mesh smoothing and currently I&#8217;ve implemented <a href="http://en.wikipedia.org/wiki/Laplacian_smoothing" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Laplacian_smoothing?referer=');">Laplacian smoothing</a> and am working on other options as well&#8230; </p>
<p>All this should be very interesting for all users with a more architectural background, but IMHO has also lots of potential for those creating digital fabrication tools. If you have any interest in this and/or some useful pointers to share, please do get in touch! </p>
<p>Pending further testing, this new mesh structure and support architecture will available in the next release (0020)&#8230;</p>
<p><iframe src="http://player.vimeo.com/video/13950132" width="680" height="382" frameborder="0"></iframe></p>
<p>The mesh in the video and the examples below are using normal shading to help verifying the correctness of the edge/face splitting algorithm. Each vertex is tinted using its normal vector XYZ components interpreted as RGB color intensities.</p>
<p><a href="http://www.flickr.com/photos/toxi/sets/72157624566599422/" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/sets/72157624566599422/?referer=');"><img src="http://toxiclibs.org/wp-content/uploads/2010/08/toxi.test_.SubdivTest013-680x396.png" alt="" title="toxi.test.SubdivTest013" width="680" height="396" class="alignnone size-large wp-image-409" /></a></p>
<p><a href="http://www.flickr.com/photos/toxi/sets/72157624566599422/" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/sets/72157624566599422/?referer=');"><img src="http://toxiclibs.org/wp-content/uploads/2010/08/toxi.test_.SubdivTest014-680x394.png" alt="" title="toxi.test.SubdivTest014" width="680" height="394" class="alignnone size-large wp-image-410" /></a></p>
<p>These following images show a displacement-subdivided cube with (right) &#038; without (left) mesh smoothing applied&#8230;</p>
<p><a href="http://www.flickr.com/photos/toxi/sets/72157624566599422/" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/sets/72157624566599422/?referer=');"><img src="http://toxiclibs.org/wp-content/uploads/2010/08/toxi.test_.SubdivTest015-303x175.png" alt="" title="toxi.test.SubdivTest015" width="303" height="175" class="alignnone size-medium wp-image-411" /></a> <a href="http://www.flickr.com/photos/toxi/sets/72157624566599422/" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/sets/72157624566599422/?referer=');"><img src="http://toxiclibs.org/wp-content/uploads/2010/08/toxi.test_.SubdivTest016-303x175.png" alt="" title="toxi.test.SubdivTest016" width="303" height="175" class="alignnone size-medium wp-image-412" /></a></p>
<p>Some slightly older experiments from the early stages of developing the system. These meshes started out as a simple 8-point cube, subdivided 4-5 levels and then rendered as VBOs with standard gouroud shading&#8230;</p>
<p><a href="http://www.flickr.com/photos/toxi/4821906878/" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/4821906878/?referer=');"><img alt="" src="http://farm5.static.flickr.com/4143/4821906878_6b4897b3c9_b.jpg" title="winged-edge mesh subdivision" class="alignnone" width="680" /></a></p>
<p><a href="http://www.flickr.com/photos/toxi/4821305417" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/4821305417?referer=');"><img alt="" src="http://farm5.static.flickr.com/4098/4821305417_54645e84e3_b.jpg" title="winged-edge mesh" class="alignnone" width="680" /></a></p>
<p><a href="http://www.flickr.com/photos/toxi/4821283185" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/4821283185?referer=');"><img alt="" src="http://farm5.static.flickr.com/4137/4821283185_1b4c3a34be_b.jpg" title="winged-edge mesh" class="alignnone" width="680" /></a></p>
<p><a href="http://www.flickr.com/photos/toxi/4821304053" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/4821304053?referer=');"><img alt="" src="http://farm5.static.flickr.com/4076/4821304053_f977aa3d5f_b.jpg" title="winged-edge mesh" class="alignnone" width="680" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://toxiclibs.org/2010/08/wingededge-mesh/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>simutils-0001: Gray-Scott reaction diffusion</title>
		<link>http://toxiclibs.org/2010/02/simutils-grayscott/</link>
		<comments>http://toxiclibs.org/2010/02/simutils-grayscott/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 08:05:39 +0000</pubDate>
		<dc:creator>toxi</dc:creator>
				<category><![CDATA[colorutils]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[simutils]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Usage]]></category>
		<category><![CDATA[volumeutils]]></category>

		<guid isPermaLink="false">http://toxiclibs.org/?p=217</guid>
		<description><![CDATA[This is part 2 of the discussion of the classes &#38; processes provided by the recently released simutils package. The first part of this series dealt with Diffusion-limited Aggregation (DLA) and this next process too is related to the simulated diffusion of particles. However, whereas the DLA process dealt with individual particles, this next one [...]]]></description>
			<content:encoded><![CDATA[<p>This is part 2 of the discussion of the classes &amp; processes provided by the recently released <a href="http://toxiclibs.org/category/simutils/">simutils</a> package. <a href="http://toxiclibs.org/2010/02/new-package-simutils/">The first part of this series dealt with Diffusion-limited Aggregation</a> (DLA) and this next process too is related to the simulated diffusion of particles. However, whereas the DLA process dealt with individual particles, this next one is only looking at the concentrations of particles of different &#8220;substances&#8221; in a two-dimensional simulation space.</p>
<p>The Gray-Scott reaction diffusion model is a member of a whole variety of <a href="http://en.wikipedia.org/wiki/Reaction-diffusion_system" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Reaction-diffusion_system?referer=');">RD systems</a>, popular largely due to its ability to produce a very varied number of biological looking (and behaving) patterns, both static and constantly changing. Some patterns are reminiscent of cell devision, gastrulation or the formation of spots &amp; stripes on furry animals. As with all RD models, these patterns are the result of an iterative process evaluating each cell of the simulation space based on the concentrations of the two main parameters (for Gray-Scott usually named <strong>f</strong> and <strong>K</strong>) of the reaction equation as well as taking into account the concentrations of these 2 substances in neighboring cells. So conceptually the reaction diffusion system lies somewhere between the isolated DLA process working with individual particles and the entirely rulebased evaluation of a cell&#8217;s neighborhood in traditional cellular automatas, which we will deal with in the next post.</p>
<p>The image below, by <a href="http://mrob.com/pub/comp/xmorphia/" onclick="pageTracker._trackPageview('/outgoing/mrob.com/pub/comp/xmorphia/?referer=');">Robert Munafo</a>, is a fantastically helpful map of possible patterns resulting from various combinations of the <strong>f</strong> and <strong>K</strong> coefficients. Click the image to go to his website and explore the parameters in more detail (there&#8217;re close-ups and videos of all interesting combinations).</p>
<p><a href="http://mrob.com/pub/comp/xmorphia/" onclick="pageTracker._trackPageview('/outgoing/mrob.com/pub/comp/xmorphia/?referer=');"><img class="alignnone size-large wp-image-245" title="gs-parameter-map" src="http://toxiclibs.org/wp-content/uploads/2010/02/gs-parameter-map-680x680.jpg" alt="GS parameter map" width="680" height="680" /></a></p>
<p>As with the other classes of the <a href="http://toxiclibs.org/category/simutils/">simutils</a> package, the GrayScott implementation comes with several small demos to help you get started. The most basic use case (<a href="http://code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/examples/sim/HelloGrayScott/HelloGrayScott.pde" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/examples/sim/HelloGrayScott/HelloGrayScott.pde?referer=');">HelloGrayScott</a>) is just setting up a simulation with default parameters and then allows you to draw in the simulation space with the mouse. Each frame, the reaction is updated, its new state translated into grayscale pixels and then rendered to the screen. The important thing to know here is that there&#8217;re 2 separate results states available, normally called the <strong>u</strong> and <strong>v</strong> buffers.</p>
<pre class="brush:java">
GrayScott gs;

// create a new simulation instance
// the "false" refers to a non-tiled space with walls
// set to true to create tiling patterns
gs=new GrayScott(width,height,false);

// configure the simulation params to:
// f=0.023, K=0.074
// diffusion speed for u buffer = 0.095
// diffusion speed for u buffer = 0.03
gs.setCoefficients(0.023,0.074,0.095,0.03);
</pre>
<p>The main <code>draw()</code> loop then just does this:</p>
<pre class="brush:java">
void draw() {
  if (mousePressed) {
    // set cells around mouse pos to max saturation
    gs.setRect(mouseX, mouseY,20,20);
  }
  loadPixels();
  // update simulation by 10 time steps per frame
  for(int i=0; i&lt;10; i++) gs.update(1);
  // read out the v buffer and translate into grayscale colors
  for(int i=0; i&lt;gs.v.length; i++) {
    float cellValue=gs.v[i];
    // the cell values in v are usually in the range 0.0 .. 0.33
    int col=255-(int)(min(255,cellValue*768));
    // use the col value for red, green and blue and set alpha to full opacity
    pixels[i]=col&lt;&lt;16|col&lt;&lt;8|col|0xff000000;
  }
  updatePixels();
}
</pre>
<p>To avoid this manual pixel pushing and enable us to make some of the subtle changes of densities more obvious, we can also use the handy (and also new) <a href="http://code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/src.color/toxi/color/ToneMap.java" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/src.color/toxi/color/ToneMap.java?referer=');"><code>ToneMap</code></a> class of the <a href="http://toxiclibs.org/category/colorutils/">colorutils</a> package. This allows us to map a number range to different positions (colors) on a multi-color gradient and so potentially better visualize the different densities. The basic usage of this class is shown below:</p>
<pre class="brush:java">
import toxi.color.*;

ToneMap toneMap;

// define a color gradient by adding colors at certain key points
// a gradient is like a 1D array with target colors at certain points
// all inbetween values are automatically interpolated (customizable too)
// this gradient here will contain 256 values
ColorGradient gradient=new ColorGradient();
gradient.addColorAt(0, NamedColor.BLACK);
gradient.addColorAt(128, NamedColor.RED);
gradient.addColorAt(192, NamedColor.YELLOW);
gradient.addColorAt(255, NamedColor.WHITE);

// now create a ToneMap instance using this gradient
// this maps the value range 0.0 .. 0.33 across the entire gradient width
// a 0.0 input value will be black, 0.33 white
toneMap=new ToneMap(0, 0.33, gradient);
</pre>
<p>Now we can refactor our Gray-Scott rendering code into something even simpler:</p>
<pre class="brush:java">
for(int i=0; i&lt;gs.v.length; i++) {
    // take a GS v value and turn it into a packed integer ARGB color value
    pixels[i]=toneMap.getARGBToneFor(gs.v[i]);
}
</pre>
<p>Btw. The <code>ToneMap</code> class is a nice example of the whole reusable &#8220;building block philosophy&#8221; of toxiclibs (and the object oriented approach in general). The class is simply a <a href="http://en.wikipedia.org/wiki/Object_composition" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Object_composition?referer=');">composition</a> of other library classes and under the hood delegates everything to these elements:</p>
<p><img src="http://toxiclibs.org/wp-content/uploads/2010/02/tonemap.png" alt="ToneMap composition" title="ToneMap composition" width="379" height="266" class="aligncenter size-full wp-image-275" /></p>
<p>All other GrayScott demos, as well as all Cellular Automata examples, make use of this ToneMap class, so do have a look at those for more reference&#8230; </p>
<p>Since a homogeneous configuration of the entire sim grid will always just provide one particular character/patterning, the <code>GrayScott</code> class has been designed with extension in mind. The <a href="http://code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/examples/sim/CustomGrayScott/CustomGrayScott.pde" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/examples/sim/CustomGrayScott/CustomGrayScott.pde?referer=');">CustomGrayScott</a> demo shows how to impose a pattern on the actual simulation parameters themselves, so that cells at different positions are evaluated using different parameters:</p>
<pre class="brush:java">
class PatternedGrayScott extends GrayScott {

  // our constructor just passes things on to the parent class
  PatternedGrayScott(int w, int h, boolean tiling) {
    super(w,h,tiling);
  }

  // this function is called for each cell
  // to retrieve its f coefficient
  public float getFCoeffAt(int x, int y) {
    // here we only take the x coordinate
    // and choose one of 2 options (even &#038; odd)
    x/=32;
    return 0==x%2 ? f : f-0.005;
  }

  // this function is called for each cell
  // to retrieve its K coefficient
  public float getKCoeffAt(int x, int y) {
    // here we only use the y coordinate
    // and create a gradient falloff for this param
    return k-y*0.00004;
  }
}
</pre>
<p>Instead of using the default GrayScott class, we only need to change one line in the setup() method to use our extended version instead:</p>
<pre class="brush:java">
GrayScott gs;

void setup() {
	size(200,200);
	gs=new PatternedGrayScott(width,height,false);
	...
}
</pre>
<p>The result of this is shown below&#8230; Easy, huh? :)</p>
<p><img class="alignnone size-full wp-image-193" title="CustomGrayScott001" src="http://toxiclibs.org/wp-content/uploads/2010/02/CustomGrayScott001.png" alt="" width="680" height="362" /></p>
<p>Having this mechanism in place, it can be also used to create more interesting types of masking. For a commission to produce a <a href="http://postspectacular.com/work/printmag/" onclick="pageTracker._trackPageview('/outgoing/postspectacular.com/work/printmag/?referer=');">cover design for Print Magazine</a> in 2008, I generated a type face from simple line &#038; arc segments and used it as mask to manipulate the concentrations of the f &#038; K parameters to achieve two different types of patterning: one for the inside of the letter shapes, the other for the outside&#8230;</p>
<p><iframe src="http://player.vimeo.com/video/1272071" width="680" height="383" frameborder="0"></iframe></p>
<p>The frames of that animation were then stacked up along the Z axis in 3D space and with the help of the <a href="http://toxiclibs.org/category/volumeutils/">volumeutils</a> classes turned into 3D mesh, <a href="http://code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/src.core/toxi/geom/util/STLWriter.java" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/src.core/toxi/geom/util/STLWriter.java?referer=');">exported as STL format</a> (also see <a href="http://toxiclibs.org/docs/core/toxi/geom/util/TriangleMesh.html#saveAsSTL%28java.lang.String%29">TriangleMesh.saveAsSTL()</a>) and finally fabricated into the physical, 3D printed sculpture shown below. In a way, the sculpture can be seen as a map of its entire creation process&#8230;</p>
<p><img class="size-full wp-image-237" title="typeform_square_680" src="http://toxiclibs.org/wp-content/uploads/2010/02/typeform_square_680.jpg" alt="Type &amp; Form sculpture" width="680" height="680" /></p>
<p>Here&#8217;re some more rendered detail shots of the sculpture. <a href="http://postspectacular.com/work/printmag/" onclick="pageTracker._trackPageview('/outgoing/postspectacular.com/work/printmag/?referer=');">More information about this project is here</a> and the <a href="http://www.flickr.com/photos/toxi/sets/72157604724789091/" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/sets/72157604724789091/?referer=');">related flickr set</a>.</p>
<p><img class="aligncenter size-full wp-image-265" title="typeform_detail1" src="http://toxiclibs.org/wp-content/uploads/2010/02/typeform_detail1.jpg" alt="" width="680" height="382" /></p>
<p><img src="http://toxiclibs.org/wp-content/uploads/2010/02/typeform_detail2.jpg" alt="" title="typeform_detail2" width="680" height="382" class="aligncenter size-full wp-image-266" /></p>
<p>Finally, the <a href="http://code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/examples/sim/GrayScottImage/GrayScottImage.pde" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/examples/sim/GrayScottImage/GrayScottImage.pde?referer=');"><code>GrayScottImage</code></a> demo shows another supported technique of using the library: the seeding of the simulation using a bitmap image.</p>
<p><img class="alignnone size-full wp-image-194" title="GrayScottImage002" src="http://toxiclibs.org/wp-content/uploads/2010/02/GrayScottImage002.png" alt="" width="680" height="362" /></p>
]]></content:encoded>
			<wfw:commentRss>http://toxiclibs.org/2010/02/simutils-grayscott/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Re-inventing the wheel</title>
		<link>http://toxiclibs.org/2010/01/re-inventing-the-wheel/</link>
		<comments>http://toxiclibs.org/2010/01/re-inventing-the-wheel/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 02:44:50 +0000</pubDate>
		<dc:creator>toxi</dc:creator>
				<category><![CDATA[core]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Usage]]></category>
		<category><![CDATA[generative]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[searchspace]]></category>
		<category><![CDATA[spline]]></category>
		<category><![CDATA[symmetry]]></category>
		<category><![CDATA[variation]]></category>

		<guid isPermaLink="false">http://toxiclibs.org/?p=141</guid>
		<description><![CDATA[Firstly, massive thanks are in order for such a storming positive reception of this new site &#8211; I really hope this will become a good resource for everyone interested in the fields these libs are addressing and I will try to update everyone (and everything) as often as I can. In the near future that [...]]]></description>
			<content:encoded><![CDATA[<p>Firstly, massive thanks are in order for such a storming positive reception of this new site &#8211; I really hope this will become a good resource for everyone interested in the fields these libs are addressing and I will try to update everyone (and everything) as often as I can. In the near future that will include a bit of future gazing, but today I&#8217;ve been re-inventing the wheel, literally&#8230;</p>
<p><a href="http://www.flickr.com/photos/toxi/4280317234/" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/4280317234/?referer=');"><img class="alignnone size-full wp-image-147" title="wheel12" src="http://toxiclibs.org/wp-content/uploads/2010/01/wheel12.jpg" alt="wheel 12 spokes" width="680" height="525" /></a></p>
<p>I&#8217;ve been working on some designs for custom made wheels for a potential installation project. The aim is to lasercut some light-weight &amp; good looking acrylic wheels and so I&#8217;ve been literally searching for a few candidate solutions, which allow me to cut out large pieces of material from inside the wheel to keep the weight down whilst still being sturdy enough (thankfully the load on them will be minimal so I can skip the structural analysis).</p>
<p>Not wanting to do this exploration/hike manually, I opted for the Processing PDF output route and have written this little tool below to show me my options (at least some of them) and also tweak them easily.</p>
<p>Apart from Processing, the tool also makes use of these 3 classes from the <a href="http://toxiclibs.org/docs/core/">toxiclibscore</a> package:</p>
<h2>Vec2D</h2>
<p>This class, alongside its sibling Vec3D, is likely one of the most used classes of the entire library. Since 1.0 Processing has its own vector class too now, but Vec2D/3D are far more feature complete, implement a <a href="http://en.wikipedia.org/wiki/Fluent_interface" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Fluent_interface?referer=');">fluent interface</a> for more legible code when dealing with complex vector maths and <em>can</em> be faster too (especially for 2D, but also by helping you to avoid temporary object creation). Furthermore Vec2D also has support for polar coordinates (Vec3D has spherical as equivalent) which was very helpful for building the tool below:</p>
<p>Normally, you&#8217;d specify a Cartesian point with:</p>
<pre class="brush:java">Vec2D v = new Vec2D(x, y);</pre>
<p>However, if we want to interpret our vector as polar coordinates, we&#8217;re using the x component to specify the radius and the y component as rotation angle. To convert the vector back into Cartesian space (e.g. our screen) we can use the <code>.toCartesian()</code> method&#8230;</p>
<pre class="brush:java">Vec2D v = new Vec2D(radius, theta).toCartesian();</pre>
<p>In a similar manner, you can also transform a Cartesian point into polar coordinates:</p>
<pre class="brush:java">// here we 1st create a copy of v and then convert that one
Vec2D p = v.copy().toPolar();</pre>
<p>To see this basic usage pattern in more context, take a closer look at the <code>drawHoles(</code>) method below (lines 114-134) or check out the <a href="http://code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/examples/core/PolarUnravel/PolarUnravel.pde" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/examples/core/PolarUnravel/PolarUnravel.pde?referer=');">PolarUnravel demo</a> bundled with the core lib.</p>
<h2>Spline2D</h2>
<p>Each cut-out shape in the wheel is created from a simple spline shape, specified using only 4 points. As mentioned above, these anchor points are specified using (initially) polar coordinates and the Spline2D class is then computing control points (handles) for each of these given points automatically. As user you can also specify tightness &amp; subdivisions for the computed curve vertices in between. While the lack of direct manual control over the spline handles might be a shortcoming in some situations, I generally found it easier to work with this automated version, especially when working with long curves and not only single bezier segments.</p>
<p>The next release of the library will also add a decimator method to this class which will enable the sampling of the curve at a uniform interval (i.e. all successive points of the returned list have the same distance (within a tolerance), regardless of curvature). This feature comes from the <a href="http://code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/src.physics/toxi/physics/ParticlePath.java" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/src.physics/toxi/physics/ParticlePath.java?referer=');">ParticlePath</a> class briefly described in the <a href="http://toxiclibs.org/2010/01/happy-2010/">Happy 2010 post</a>.</p>
<p>Computing symmetrical handles for the curve endpoints is another still outstanding feature, but currently low priority (unless someone has got a patch ready for that ;)</p>
<p>The next image shows the 4 anchor points of each spline shape in green and all other computed vertices in pink.</p>
<p><a href="http://www.flickr.com/photos/toxi/4280635396/" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/4280635396/?referer=');"><img src="http://toxiclibs.org/wp-content/uploads/2010/01/wheelspline-e1263695654792.png" alt="wheel with highlighted spline vertices" title="wheelspline" width="680" height="680" class="alignnone size-full wp-image-180" /></a></p>
<h2>UnitTranslator</h2>
<p>This class is the sole, lonely member of the <code>toxi.math.conversion</code> package, but is especially useful for those of you using Processing for digital fabrication or creating printed outputs. It provides the following conversion methods, making it trivial to e.g produce PDF outputs at the right physical dimensions (without trial &amp; error):</p>
<ul>
<li><code>millisToPixels(double mm, int dpi)</code> &#8211; Converts millimeters into pixels.</li>
<li><code>millisToPoints(double mm)</code> &#8211; Converts millimeters into PostScript points.</li>
<li><code>pixelsToInch(int pix, int dpi)</code> &#8211; Converts pixels into inches.</li>
<li><code>pixelsToMillis(int pix, int dpi)</code> &#8211; Converts pixels into millimeters.</li>
<li><code>pixelsToPoints(int pix, int dpi)</code> &#8211; Converts pixels into points.</li>
<li><code>pointsToMillis(double pt)</code> &#8211; Converts points into millimeters.</li>
<li><code>pointsToPixels(double pt, int dpi)</code> &#8211; Converts points into pixels.</li>
</ul>
<p>In the demo below, we&#8217;re using it to specifiy the wheel radius and drill holes in mm and then automatically calculate the required window size in pixels. In that case we&#8217;re however not using <code>millisToPixels()</code>, but <code>millisToPoints()</code> because PDF units are in points which are interpreted as 1 pixel (at 72 dpi)&#8230;</p>
<h2>The Wheel tool</h2>
<p>Just copy &#038; paste the code below into Processing and hit <em>Run</em> to fill up your hard disk (kidding, by default it only generates 120 different small PDF files/variations). The variations are created by iterating over all permutations of 4 parameters: number of symmetry steps, inset radius, core radius, alternate core radius.</p>
<pre class="brush:java">/**
 * Generative wheel designs utilizing Vec2D polar coordinates,
 * splines and unit conversion. By default each design is exported as
 * PDF &#038; PNG file, but can be turned off by setting the doExport flag to false.
 *
 * Usage: if export is enabled simply run &#038; wait until all permutations
 * have been generated. Else press 'x' to activate next permutation or
 * use - / = to adjust the ARC_WIDTH parameter which defines the
 * size of the cutouts.
 *
 * (c) 2010 Karsten Schmidt, PostSpectacular Ltd.
 *
 * More info: http://toxiclibs.org/2010/01/re-inventing-the-wheel/
 * Source code licensed under GPL v3.0. See http://www.gnu.org/licenses/gpl.html
 */

import processing.pdf.*;

import toxi.geom.*;
import toxi.math.conversion.*;

// bleed in mm
int BLEED = 6;

// wheel radii &#038; document size
float R = (float)UnitTranslator.millisToPoints(370 / 2);
float W = 2 * R + 2 * (float)UnitTranslator.millisToPoints(BLEED);
float EMPTY_CORE_SIZE = (float)UnitTranslator.millisToPoints(5);

// start number of main segments
int NUM_SEGMENTS = 3;

// normalized parameters
float INSET_RADIUS = 0.8f;
float OFFSET = 0.1f;
float CORE_RADIUS = 0.15f;
float ALTCORE_RADIUS = 0.3f;
float ARC_WIDTH = 0.4f;

// optional mounting holes
int NUM_DOTS = 18;
float DOT_RADIUS = 0.97f;
float DOTSIZE = (float)UnitTranslator.millisToPoints(2);

// number of subdivisions for spline vertex computation
int SPLINE_SUBDIV = 20;

// flag for PDF &#038; PNG export of all permutations
boolean doExport = true;

public void setup() {
  size((int) W, (int) W);
  // turn off automatic redraws when not exporting
  if (!doExport) {
    noLoop();
  }
}

public void draw() {
  String frameID =
    "wheel-" + NUM_SEGMENTS + "-" + nf(INSET_RADIUS, 1, 2) + "-"
    + nf(ALTCORE_RADIUS, 1, 2) + "-"
    + nf(CORE_RADIUS, 1, 2) + "-" + nf(ARC_WIDTH, 1, 2);
  println(frameID);
  if (doExport) {
    beginRecord(PDF, "out/" + frameID + ".pdf");
  }
  background(255);
  noStroke();
  fill(0);
  translate(width / 2, height / 2);
  ellipseMode(RADIUS);
  ellipse(0, 0, R, R);
  fill(255);
  ellipse(0, 0, EMPTY_CORE_SIZE, EMPTY_CORE_SIZE);
  // main holes
  drawHoles((INSET_RADIUS + OFFSET) * R, CORE_RADIUS * R, (INSET_RADIUS
    + OFFSET + CORE_RADIUS)
    / 2 * R, ARC_WIDTH, 0, NUM_SEGMENTS);
  if (CORE_RADIUS &gt;= 0.5) {
    drawHoles(CORE_RADIUS * 0.85f * R, 0.2f * R,
    (CORE_RADIUS * 0.85f + 0.2f) / 2 * R, ARC_WIDTH, 0,
    NUM_SEGMENTS);
  }
  // small cutouts
  drawHoles(INSET_RADIUS * R, ALTCORE_RADIUS * R,
  (INSET_RADIUS + ALTCORE_RADIUS) / 2 * R, ARC_WIDTH / 2, PI
    / NUM_SEGMENTS, NUM_SEGMENTS);
  if (ALTCORE_RADIUS &gt;= 0.5) {
    drawHoles(ALTCORE_RADIUS * 0.85f * R, 0.3f * R,
    (ALTCORE_RADIUS * 0.85f + 0.3f) / 2 * R, ARC_WIDTH / 2, PI
      / NUM_SEGMENTS, NUM_SEGMENTS);
  }
  // drill holes
  drawDots(NUM_DOTS, DOT_RADIUS * R, DOTSIZE);
  if (doExport) {
    endRecord();
    saveFrame("png/" + frameID + ".png");
    nextPermutation();
  }
}

void drawDots(int num, float radius, float s) {
  float delta = TWO_PI / num;
  for (int i = 0; i &lt; num; i++) {
    Vec2D p = new Vec2D(radius, i * delta).toCartesian();
    ellipse(p.x, p.y, s, s);
  }
}

void drawHoles(float outerR, float innerR, float centerR, float radiusWidth, float thetaOffset, int num) {
  radiusWidth *= PI / num;
  Spline2D s = new Spline2D();
  // define point in polar coordinates, then convert them
  Vec2D p = new Vec2D(outerR, 0).toCartesian();
  Vec2D a = new Vec2D(outerR, radiusWidth).toCartesian();
  Vec2D b = new Vec2D(centerR, radiusWidth).toCartesian();
  Vec2D c = new Vec2D(innerR, 0).toCartesian();
  Vec2D d = new Vec2D(centerR, -radiusWidth).toCartesian();
  Vec2D e = new Vec2D(outerR, -radiusWidth).toCartesian();
  // add points to spline &#038; compute
  s.add(p).add(a).add(b).add(c).add(d).add(e).add(p);
  java.util.List verts = s.computeVertices(SPLINE_SUBDIV);
  float delta = TWO_PI / num;
  for (int i = 0; i &lt; num; i++) {
    pushMatrix();
    rotate(i * delta + thetaOffset);
    drawPath(verts);
    popMatrix();
  }
}

void drawPath(java.util.List verts) {
  beginShape();
  for (Iterator i = verts.iterator(); i.hasNext();) {
    Vec2D v = (Vec2D) i.next();
    vertex(v.x, v.y);
  }
  endShape();
}

public void keyPressed() {
  if (key == 'x') {
    nextPermutation();
  } else if (key == '-') {
    ARC_WIDTH -= 0.02;
  } else if (key == '=') {
    ARC_WIDTH += 0.02;
  }
  redraw();
}

void nextPermutation() {
  CORE_RADIUS += 0.2;
  if (CORE_RADIUS &gt;= INSET_RADIUS) {
    CORE_RADIUS = 0.15f;
    ALTCORE_RADIUS += 0.2f;
    if (ALTCORE_RADIUS &gt;= INSET_RADIUS) {
      ALTCORE_RADIUS = 0.3f;
      INSET_RADIUS += 0.1f;
      if (INSET_RADIUS &gt; 0.8) {
        NUM_SEGMENTS++;
        INSET_RADIUS = 0.8f;
        if (NUM_SEGMENTS &gt; 12) {
          exit();
        }
      }
    }
  }
}
</pre>
<p>Finally, below are some more images of variations created with this tool (<a href="http://www.flickr.com/photos/toxi/sets/72157623224570676/" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/sets/72157623224570676/?referer=');">see the full size &#038; set on flickr</a>):</p>
<p><a href="http://www.flickr.com/photos/toxi/4280053262/" title="wheel3_all by toxi, on Flickr" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/4280053262/?referer=');"><img src="http://farm3.static.flickr.com/2680/4280053262_5e0676cd13.jpg" width="350" height="500" alt="wheel3_all" /></a></p>
<p><a href="http://www.flickr.com/photos/toxi/4279310563/" title="wheel5_all by toxi, on Flickr" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/4279310563/?referer=');"><img src="http://farm5.static.flickr.com/4021/4279310563_ca5ed79d6c.jpg" width="350" height="500" alt="wheel5_all" /></a></p>
<p><a href="http://www.flickr.com/photos/toxi/4280055796/" title="wheel8_all by toxi, on Flickr" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/toxi/4280055796/?referer=');"><img src="http://farm3.static.flickr.com/2758/4280055796_f43663fc20.jpg" width="350" height="500" alt="wheel8_all" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://toxiclibs.org/2010/01/re-inventing-the-wheel/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Recode submissions</title>
		<link>http://toxiclibs.org/2010/01/decoderecode-submissions/</link>
		<comments>http://toxiclibs.org/2010/01/decoderecode-submissions/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 02:14:00 +0000</pubDate>
		<dc:creator>toxi</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Showcase]]></category>
		<category><![CDATA[volumeutils]]></category>
		<category><![CDATA[decode]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[variation]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://toxiclibs.postspectacular.com/?p=85</guid>
		<description><![CDATA[Here&#8217;re four of my personal favourites of the many submissions to the Recode competition of the V&#38;A Decode identity, which closed last Sunday&#8230; I&#8217;m not part of the judging panel, but I&#8217;m looking forward to find out if one of them will be chosen to be shown on the cross-track projectors throughout London Underground. Generative [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;re four of my personal favourites of the many submissions to the Recode competition of the <a href="/2009/12/va-decode-generative-identity/">V&amp;A Decode identity</a>, which closed last Sunday&#8230; I&#8217;m not part of the judging panel, but I&#8217;m looking forward to find out if one of them will be chosen to be shown on the cross-track projectors throughout London Underground. Generative art for the masses! :)</p>
<p><iframe src="http://player.vimeo.com/video/8613900" width="680" height="382" frameborder="0"></iframe><br />
By <a href="http://www.vimeo.com/oampo" onclick="pageTracker._trackPageview('/outgoing/www.vimeo.com/oampo?referer=');">Joe Turner</a></p>
<p><iframe src="http://player.vimeo.com/video/8658509" width="680" height="382" frameborder="0"></iframe><br />
By <a href="http://www.vimeo.com/user2007615" onclick="pageTracker._trackPageview('/outgoing/www.vimeo.com/user2007615?referer=');">DieTapete</a></p>
<p><iframe src="http://player.vimeo.com/video/8556433" width="680" height="382" frameborder="0"></iframe><br />
By <a href="http://www.vimeo.com/user1584689" onclick="pageTracker._trackPageview('/outgoing/www.vimeo.com/user1584689?referer=');">Stefan Mylleager</a></p>
<p><iframe src="http://player.vimeo.com/video/8051278" width="680" height="382" frameborder="0"></iframe><br />
By <a href="http://www.vimeo.com/liasomething" onclick="pageTracker._trackPageview('/outgoing/www.vimeo.com/liasomething?referer=');">Lia</a></p>
]]></content:encoded>
			<wfw:commentRss>http://toxiclibs.org/2010/01/decoderecode-submissions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

