{"id":533,"date":"2014-08-25T15:39:50","date_gmt":"2014-08-25T22:39:50","guid":{"rendered":"http:\/\/www.imaginary-institute.com\/blog\/?p=533"},"modified":"2014-08-26T09:15:45","modified_gmt":"2014-08-26T16:15:45","slug":"making-a-processing-library","status":"publish","type":"post","link":"https:\/\/www.imaginary-institute.com\/blog\/2014\/08\/25\/making-a-processing-library\/","title":{"rendered":"Making A Processing Library"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.imaginary-institute.com\/blog\/wp-content\/uploads\/2014\/08\/AUlogo.png\" alt=\"AUlogo\" width=\"155\" height=\"154\" class=\"alignright size-full wp-image-549\" srcset=\"https:\/\/www.imaginary-institute.com\/blog\/wp-content\/uploads\/2014\/08\/AUlogo.png 226w, https:\/\/www.imaginary-institute.com\/blog\/wp-content\/uploads\/2014\/08\/AUlogo-150x150.png 150w\" sizes=\"auto, (max-width: 155px) 100vw, 155px\" \/>While programming in <a href=\"http:\/\/www.processing.org\" target=\"_blank\">Processing<\/a>, I&#8217;ve developed about a dozen useful tools for everyday work. I&#8217;ve packaged these up in a library which I call AU, for &#8220;Andrew&#8217;s Utilities.&#8221; I&#8217;ll be sharing it as soon as I finish the documentation. Although the official Processing wiki has a <a href=\"http:\/\/wiki.processing.org\/w\/Create_Libraries\" target=\"_blank\">nice walkthrough<\/a> for how to make a library, there are a few things that I spent considerable time figuring out. Here&#8217;s what I learned, to save you the effort.<br \/>\n<!--more--><\/p>\n<p><strong>First<\/strong>, Processing libraries are not written in Processing! They&#8217;re Java. It&#8217;s easy enough to convert from Processing to Java, but if you relied a lot on some of Processing&#8217;s built-in routines (like <em>map<\/em> or <em>constrain<\/em>) you&#8217;ll need to touch up your code, either by calling those routines through a pointer back to your sketch, or by re-implementing them locally. You&#8217;ll find a lot of the numerical routines (like <em>sin<\/em> and <em>sqrt<\/em>) available in Java&#8217;s Math library.<\/p>\n<p><strong>Second<\/strong>, I found the template approach described <a href=\"https:\/\/github.com\/processing\/processing-library-template\" target=\"_blank\">here<\/a> to be by far the easiest way to go. I used their <em>Option B: Download Package<\/em> and it worked great.<\/p>\n<p><strong>Third<\/strong>, Step 2 under &#8220;Set Up and Compile&#8221; wants you to &#8220;Open the resources folder inside of your Java project.&#8221; I spent a good 20 minutes looking for this. It&#8217;s actually inside your template! Open the template folder and there&#8217;s your resources folder.<\/p>\n<p><strong>Fourth<\/strong>, while editing <em>build.properties<\/em> and setting up all the paths for your Processing installation, you can set your <em>classpath.local.location<\/em> variable in two places (as of template 0.5.3,, lines 32 and 41). Only use one, and leave the other commented out.<\/p>\n<p><strong>Fifth<\/strong>, you&#8217;ll see a setting for <em>ant.description<\/em>. Don&#8217;t change it; the default works fine.<\/p>\n<p><strong>Sixth<\/strong>, when it&#8217;s time to compile, you want to press the small white triangle in a green circle at the top of the Ant pane. To enable this button, make sure that you have selected the file in the pane (this is the one that was made when you dragged <em>build.xml<\/em> into the pane, and is probably named <em>ProcessingLibs<\/em>).<\/p>\n<p>The rest is pretty straightforward if you follow their instructions. The hardest part was making all the little changes from Processing to Java (such as adding the keyword <em>public<\/em> to things). Their example code calls the parent sketch <em>myParent<\/em>, but I renamed this to <em>theSketch<\/em> because I think that&#8217;s much more specific and informative.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While programming in Processing, I&#8217;ve developed about a dozen useful tools for everyday work. I&#8217;ve packaged these up in a library which I call AU, for &#8220;Andrew&#8217;s Utilities.&#8221; I&#8217;ll be sharing it as soon as I finish the documentation. Although the official Processing wiki has a nice walkthrough for how to make a library, there [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-533","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.imaginary-institute.com\/blog\/wp-json\/wp\/v2\/posts\/533","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.imaginary-institute.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.imaginary-institute.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.imaginary-institute.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.imaginary-institute.com\/blog\/wp-json\/wp\/v2\/comments?post=533"}],"version-history":[{"count":15,"href":"https:\/\/www.imaginary-institute.com\/blog\/wp-json\/wp\/v2\/posts\/533\/revisions"}],"predecessor-version":[{"id":552,"href":"https:\/\/www.imaginary-institute.com\/blog\/wp-json\/wp\/v2\/posts\/533\/revisions\/552"}],"wp:attachment":[{"href":"https:\/\/www.imaginary-institute.com\/blog\/wp-json\/wp\/v2\/media?parent=533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.imaginary-institute.com\/blog\/wp-json\/wp\/v2\/categories?post=533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.imaginary-institute.com\/blog\/wp-json\/wp\/v2\/tags?post=533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}