<?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>Code &#038; form &#187; Libraries</title>
	<atom:link href="http://workshop.evolutionzone.com/category/libraries/feed/" rel="self" type="application/rss+xml" />
	<link>http://workshop.evolutionzone.com</link>
	<description>Computational aesthetics and programming for artists and designers.</description>
	<lastBuildDate>Sun, 04 Jul 2010 20:09:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>TileSaver broken &#8211; temporary hack</title>
		<link>http://workshop.evolutionzone.com/2009/08/18/tilesaver-broken-temporary-hack/</link>
		<comments>http://workshop.evolutionzone.com/2009/08/18/tilesaver-broken-temporary-hack/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 05:22:26 +0000</pubDate>
		<dc:creator>marius watz</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Libraries]]></category>
		<category><![CDATA[Processing / Java]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[high-resolution]]></category>
		<category><![CDATA[output]]></category>
		<category><![CDATA[print]]></category>
		<category><![CDATA[processing.org]]></category>
		<category><![CDATA[tilesaver]]></category>
		<category><![CDATA[unlekkerlib]]></category>

		<guid isPermaLink="false">http://workshop.evolutionzone.com/?p=244</guid>
		<description><![CDATA[As documented in this thread on the Processing forums the TileSaver class seems to be broken for current versions of Processing. Sadly I&#8217;m not sure what the problem is and I don&#8217;t have time to fix it right now.
However, I tried the original TileSaver code posted back in 2006 and miraculously that still works. This [...]]]></description>
			<content:encoded><![CDATA[<p>As documented in <a href="http://processing.org/discourse/yabb2/YaBB.pl?num=1248245155/0#10">this thread on the Processing forums</a> the TileSaver class seems to be broken for current versions of Processing. Sadly I&#8217;m not sure what the problem is and I don&#8217;t have time to fix it right now.</p>
<p>However, I tried the original TileSaver code posted back in 2006 and miraculously that still works. This would imply a larger issue with the unlekkerLib library and Processing 1.0, which I&#8217;ll have to address when I have the time.</p>
<p>For now, here is a link to a working Processing sketch using the old TileSaver code: <a href="http://workshop.evolutionzone.com/files/TileSaverTest.zip">TileSaverTest.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://workshop.evolutionzone.com/2009/08/18/tilesaver-broken-temporary-hack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>unlekkerLib0003c: Now compatible with Processing 1.0</title>
		<link>http://workshop.evolutionzone.com/2009/04/16/unlekkerlib0003c-now-compatible-with-processing-10/</link>
		<comments>http://workshop.evolutionzone.com/2009/04/16/unlekkerlib0003c-now-compatible-with-processing-10/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 06:19:56 +0000</pubDate>
		<dc:creator>marius watz</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Libraries]]></category>
		<category><![CDATA[Processing / Java]]></category>
		<category><![CDATA[codeandform]]></category>
		<category><![CDATA[google code]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[processing.org]]></category>
		<category><![CDATA[tilesaver]]></category>
		<category><![CDATA[unlekkerlib]]></category>

		<guid isPermaLink="false">http://workshop.evolutionzone.com/?p=234</guid>
		<description><![CDATA[After several requests I&#8217;ve taken the time to make unlekkerLib  compatible with Processing 1.0. Apologies to anyone who&#8217;s been inconvenienced by the lack of a 1.0 version.
In particular, STL export should work again. However I haven&#8217;t had the chance to test the code very much, so please let me know if you find any [...]]]></description>
			<content:encoded><![CDATA[<p>After several requests I&#8217;ve taken the time to make <a href="http://workshop.evolutionzone.com/unlekkerlib/">unlekkerLib </a> compatible with Processing 1.0. Apologies to anyone who&#8217;s been inconvenienced by the lack of a 1.0 version.</p>
<p>In particular, STL export should work again. However I haven&#8217;t had the chance to test the code very much, so please let me know if you find any bugs.</p>
<div class="mediumtitle">Download</div>
<ul>
<li><a href="http://code.google.com/p/codeandform/downloads/detail?name=unlekkerLib0003c.zip&#038;can=2&#038;q=" title="unlekkerLib0003c">unlekkerLib0003c</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://workshop.evolutionzone.com/2009/04/16/unlekkerlib0003c-now-compatible-with-processing-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>unlekkerLib-0003: Fixed missing classes</title>
		<link>http://workshop.evolutionzone.com/2008/07/12/unlekkerlib-0003-fixed-missing-classes/</link>
		<comments>http://workshop.evolutionzone.com/2008/07/12/unlekkerlib-0003-fixed-missing-classes/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 18:51:37 +0000</pubDate>
		<dc:creator>marius watz</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Libraries]]></category>
		<category><![CDATA[Processing / Java]]></category>
		<category><![CDATA[codeandform]]></category>
		<category><![CDATA[google code]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[processing.org]]></category>
		<category><![CDATA[tilesaver]]></category>
		<category><![CDATA[unlekkerlib]]></category>

		<guid isPermaLink="false">http://workshop.evolutionzone.com/?p=205</guid>
		<description><![CDATA[I&#8217;ve uploaded a new version of my unlekkerLib library. For some inexplicable reason version 0002 was missing some classes that were needed for certain examples to function. As a result the TileSaver class was broken, which was a serious omission. 
You can download unlekkerLib-0003 from the <a href="http://code.google.com/p/codeandform/downloads/list" title="Code &#038; Form Google Code repository">Code &#038; Form Google Code repository</a>. I&#8217;ve added the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve uploaded a new version of my <a href="http://workshop.evolutionzone.com/unlekkerlib/">unlekkerLib library</a>. For some inexplicable reason version 0002 was missing some classes that were needed for certain examples to function. As a result the TileSaver class was broken, which was a serious omission. </p>
<p>You can download unlekkerLib-0003 from the <a href="http://code.google.com/p/codeandform/downloads/list" title="Code &#038; Form Google Code repository">Code &#038; Form Google Code repository</a>. I&#8217;ve added the missing classes, but otherwise the library is the same. If you still experience problems please report them here.</p>
]]></content:encoded>
			<wfw:commentRss>http://workshop.evolutionzone.com/2008/07/12/unlekkerlib-0003-fixed-missing-classes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Code &amp; Form code library 0001+ Google Code repository</title>
		<link>http://workshop.evolutionzone.com/2008/04/12/code-form-code-library-0001-google-code-repository/</link>
		<comments>http://workshop.evolutionzone.com/2008/04/12/code-form-code-library-0001-google-code-repository/#comments</comments>
		<pubDate>Sat, 12 Apr 2008 12:44:19 +0000</pubDate>
		<dc:creator>marius watz</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Libraries]]></category>
		<category><![CDATA[Processing / Java]]></category>
		<category><![CDATA[codeandform]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[google code]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[processing.org]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[unlekkerlib]]></category>

		<guid isPermaLink="false">http://workshop.evolutionzone.com/2008/04/12/code-form-code-library-0001-google-code-repository/</guid>
		<description><![CDATA[
Contents of <a href="http://code.google.com/p/codeandform/downloads/list" title="Code &#038; Form code library v0001">Code &#038; Form code library v0001</a>
I&#8217;ve decided to put my Processing hacks from the <a href="http://workshop.evolutionzone.com/code-hacks/" title="Code &#038; hacks page">Code &#038; hacks page</a> and consolidate them into a downloadable archive. Thus the <a href="http://workshop.evolutionzone.com/codeandformcodelib/" title="Code &#038; Form code library">Code &#038; Form code library</a> is born. It will contain various demos and hacks, as well as example code for the unlekkerLib library. It should be [...]]]></description>
			<content:encoded><![CDATA[<div class="flickrImg"><a href="http://code.google.com/p/codeandform/downloads/list" title='codeandformCodeLib 0001 Folder structure'><img src='http://workshop.evolutionzone.com/wp-content/uploads/2008/04/codeandform-001-folder-snapshot.gif' alt='Code &#038; Form Code library 0001 Folder structure' /></a></p>
<p>Contents of <a href="http://code.google.com/p/codeandform/downloads/list" title="Code &#038; Form code library v0001">Code &#038; Form code library v0001</a></p></div>
<p>I&#8217;ve decided to put my Processing hacks from the <a href="http://workshop.evolutionzone.com/code-hacks/" title="Code &#038; hacks page">Code &#038; hacks page</a> and consolidate them into a downloadable archive. Thus the <a href="http://workshop.evolutionzone.com/codeandformcodelib/" title="Code &#038; Form code library">Code &#038; Form code library</a> is born. It will contain various demos and hacks, as well as example code for the unlekkerLib library. It should be much easier to publish code this way, since students etc. can simply download the archive and dump the contents in their sketchbook folder for quick access.</p>
<p>I&#8217;ve started a <a href="http://code.google.com/p/codeandform/" title="Google Code repository">Google Code repository</a> for this purpose, which seems a good way to go. I&#8217;m still figuring out SVN etc, hopefully I can switch to publishing the unlekkerLib source &#8220;live&#8221; through SVN once I figure it out. I&#8217;ll also publish archives of code written during past workshops to the repository.</p>
<p><strong>There seems to be a growing list</strong> of Processing-related Google Code repositories out there, examples include Toxi&#8217;s <a href="http://code.google.com/p/toxiclibs/" title="Toxiclibs">Toxiclibs</a>, <a href="http://code.google.com/p/interfascia/" title="interfascia">interfascia</a> and <a href="http://code.google.com/p/jddaniels/" title="jddaniels">jddaniels</a>. Do a <a href="http://code.google.com/hosting/search?q=processing.org&#038;projectsearch=Search+Projects" title="search for processing.org">search for processing.org</a> to find more.</p>
]]></content:encoded>
			<wfw:commentRss>http://workshop.evolutionzone.com/2008/04/12/code-form-code-library-0001-google-code-repository/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Library: unlekkerLib-0002</title>
		<link>http://workshop.evolutionzone.com/2007/10/28/library-unlekkerlib-0002/</link>
		<comments>http://workshop.evolutionzone.com/2007/10/28/library-unlekkerlib-0002/#comments</comments>
		<pubDate>Sun, 28 Oct 2007 00:30:34 +0000</pubDate>
		<dc:creator>marius watz</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Libraries]]></category>
		<category><![CDATA[Processing / Java]]></category>

		<guid isPermaLink="false">http://workshop.evolutionzone.com/2007/10/28/library-unlekkerlib-0002/</guid>
		<description><![CDATA[I just posted a quick update to <a href="http://workshop.evolutionzone.com/unlekkerlib/" title="unlekkerLib">unlekkerLib</a>. It seems the first version I posted used Java 5 because I hadn&#8217;t configured Eclipse correctly. This version is compiled for 1.4. I have tested it with Processing 0125, but please give me feedback if it gives you trouble.
I added two new functions to the library, nothing [...]]]></description>
			<content:encoded><![CDATA[<p>I just posted a quick update to <a href="http://workshop.evolutionzone.com/unlekkerlib/" title="unlekkerLib">unlekkerLib</a>. It seems the first version I posted used Java 5 because I hadn&#8217;t configured Eclipse correctly. This version is compiled for 1.4. I have tested it with Processing 0125, but please give me feedback if it gives you trouble.</p>
<p>I added two new functions to the library, nothing big but could be useful for some people:</p>
<div class="mediumtitle">[071028] unlekkerLib-0002 features:</div>
<ul>
<li><strong>unlekker.data.POVRay:</strong> Primitive POV-Ray triangle geometry export.</li>
<li><strong>unlekker.data.FeedReader:</strong> Feed reading utility class (requires installing extra JARs)</li>
</ul>
<p>To use the feed classes simply use the code from <a href="http://workshop.evolutionzone.com/2007/09/24/code-read-rss-feed-in-processing/" title="this previous post">this previous post</a>, minus the class definitions.</p>
]]></content:encoded>
			<wfw:commentRss>http://workshop.evolutionzone.com/2007/10/28/library-unlekkerlib-0002/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>New library: unlekkerLib</title>
		<link>http://workshop.evolutionzone.com/2007/09/24/unlekkerlib/</link>
		<comments>http://workshop.evolutionzone.com/2007/09/24/unlekkerlib/#comments</comments>
		<pubDate>Mon, 24 Sep 2007 17:12:45 +0000</pubDate>
		<dc:creator>marius watz</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Libraries]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Processing / Java]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[processing.org]]></category>
		<category><![CDATA[rapid-prototyping]]></category>
		<category><![CDATA[stereolithography]]></category>
		<category><![CDATA[stl]]></category>
		<category><![CDATA[unlekkerlib]]></category>

		<guid isPermaLink="false">http://workshop.evolutionzone.com/2007/09/24/unlekkerlib/</guid>
		<description><![CDATA[
<a href="http://flickr.com/photos/watz/sets/72157594387603246/" title="Rapid prototyping objects">Rapid prototyping objects</a> generated with Processing and output to STL using unlekkerLib.
I&#8217;ve just uploaded a new Processing library called unlekkerLib. It is a collection of tools and code snippets I use frequently, and which I&#8217;ve now just barely cleaned up enough for other people to use. Instead of releasing them piece by piece, I&#8217;ve decided [...]]]></description>
			<content:encoded><![CDATA[<div class="flickrImg"><a href="http://www.flickr.com/photos/watz/1416633393/" title="Photo Sharing"><img src="http://farm2.static.flickr.com/1346/1416633393_84b9b43838.jpg" width="500" height="375" alt="AHO RP 004 Object #1 - #3 [lo]" /></a></p>
<p><a href="http://flickr.com/photos/watz/sets/72157594387603246/" title="Rapid prototyping objects">Rapid prototyping objects</a> generated with Processing and output to STL using unlekkerLib.</p></div>
<p>I&#8217;ve just uploaded a new Processing library called unlekkerLib. It is a collection of tools and code snippets I use frequently, and which I&#8217;ve now just barely cleaned up enough for other people to use. Instead of releasing them piece by piece, I&#8217;ve decided to bundle them together in a package hierarchy. </p>
<p>The main reason I decided to release it now is the STL export code I&#8217;ve written for my <a href="http://flickr.com/photos/watz/sets/72157594387603246/" title="rapid prototyping">rapid prototyping</a> projects. Several people have asked for the code, so I wanted to get it out there for you to play with. Obviously, it works as well with Processing as it does with regular Java.</p>
<p>Caveat emptor:There&#8217;s not much documentation but I do provide the source code. This is v.0001 &#8211; the very first release, so it&#8217;s pretty basic. See below for an idea of what the library contains. Right now the most exciting new component is the unlekker.data.STL class, which supports export and import of STL stereolithography files for rapid prototyping. Have a look at the <a href="http://workshop.evolutionzone.com/files/unlekkerLibDoc" title="Javadoc">Javadoc</a> for more details. </p>
<p>Updates will appear here: <a href="http://workshop.evolutionzone.com/unlekkerlib/">http://workshop.evolutionzone.com/unlekkerlib/</a>.</p>
<p><span id="more-142"></span>
<div class="mediumtitle">[070924] unlekkerLib-0001 features:</div>
<ul>
<li><strong>unlekker.data.STL:</strong> STL import and export.</li>
<li><strong>unlekker.util.Rnd:</strong> Mersenne Twister pseudo-random number generator.</li>
<li><strong>unlekker.util.TileSaver:</strong> The TileSaver class for creating high-res images from OpenGL graphics by tiling the viewport.</li>
<li><strong>unlekker.geom.Intersect:</strong> Line intersection and checking for collision with complex 2D polygons.</li>
</ul>
<div class="mediumtitle">Installation</div>
<p>Download <a href="http://workshop.evolutionzone.com/files/unlekkerLib-0001.zip" title="unlekkerLib-0001.zip">unlekkerLib-0001.zip</a> and unpack it.</p>
<p>Copy the &quot;unlekker&quot; folder from the &#8220;00 For processing library folder&#8221; folder into the &quot;libraries&quot; subfolder of your Processing application. The library should now appear as a choice in &quot;Import library&quot; next time you start Processing. </p>
<p>The Java source can be found in &#8220;00 For processing library folder > unlekker> src&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://workshop.evolutionzone.com/2007/09/24/unlekkerlib/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Code: Read RSS feeds in Processing</title>
		<link>http://workshop.evolutionzone.com/2007/09/24/code-read-rss-feed-in-processing/</link>
		<comments>http://workshop.evolutionzone.com/2007/09/24/code-read-rss-feed-in-processing/#comments</comments>
		<pubDate>Mon, 24 Sep 2007 01:08:24 +0000</pubDate>
		<dc:creator>marius watz</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Libraries]]></category>
		<category><![CDATA[Processing / Java]]></category>
		<category><![CDATA[Workshops]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[pde]]></category>
		<category><![CDATA[processing.org]]></category>
		<category><![CDATA[rome]]></category>
		<category><![CDATA[rss]]></category>

		<guid isPermaLink="false">http://workshop.evolutionzone.com/2007/09/24/code-read-rss-feed-in-processing/</guid>
		<description><![CDATA[After suggesting to my AHO class that they consider using RSS feeds in Processing, I realized that there is actually no built-in functionality to do so. The XML class built into Processing is too basic to handle feeds, it seems. To remedy the situation I&#8217;ve cooked up a quick hack using the <a href="https://rome.dev.java.net/" title="ROME library">ROME library</a> for [...]]]></description>
			<content:encoded><![CDATA[<p>After suggesting to my AHO class that they consider using RSS feeds in Processing, I realized that there is actually no built-in functionality to do so. The XML class built into Processing is too basic to handle feeds, it seems. To remedy the situation I&#8217;ve cooked up a quick hack using the <a href="https://rome.dev.java.net/" title="ROME library">ROME library</a> for RSS / Atom syndication.</p>
<p>To run the code below you&#8217;ll need to download <a href="https://rome.dev.java.net/" title="ROME">ROME</a> and <a href="http://www.jdom.org/" title="JDOM">JDOM</a>. Make a &#8220;code&#8221; subfolder in your sketch and paste &#8220;jdom.jar&#8221; and &#8220;rome-*.jar&#8221; into it, then run the code as given. The FeedReader and FeedEntry convenience classes take care of parsing the feed and returning the entries with the most common fields included. Error checking is rudimentary, however.</p>
<div class="mediumtitle">Code &#8211; feedParser.pde</div>
<p><span id="more-141"></span>
<pre name="code" class="java">// feedParser.pde
//
// Reads RSS and Atom feeds. Requires ROME
// (https://rome.dev.java.net/)
// and JDOM (http://www.jdom.org/), just make
// a code folder and copy "jdom.jar" and "rome-*.jar"
// into it.
//
// Marius Watz - http://workshop.evolutionzone.com

import com.sun.syndication.feed.synd.*;
import com.sun.syndication.io.*;

FeedReader feed;
String feedurl;

void setup() {
  size(200, 200);

  // load feed
  feedurl="http://feeds.feedburner.com/CodeForm";
  println("Loading feed: "+feedurl);
  feed=new FeedReader(feedurl);

  // print feed data
  println("Feed: "+feed.title);
  println("------------------------------");
  println("Description: "+feed.description);
  println("\nNumber of entries: "+feed.numEntries);
  println("------------------------------");

  // print feed entries
  for(int i=0; i< feed.numEntries; i++) {
    println(i+": "+feed.entry[i]);
  }
}

class FeedReader {
  SyndFeed feed;
  String url,description,title;
  int numEntries;
  FeedEntry entry[];

  public FeedReader(String _url) {
    url=_url;
    try {
      feed=new SyndFeedInput().build(new XmlReader(new URL(url)));
      description=feed.getDescription();
      title=feed.getTitle();

      java.util.List entrl=feed.getEntries();
      Object [] o=entrl.toArray();
      numEntries=o.length;

      entry=new FeedEntry[numEntries];
      for(int i=0; i< numEntries; i++) {
        entry[i]=new FeedEntry((SyndEntryImpl)o[i]);
        println(i+": "+entry[i]);
      }
    }
    catch(Exception e) {
      println("Exception in Feedreader: "+e.toString());
      e.printStackTrace();
    }
  }

}

class FeedEntry {
  Date pubdate;
  SyndEntryImpl entry;
  String author, contents, description, url, title;
  public String newline = System.getProperty("line.separator");

  public FeedEntry(SyndEntryImpl _entry) {
    try {
      entry=_entry;
      author=entry.getAuthor();
      Object [] o=entry.getContents().toArray();
      if(o.length>0) contents=((SyndContentImpl)o[0]).getValue();
      else contents="[No content.]";

      description=entry.getDescription().getValue();
      if(description.charAt(0)==
        System.getProperty("line.separator").charAt(0))
          description=description.substring(1);

      url=entry.getLink();
      title=entry.getTitle();
      pubdate=entry.getPublishedDate();
    }
    catch(Exception e) {
      println("Exception in FeedEntry: "+e.toString());
      e.printStackTrace();
    }

  }

  public String toString() {
    String s;

    s="Title: "+title+newline+
      "URL: "+url+newline+
      "Date: "+pubdate.toString()+newline;

    if(description.length()>50)
      s+="Descr: ["+description.substring(0,50)+
        "...]"+newline;
    else s+="Descr: ["+description+"]"+newline;

    if(contents.length()>50)
      s+="Contents: ["+contents.substring(0,50)+
        "...]"+newline;
    else s+="Contents: ["+contents+"]"+newline;
    return s;
  }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://workshop.evolutionzone.com/2007/09/24/code-read-rss-feed-in-processing/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Hack: OpenGL anti-aliasing for 0125</title>
		<link>http://workshop.evolutionzone.com/2007/09/08/hack-opengl-anti-aliasing-for-0125/</link>
		<comments>http://workshop.evolutionzone.com/2007/09/08/hack-opengl-anti-aliasing-for-0125/#comments</comments>
		<pubDate>Sat, 08 Sep 2007 10:14:29 +0000</pubDate>
		<dc:creator>marius watz</dc:creator>
				<category><![CDATA[Libraries]]></category>
		<category><![CDATA[Processing / Java]]></category>

		<guid isPermaLink="false">http://workshop.evolutionzone.com/2007/09/08/hack-opengl-anti-aliasing-for-0125/</guid>
		<description><![CDATA[Update: This hack is obsolete as of 0133. Read more <a href="http://workshop.evolutionzone.com/2007/10/30/opengl-anti-aliasing-in-processing-0133/" title="here">here</a>.
For those of you who have been using the hack I posted <a href="http://workshop.evolutionzone.com/2007/04/30/hack-force-opengl-anti-aliasing-in-processing/" title="a while back">a while back</a> to force anti-aliasing in Processing, here&#8217;s an updated version for Processing 0125. According to the <a href="http://dev.processing.org/source/index.cgi/trunk/processing/opengl/src/processing/opengl/PGraphicsOpenGL.java?rev=3420&#038;view=log" title="source repository">source repository</a> Ben has been fixing lots of little things in PGraphicsOpenGL, so it&#8217;s worth [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update: This hack is obsolete as of 0133. Read more <a href="http://workshop.evolutionzone.com/2007/10/30/opengl-anti-aliasing-in-processing-0133/" title="here">here</a>.</strong></p>
<p>For those of you who have been using the hack I posted <a href="http://workshop.evolutionzone.com/2007/04/30/hack-force-opengl-anti-aliasing-in-processing/" title="a while back">a while back</a> to force anti-aliasing in Processing, here&#8217;s an updated version for Processing 0125. According to the <a href="http://dev.processing.org/source/index.cgi/trunk/processing/opengl/src/processing/opengl/PGraphicsOpenGL.java?rev=3420&#038;view=log" title="source repository">source repository</a> Ben has been fixing lots of little things in PGraphicsOpenGL, so it&#8217;s worth updating. </p>
<p>The hack is actually lying dormant in the PGraphicsOpenGL source, but it&#8217;s been commented out with the note &#8220;how to integrate this properly?&#8221;. Obviously, having to set hardware-specific settings goes against the ease of use that Processing is known for. I guess Ben and Casey are just trying to find a way to include it in a manner consistent with the rest of the application.</p>
<p>To use the hack simply download the ZIP archive below and unpack it to produce the hacked &#8220;opengl.jar&#8221; file. Drop the JAR into the &#8220;libraries\opengl\library&#8221; subfolder of your Processing application directory. Make sure to make a backup of the original opengl.jar. Once replaced, the new PGraphicsOpenGL class always initializes with 4x supersampling.</p>
<div class="mediumtitle">Downloads</div>
<ul>
<li>OpenGL hack for version 0125: <a href="http://workshop.evolutionzone.com/files/opengl-hack-0125.zip" title="opengl-hack-0125.zip">opengl-hack-0125.zip</a>. </li>
<li>OpenGL hack for version 0124: <a href="http://workshop.evolutionzone.com/files/opengl-hack-0124.zip" title="opengl-hack-0124.zip">opengl-hack-0124.zip</a>. </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://workshop.evolutionzone.com/2007/09/08/hack-opengl-anti-aliasing-for-0125/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Code: aTileSaver.pde</title>
		<link>http://workshop.evolutionzone.com/2007/03/24/code-tilesaverpde/</link>
		<comments>http://workshop.evolutionzone.com/2007/03/24/code-tilesaverpde/#comments</comments>
		<pubDate>Sat, 24 Mar 2007 08:13:46 +0000</pubDate>
		<dc:creator>marius watz</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Libraries]]></category>
		<category><![CDATA[Processing / Java]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[pde]]></category>
		<category><![CDATA[processing.org]]></category>
		<category><![CDATA[tilesaver]]></category>

		<guid isPermaLink="false">http://workshop.evolutionzone.com/2007/03/24/code-tilesaverpde/</guid>
		<description><![CDATA[
High-resolution images from Processing using tiling (1.6% / 20%)

UPDATE: This code currently doesn&#8217;t work with Processing 1.0 and later. Please use Karsten Schmidt&#8217;s TileSaver replacement instead.
A while back I posted about <a href="http://workshop.evolutionzone.com/2006/08/31/tile-based-output-of-huge-raster-images/" title="rendering very high-resolution images">rendering very high-resolution images</a> from Processing using a tiling technique. I had implemented a working version of a solution first <a href="http://processing.org/discourse/yabb_beta/YaBB.cgi?board=OpenGL;action=display;num=1159148942;start=11#11" title="described by "surelyyoujest"">described by "surelyyoujest"</a>, but [...]]]></description>
			<content:encoded><![CDATA[<div class="flickrImg"><img id="image89" src="http://workshop.evolutionzone.com/wp-content/uploads/2007/03/070324_tilesaver.gif" alt="070324_tilesaver.gif" /></p>
<p class="flickrCaption">High-resolution images from Processing using tiling (1.6% / 20%)</p>
</div>
<p><strong>UPDATE: This code currently doesn&#8217;t work with Processing 1.0 and later. Please use Karsten Schmidt&#8217;s <a href="http://processing.org/discourse/yabb2/YaBB.pl?num=1248245155/0#11">TileSaver replacement</a> instead.</strong></p>
<p>A while back I posted about <a href="http://workshop.evolutionzone.com/2006/08/31/tile-based-output-of-huge-raster-images/" title="rendering very high-resolution images">rendering very high-resolution images</a> from Processing using a tiling technique. I had implemented a working version of a solution first <a href="http://processing.org/discourse/yabb_beta/YaBB.cgi?board=OpenGL;action=display;num=1159148942;start=11#11" title="described by "surelyyoujest"">described by "surelyyoujest"</a>, but didn&#8217;t have time to post a clean version of the code. (I did however post <a href="http://workshop.evolutionzone.com/2006/10/11/code-imagestitcherpde/" title="ImageStitcher.pde">ImageStitcher.pde</a>, which is code for stitching these tiled images back together.) But after a long delay, here is finally the more useful bit of code.</p>
<p>The code works by panning the camera over the original viewport area, subdividing the image into tiles. This way, OpenGL&#8217;s limitations on maximum resolution can be circumvented. As long as enough memory is allocated, the images created can be very big indeed. The images shown above are from a 15360 x 15360 pixel image, shown at 1.6% and 20% respectively. With 1.5 GB assigned to Java I have so far successfully saved 20k x 20k images. That&#8217;s large enough to print 2&#215;2 meter prints at 260 DPI.</p>
<p>What follows is the aTileSaver class and a simple demo application. I will post a more complex example soon.</p>
<p><strong>Update: I&#8217;ve changed a few minor details in the code. Make note of the version number if you have download it already. This code is likely to change.</strong>. </p>
<div class="mediumtitle">Source code &#8211;  aTileSaver.pde</div>
<p><span id="more-88"></span></p>
<p>The aTileSaver class is fairly easy to use. Drop it into any Processing sketch, add a trigger to start the tiling process and call Tilesaver.pre() and Tilesaver.post() at the beginning and end of draw(). The only thing to be aware of is that the shapes drawn should not change in any way while the tiling is in progress, otherwise the results will be mangled.</p>
<pre name="code" class="java">// aTileSaver.pde - v0.12 2007.0326
// Marius Watz - http://workshop.evolutionzone.com
//
// Class for rendering high-resolution images by splitting them into
// tiles using the viewport.
//
// Builds heavily on solution by "surelyyoujest":
// http://processing.org/discourse/yabb_beta/YaBB.cgi?
// board=OpenGL;action=display;num=1159148942

class aTileSaver {
  public boolean isTiling=false,done=true;
  public boolean doSavePreview=true;

  PApplet p;
  float FOV=60; // initial field of view
  float cameraZ, width, height;
  int tileNum=10,tileNumSq; // number of tiles
  int tileImgCnt, tileX, tileY, tilePad;
  boolean firstFrame=false, secondFrame=false;
  String tileFilename,tileFileExt=".tga";
  PImage tileImg;
  float perc,percMilestone;

// The constructor takes a PApplet reference to your sketch.
  public aTileSaver(PApplet _p) {
    p=_p;
  }

// If init() is called without specifying number of tiles, getMaxTiles()
// will be called to estimate number of tiles according to free memory.
  public void init(String _filename) {
    init(_filename,getMaxTiles(p.width));
  }

// Initialize using a filename to output to and number of tiles to use.
  public void init(String _filename,int _num) {
    tileFilename=_filename;
    tileNum=_num;
    tileNumSq=(tileNum*tileNum);

    width=p.width;
    height=p.height;
    cameraZ=(height/2.0f)/p.tan(p.PI*FOV/360.0f);
    p.println("aTileSaver: "+tileNum+" tilesnResolution: "+
      (p.width*tileNum)+"x"+(p.height*tileNum));

    // remove extension from filename
    if(!new java.io.File(tileFilename).isAbsolute())
      tileFilename=p.dataPath(tileFilename);
    tileFilename=noExt(tileFilename);
    p.createPath(tileFilename);

    // save preview
    if(doSavePreview) p.g.save(tileFilename+"_preview.png");

    // set up off-screen buffer for saving tiled images
    tileImg=new PImage(p.width*tileNum, p.height*tileNum);

    // start tiling
    done=false;
    isTiling=false;
    perc=0;
    percMilestone=0;
    tileInc();
  }

  // set filetype, default is TGA. pass a valid image extension as parameter.
  public void setSaveType(String extension) {
    tileFileExt=extension;
    if(tileFileExt.indexOf(".")==-1) tileFileExt="."+tileFileExt;
  }

  // pre() handles initialization of each frame.
  // It should be called in draw() before any drawing occurs.
  public void pre() {
    if(!isTiling) return;
    if(firstFrame) firstFrame=false;
    else if(secondFrame) {
      secondFrame=false;
      tileInc();
    }
    setupCamera();
  }

  // post() handles tile update and image saving.
  // It should be called at the very end of draw(), after any drawing.
  public void post() {
    // If first or second frame, don't update or save.
    if(firstFrame||secondFrame|| (!isTiling)) return;

    // Find image ID from reverse row order
    int imgid=tileImgCnt%tileNum+
	  (tileNum-tileImgCnt/tileNum-1)*tileNum;
    int idx=(imgid%tileNum);
    int idy=(imgid/tileNum);

    // Get current image from sketch and draw it into buffer
    p.loadPixels();
    tileImg.set(idx*p.width, idy*p.height, p.g);

    // Increment tile index
    tileImgCnt++;
    perc=100*((float)tileImgCnt/(float)tileNumSq);
    if(perc-percMilestone> 5 || perc>99) {
      p.println(p.nf(perc,3,2)+"% completed. "+tileImgCnt+
	    "/"+tileNumSq+" images saved.");
      percMilestone=perc;
    }

    if(tileImgCnt==tileNumSq) tileFinish();
    else tileInc();
  }

  public boolean checkStatus() {
    return isTiling;
  }

  // tileFinish() handles saving of the tiled image
  public void tileFinish() {
    isTiling=false;

    restoreCamera();

    // save large image to TGA
    tileFilename+="_"+(p.width*tileNum)+"x"+
            (p.height*tileNum)+tileFileExt;
    p.println("Save: "+
      tileFilename.substring(
        tileFilename.lastIndexOf(java.io.File.separator)+1));
    tileImg.save(tileFilename);
    p.println("Done tiling.n");

    // clear buffer for garbage collection
    tileImg=null;
    done=true;
  }

  // Increment tile coordinates
  public void tileInc() {
    if(!isTiling) {
      isTiling=true;
      firstFrame=true;
      secondFrame=true;
      tileImgCnt=0;
    } else {
      if(tileX==tileNum-1) {
        tileX=0;
        tileY=(tileY+1)%tileNum;
      } else
        tileX++;
    }
  }

  // set up camera correctly for the current tile
  public void setupCamera() {
    p.camera(width/2.0f, height/2.0f, cameraZ,
      width/2.0f, height/2.0f, 0, 0, 1, 0);

    if(isTiling) {
      float mod=1f/10f;
      p.frustum(width*((float)tileX/(float)tileNum-.5f)*mod,
        width*((tileX+1)/(float)tileNum-.5f)*mod,
        height*((float)tileY/(float)tileNum-.5f)*mod,
        height*((tileY+1)/(float)tileNum-.5f)*mod,
        cameraZ*mod, 10000);
    }

  }

  // restore camera once tiling is done
  public void restoreCamera() {
    float mod=1f/10f;
    p.camera(width/2.0f, height/2.0f, cameraZ,
      width/2.0f, height/2.0f, 0, 0, 1, 0);
    p.frustum(-(width/2)*mod, (width/2)*mod,
      -(height/2)*mod, (height/2)*mod,
      cameraZ*mod, 10000);
  }

  // checks free memory and gives a suggestion for maximum tile
  // resolution. It should work well in most cases, I've been able
  // to generate 20k x 20k pixel images with 1.5 GB RAM allocated.
  public int getMaxTiles(int width) {

    // get an instance of java.lang.Runtime, force garbage collection
    java.lang.Runtime runtime=java.lang.Runtime.getRuntime();
    runtime.gc();

    // calculate free memory for ARGB (4 byte) data, giving some slack
    // to out of memory crashes.
    int num=(int)(Math.sqrt(
      (float)(runtime.freeMemory()/4)*0.925f))/width;
    p.println(((float)runtime.freeMemory()/(1024*1024))+"/"+
      ((float)runtime.totalMemory()/(1024*1024)));

    // warn if low memory
    if(num==1) {
      p.println("Memory is low. Consider increasing memory.");
      num=2;
    }

    return num;
  }

  // strip extension from filename
  String noExt(String name) {
    int last=name.lastIndexOf(".");
    if(last>0)
      return name.substring(0, last);

    return name;
  }
}</pre>
<div class="mediumtitle">Source code &#8211;  aTileSaverSimpleTest.pde</div>
<pre name="code" class="java">// aTileSaverSimpleTest.pde - v0.1 2007.0325
// Marius Watz - http://workshop.evolutionzone.com
//
// Basic demo of the aTileSaver class.

import processing.opengl.*;

aTileSaver tiler;

void setup() {
  size(500,500, OPENGL);
  noStroke();
  tiler=new aTileSaver(this);
}

public void draw() {
  if(tiler==null) return; // Not initialized

  // call aTileSaver.pre() to prepare frame and setup camera if it exists.
  tiler.pre();

  smooth();
  background(0,50,0);
  lights();

  translate(width/2,height/2);
  rotateY(PI/4);
  rotateX(PI/4);
  scale(8);
  fill(240,255,0,220);
  box(10,50,10);
  fill(150,255,0,220);
  box(50,10,10);
  fill(255,150,0,220);
  box(10,10,50);

  // call aTileSaver.post() to update tiles if tiler is active
  tiler.post();
}

// Saves tiled imaged when 't' is pressed
public void keyPressed() {
  if(key=='t') tiler.init("Simple"+nf(frameCount,5),5);
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://workshop.evolutionzone.com/2007/03/24/code-tilesaverpde/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
		<item>
		<title>Library: Mersenne Twister (pseudorandom number generator)</title>
		<link>http://workshop.evolutionzone.com/2006/05/16/random-number-generator-mersenne-twister/</link>
		<comments>http://workshop.evolutionzone.com/2006/05/16/random-number-generator-mersenne-twister/#comments</comments>
		<pubDate>Tue, 16 May 2006 08:54:25 +0000</pubDate>
		<dc:creator>marius watz</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Libraries]]></category>
		<category><![CDATA[Processing / Java]]></category>

		<guid isPermaLink="false">http://workshop.evolutionzone.com/2006/05/16/random-number-generator-mersenne-twister/</guid>
		<description><![CDATA[Update 17 Jan 2008: This library is not available at the moment at the request of Sean Luke, who along with Michael Lecuyer were the original author of the Mersenne Twister code used in the library. In packaging the library for use with Processing I carelessly removed the copyright and license information from the original [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update 17 Jan 2008: This library is not available at the moment at the request of Sean Luke, who along with Michael Lecuyer were the original author of the Mersenne Twister code used in the library. In packaging the library for use with Processing I carelessly removed the copyright and license information from the original file, thereby falsely giving the impression that I had written the code myself.</strong></p>
<p><strong>I&#8217;m hoping to resolve the issue and provide the library in a different form in the near future.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://workshop.evolutionzone.com/2006/05/16/random-number-generator-mersenne-twister/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
