<?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>/dev/stu &#187; processing</title>
	<atom:link href="http://www.stuartaxon.com/tag/processing/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stuartaxon.com</link>
	<description>Adding LOC to the web.</description>
	<lastBuildDate>Mon, 09 Jan 2012 18:11:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Processing with Jython and Nodebox/Shoebot libraries</title>
		<link>http://www.stuartaxon.com/2010/02/10/processing-with-jython-and-nodeboxshoebot-libraries/</link>
		<comments>http://www.stuartaxon.com/2010/02/10/processing-with-jython-and-nodeboxshoebot-libraries/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 22:44:21 +0000</pubDate>
		<dc:creator>stu</dc:creator>
				<category><![CDATA[projects]]></category>
		<category><![CDATA[nodebox]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[shoebot]]></category>

		<guid isPermaLink="false">http://www.stuartaxon.com/?p=234</guid>
		<description><![CDATA[Update: 26/April/2010 Problems I was having with incomplete images have been fixed in the current version of the web library, available in shoebots mecurial repository. Using Processing from Jython is a promising idea, so I took the base from this post on backspaces.net where they explained how to use Jython and built on it a [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Update: 26/April/2010</p>
<p>Problems I was having with incomplete images have been fixed in the current version of the web library, available in shoebots mecurial repository.</p></blockquote>
<p>Using <a href="http://processing.org/">Processing</a> from <a href="http://www.jython.org">Jython</a> is a promising idea, so I took the base from this post on <a href="http://backspaces.net/30/processing-with-jython/">backspaces.net</a> where they explained how to use Jython and built on it a little.</p>
<p>This is great as Shoebot/Nodebox have great libraries for data manipulation, while processing is more focused on graphics.</p>
<p><a href="http://www.stuartaxon.com/wp-content/uploads/2010/02/slowcessing.png"><img class="alignnone size-medium wp-image-235" title="slowcessing" src="http://www.stuartaxon.com/wp-content/uploads/2010/02/slowcessing-300x203.png" alt="" width="300" height="203" /></a></p>
<p>The result is the attached Netbeans project which demonstrates using the nodebox web library and  drawing with processing.</p>
<h2>Slowcessing</h2>
<p>The glue code is in slowcessing.py</p>
<p>Theres a special version of PApplet (PJApplet), and &#8216;pj_frame&#8217; which can put this in a JFrame.</p>
<p>The other method is &#8216;shoebot_imports&#8217; adds the shoebot imports to the library path</p>
<p>In case anybody doesn&#8217;t want to download the whole project, heres the code:</p>
<p>imagestrip.py</p>
<pre class="brush:python">from slowcessing import PJApplet, pj_frame, shoebot_imports
from processing.opengl import *

shoebot_imports()
import web
import thread

class ImageQueue(list):
    """
    Download images in the background and add them to a list
    """
    def __init__(self, search, size):
        list.__init__(self)
        self._search = search
        self._image_size = size
        thread.start_new_thread(self._get_images, ())

    def _image_downloaded(self, path):
        p = PJApplet()
        self.append(p.loadImage(path))

    def _get_images(self):
        for image in self._search:
            image.download(self._image_size, asynchronous=False)
            self._image_downloaded(image.path)

class WebTest (PJApplet):
  def setup(self):
    self.size(400, 400, self.P3D)
    self.images = ImageQueue(web.morguefile.search("sweets", max=1), size='small')

  def draw(self):
    self.background(0);
    y = (self.height * 0.2) - self.mouseY * (len(self.images) * 0.58)
    for image in self.images:
        self.image(image, 20, y)
        y += image.height

if __name__ == '__main__':
    pj_frame(WebTest)
</pre>
<p>slowcessing.py</p>
<pre class="brush:python">from javax.swing import JFrame

from processing.core import PApplet

class PJApplet(PApplet):
  # rqd due to PApplet's using frameRate and frameRate(n) etc.
  def getField(self, name):
      return PApplet.getDeclaredField(name).get(self)

def pj_frame(pj_applet, **kwargs):
    from time import sleep

    frame = JFrame(kwargs.get('title', 'Slowcessing'))
    frame.defaultCloseOperation = kwargs.get('defaultCloseOperation', JFrame.EXIT_ON_CLOSE)
    frame.resizable = kwargs.get('resizable', False)

    panel = pj_applet()
    frame.add(panel)
    panel.init()

    while panel.defaultSize and not panel.finished:
        sleep(0.5)

    frame.pack()
    frame.visible = 1

    return frame

def shoebot_imports():
    """
    Allow import of the shoebot libraries
    """
    ##APP = 'shoebot'
    import sys
    DIR = sys.prefix + '/share/shoebot/locale'
    ##locale.setlocale(locale.LC_ALL, '')
    ##gettext.bindtextdomain(APP, DIR)
    ###gettext.bindtextdomain(APP)
    ##gettext.textdomain(APP)
    ##_ = gettext.gettext

    LIB_DIR = sys.prefix + '/share/shoebot/lib'
    sys.path.append(LIB_DIR)<span style="text-decoration: line-through;">
</span></pre>
<h2>Problems</h2>
<p>There are some things I couldn&#8217;t work :</p>
<p><span style="text-decoration: line-through;">The callback to say that images have been downloaded happens before the whole file is available, for this reason there are grey parts on the images on the first run.</span></p>
<h3>Nodebox web&#8230;</h3>
<p><span style="text-decoration: line-through;">While I did manage to fix things to get this working in Jython and get Morguefile working, I had a lot of trouble understanding what was going on here.</span></p>
<p>Cheers to Tom De Smedt for fixing these the areas of nodebox-web that I couldn&#8217;t <img src='http://www.stuartaxon.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>Processing&#8230;</h3>
<p>Some parts of PApplet to do with image loading seem to be static, which may also explain problems I was getting with reentrancy.</p>
<h2>Download</h2>
<p>If you want to have a go, you&#8217;ll need to:</p>
<p>Install Netbeans 6.8</p>
<p>Install <a href="http://www.jython.org">Jython</a> (2.5 or higher) by installing the Netbeans python module</p>
<p>Add python to the path (if using Netbeans it&#8217;s copy is where Netbeans is installed).</p>
<p>Get nodebox-web by downloading <a href="https://code.goto10.org/hg/shoebot">shoebot</a> and install it with:</p>
<pre>jython setup.py install</pre>
<p>In Netbeans, add all the jars in the processing\lib folder to the Jython classpath, and opengl\library\opengl.jar<br />
<a href="http://www.stuartaxon.com/wp-content/uploads/2010/02/jythonprocessing.png"><img class="alignnone size-medium wp-image-236" title="jythonprocessing" src="http://www.stuartaxon.com/wp-content/uploads/2010/02/jythonprocessing-300x219.png" alt="" width="300" height="219" /></a></p>
<p>Download the <a href="http://www.stuartaxon.com/wp-content/uploads/2010/02/PythonOnProcessing.zip">PythonOnProcessing</a> (tested on Netbeans 6.8)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stuartaxon.com/2010/02/10/processing-with-jython-and-nodeboxshoebot-libraries/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Noodleglue &#8211; found!</title>
		<link>http://www.stuartaxon.com/2008/10/01/noodleglue-found/</link>
		<comments>http://www.stuartaxon.com/2008/10/01/noodleglue-found/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 12:13:38 +0000</pubDate>
		<dc:creator>stu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[blender]]></category>
		<category><![CDATA[blender3d]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[gtk]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[java-gnome]]></category>
		<category><![CDATA[language bindings]]></category>
		<category><![CDATA[noodleglue]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[processing.org]]></category>

		<guid isPermaLink="false">http://www.stuartaxon.com/?p=112</guid>
		<description><![CDATA[Download noodleglue here: I had some trouble finding it. - Maybe can be used to link processing and Blender.]]></description>
			<content:encoded><![CDATA[<p>For the last few days I&#8217;ve been looking for a project called NoodleGlue.  I got interested when I wanted to look into generating java wrappings for the <a href="http://verse.blender.org/">Verse</a> library.</p>
<p><strong>If you just want to download Noodleglue skip to the end of the article</strong>.</p>
<p>Verse is a network protocol that lets 3d applications talk to each other in realtime, being developed by the Blender foundation.  I was wondering how difficult it would be to link the ease of use of <a href="http://processing.org">processing</a> with the power of Blender.</p>
<p><span id="more-112"></span></p>
<p>Processing being a simplified java, I started to look at ways of generating java bindings.</p>
<p>I knew that GTK had switched to generating their java bindings automatically, so started looking at technologies to do this, immediately I found out about noodleglue which seemed to fit the bill.</p>
<p>Slight problem &#8211; the site was down and the developers nowhere to be seen, after much searching I realised I should be looking for something written in C/C++ not java, searched for NoodleGlue.tar.gz and &#8216;bing!&#8217; there it is on one persons website.</p>
<p>I&#8217;m uploading it here, although I should probably put it on google code as well.</p>
<p><a href="http://www.stuartaxon.com/files/NoodleGlue.tar.gz">NoodleGlue.tar.gz</a></p>
<p><a href="http://www.stuartaxon.com/files/NoodleGlueGenerator.jar">NoodleGlueGenerator.jar</a></p>
<p><a title="Archive of Noodleglue.org" href="http://web.archive.org/web/20070205204525rn_1/www.noodleglue.org/noodleglue/noodleglue.html">Snapshot of noodleglue.org</a> in in the internet wayback machine.</p>
<p>I must also mention <a href="http://code.google.com/p/cibyl/">Cibyl</a>, a project for compiling C to java, it worked best for me in linux&#8230; currently a bit of a pain to setup but an interesting project nonetheless.</p>
<p><a href="http://code.google.com/p/cibyl/">Cibyl Project</a></p>
<p>Eplilogue &#8211; There was a version on the internet wayback machine the whole time, not sure why I didn&#8217;t check, however the version I&#8217;ve found is newer &#8211; at least 18/Apr/2007.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stuartaxon.com/2008/10/01/noodleglue-found/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

