<?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>Caroline Brown &#187; Programming A to Z</title>
	<atom:link href="http://carolineabrown.com/category/programming-a-to-z/feed/" rel="self" type="application/rss+xml" />
	<link>http://carolineabrown.com</link>
	<description></description>
	<lastBuildDate>Fri, 07 May 2010 15:40:22 +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>Bestiary at the ITP Spring Show</title>
		<link>http://carolineabrown.com/2009/05/bestiary-at-the-itp-spring-show/</link>
		<comments>http://carolineabrown.com/2009/05/bestiary-at-the-itp-spring-show/#comments</comments>
		<pubDate>Mon, 11 May 2009 13:21:52 +0000</pubDate>
		<dc:creator>Caroline</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[Programming A to Z]]></category>
		<category><![CDATA[bestiary]]></category>

		<guid isPermaLink="false">http://carolineabrown.com/?p=852</guid>
		<description><![CDATA[Bryan and I are having a great time showing Bestiary, our projection-based book of randomly generated animals, at the ITP Spring Show. Here&#8217;s a quick video we shot this morning during set up:

Bestiary from Caroline Brown on Vimeo.
Yesterday was day one of the show, and we got lots of great feedback on the project. Today [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_856" class="wp-caption alignnone" style="width: 320px"><a rel="attachment wp-att-856" href="http://carolineabrown.com/2009/05/bestiary-at-the-itp-spring-show/3520751405_e3e80903f9_b1/"><img class="size-thumbnail wp-image-856" title="3520751405_e3e80903f9_b1" src="http://carolineabrown.com/blog/wp-content/uploads/2009/05/3520751405_e3e80903f9_b1-310x150.jpg" alt="Bestiary" width="310" height="150" /></a><p class="wp-caption-text">Bestiary</p></div>
<p><a title="Bryan Lence" href="http://blence.com/">Bryan</a> and I are having a great time showing <a title="Bestiary" href="http://bestiary.blence.com/">Bestiary</a>, our projection-based book of randomly generated animals, at the <a title="ITP Spring Show" href="http://itp.nyu.edu/shows/spring2009/">ITP Spring Show</a>. Here&#8217;s a quick video we shot this morning during set up:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="data" value="http://vimeo.com/moogaloop.swf?clip_id=4596092&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=4596092&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=4596092&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true" data="http://vimeo.com/moogaloop.swf?clip_id=4596092&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1"></embed></object></p>
<p><a href="http://vimeo.com/4596092">Bestiary</a> from <a href="http://vimeo.com/user1739018">Caroline Brown</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>Yesterday was day one of the show, and we got lots of great feedback on the project. Today is the second and last day of the show, so come see us! The floor is open to the public 5-9pm.</p>
<p>Photo by <a title="giladlotan on flickr" href="http://www.flickr.com/photos/giladlotan/3520751405/">Gilad Lotan</a></p>
]]></content:encoded>
			<wfw:commentRss>http://carolineabrown.com/2009/05/bestiary-at-the-itp-spring-show/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bestiary Sketch (aka Menagerie, Round 3)</title>
		<link>http://carolineabrown.com/2009/04/bestiary-sketch-aka-menagerie-round-3/</link>
		<comments>http://carolineabrown.com/2009/04/bestiary-sketch-aka-menagerie-round-3/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 00:12:18 +0000</pubDate>
		<dc:creator>Caroline</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[Programming A to Z]]></category>

		<guid isPermaLink="false">http://carolineabrown.com/?p=839</guid>
		<description><![CDATA[Bryan Lence and I revisited our A to Z midterm to create another version of the creature maker. We kept our foundation of the context-free grammar, but we altered our template for the images. Instead of layering transparencies in set positions, we anchored each image to a specific variable associated with another image (i.e. the [...]]]></description>
			<content:encoded><![CDATA[<p><a title="blence.com" href="http://blence.com/">Bryan Lence</a> and I revisited our <a title="a to z midterm" href="http://carolineabrown.com/2009/03/menagerie-2-huegs-blags/">A to Z midterm</a> to create another version of the creature maker. We kept our foundation of the context-free grammar, but we altered our template for the images. Instead of layering transparencies in set positions, we anchored each image to a specific variable associated with another image (i.e. the head of an animal would be anchored to a specific x-y coordinate on a body). This gave us more flexibility to create more interesting creatures, but it was a bit of a mess:</p>
<div id="attachment_840" class="wp-caption alignnone" style="width: 320px"><a href="http://carolineabrown.com/blog/wp-content/uploads/2009/04/picture-5.png" rel="shadowbox[post-839];player=img;"><img class="size-thumbnail wp-image-840" title="picture-5" src="http://carolineabrown.com/blog/wp-content/uploads/2009/04/picture-5-310x150.png" alt="Unholy Mess of a Processing Sketch" width="310" height="150" /></a><p class="wp-caption-text">Unholy Mess of a Processing Sketch</p></div>
<p>We reworked the program to display each animal part as a set of vectors, allowing us to be a little more creative with assigning positions for various parts. We&#8217;re  placing a set of circles to overlap as joints in each composite. Our working drawings look like this:</p>
<div id="attachment_848" class="wp-caption alignnone" style="width: 320px"><a href="http://carolineabrown.com/blog/wp-content/uploads/2009/04/picture-7.png" rel="shadowbox[post-839];player=img;"><img class="size-thumbnail wp-image-848" title="horsebodytest" src="http://carolineabrown.com/blog/wp-content/uploads/2009/04/picture-7-310x150.png" alt="Horse Body Working Sketch with Joints" width="310" height="150" /></a><p class="wp-caption-text">Horse Body Working Sketch with Joints</p></div>
<p>In an effort to provide a more engaging user experience, we&#8217;ve also moved from a mouse-activated screen display to a physical installation. Our aim now is to project the creatures onto the blank pages of a book, creating a new animal each time a page is turned, and using QR codes to facilitate recall of previous pages&#8217; animals. The installation will be on display at the <a title="ITP Spring Show" href="http://itp.nyu.edu/sigs/news/itp-spring-show-2009/">ITP Spring Show</a>. We&#8217;re getting a little closer to the aesthetic we&#8217;re looking for, although I&#8217;m still hunting for the right font and tweaking the drawings:</p>
<div id="attachment_847" class="wp-caption alignnone" style="width: 320px"><a href="http://carolineabrown.com/blog/wp-content/uploads/2009/04/picture-6.png" rel="shadowbox[post-839];player=img;"><img class="size-thumbnail wp-image-847" title="mantilloboon" src="http://carolineabrown.com/blog/wp-content/uploads/2009/04/picture-6-310x150.png" alt="Mantilloboon" width="310" height="150" /></a><p class="wp-caption-text">Mantidilloboon</p></div>
<p>Here&#8217;s today&#8217;s working code. It will go through some more changes tomorrow since here our samples are hard coded, rather than drawn from our grammar file:</p>
<blockquote><p>PShape body;<br />
PShape part;<br />
//String bodyString = &#8220;horse2.svg&#8221;;<br />
String bodyString =&#8221;bluejay2body.svg&#8221;;<br />
//PShape frontLegs;<br />
//PShape rearLegs;<br />
//PShape head;</p>
<p>String[] bodyParts = {<br />
&#8220;horse2head.svg&#8221;, &#8220;bluejay2frontlegs.svg&#8221;, &#8220;horse2rearlegs.svg&#8221;, &#8220;trans.svg&#8221;};</p>
<p>int cx;<br />
int cy;<br />
int bcx;<br />
int bcy;</p>
<p>void setup() {<br />
size(800,800);<br />
body = loadShape(bodyString);<br />
//head = loadShape(&#8220;horse2head.svg&#8221;);<br />
//frontLegs = loadShape(&#8220;horse2frontlegs.svg&#8221;);<br />
//rearLegs = loadShape(&#8220;horse2rearlegs.svg&#8221;);</p>
<p>smooth();<br />
noLoop();</p>
<p>}</p>
<p>void draw() {<br />
shape(body);<br />
assemble(bodyString);<br />
//translate(cx, cy);</p>
<p>//getBodyPoint(&#8220;horse2head.svg&#8221;);<br />
//shape(head, -bcx, -bcy);<br />
}</p>
<p>int findCoord(String working_, String lookingFor_) {<br />
String lookingFor = lookingFor_;<br />
String working = working_;<br />
int start = working.indexOf(lookingFor);<br />
int end = working.indexOf(&#8221; &#8220;, start);<br />
String coord = working.substring(start, end);<br />
coord = coord.replace(&#8220;cx=&#8221;", &#8220;&#8221;);<br />
coord = coord.replace(&#8220;cy=&#8221;", &#8220;&#8221;);<br />
coord = coord.replaceAll(&#8220;&#8221;", &#8220;&#8221;);<br />
return int(coord);<br />
}</p>
<p>void assemble(String svgFile_) {<br />
String svgFile = svgFile_;<br />
XMLElement xml = new XMLElement(this, svgFile);<br />
XMLElement[] desc = xml.getChildren(&#8220;g/g/circle&#8221;);<br />
println(desc);</p>
<p>for (int i=0; i&lt;desc.length; i++) {<br />
String working = desc[i].toString();<br />
cx = findCoord(working, &#8220;cx&#8221;);<br />
cy = findCoord(working, &#8220;cy&#8221;);</p>
<p>translate(cx, cy);<br />
getBodyPoint(bodyParts[i]);<br />
println(bodyParts[i]);<br />
part = loadShape(bodyParts[i]);<br />
shape(part, -bcx, -bcy);<br />
translate(-cx, -cy);<br />
}</p>
<p>}</p>
<p>void getBodyPoint(String svgFile_) {<br />
String svgFile = svgFile_;<br />
XMLElement xml = new XMLElement(this, svgFile);<br />
XMLElement[] desc = xml.getChildren(&#8220;g/g/circle&#8221;);<br />
println(desc);</p>
<p>for (int i=0; i&lt;desc.length; i++) {<br />
String working = desc[i].toString();<br />
bcx = findCoord(working, &#8220;cx&#8221;);<br />
bcy = findCoord(working, &#8220;cy&#8221;);</p>
<p>println (&#8220;bcx: &#8221; + bcx + &#8221; bcy: &#8221; + bcy);<br />
}<br />
}</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://carolineabrown.com/2009/04/bestiary-sketch-aka-menagerie-round-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Artists&#8217; Materials via the Brooklyn Museum API</title>
		<link>http://carolineabrown.com/2009/04/artists-materials-via-the-brooklyn-museum-api/</link>
		<comments>http://carolineabrown.com/2009/04/artists-materials-via-the-brooklyn-museum-api/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 15:18:50 +0000</pubDate>
		<dc:creator>Caroline</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[Programming A to Z]]></category>

		<guid isPermaLink="false">http://carolineabrown.com/?p=776</guid>
		<description><![CDATA[For Programming A to Z last week, Adam asked us to get some XML from a web service and use it as input into one of our previous programs. I chose to work with the Brooklyn Museum&#8217;s API. In looking through an XML sample from their site, I was intrigued by the variety of artists&#8217; [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_777" class="wp-caption alignnone" style="width: 320px"><a href="http://carolineabrown.com/blog/wp-content/uploads/2009/04/brookmuse.png" rel="shadowbox[post-776];player=img;"><img class="size-thumbnail wp-image-777" title="Brooklyn Museum" src="http://carolineabrown.com/blog/wp-content/uploads/2009/04/brookmuse-310x150.png" alt="From the Brooklyn Museum Collection" width="310" height="150" /></a><p class="wp-caption-text">From the Brooklyn Museum Collection</p></div>
<p>For <a title="Programming A to Z" href="http://www.decontextualize.com/teaching/a2z/a-significant-markup/">Programming A to Z</a> last week, Adam asked us to get some XML from a web service and use it as input into one of our previous programs. I chose to work with the <a title="Brooklyn Museum API" href="http://www.brooklynmuseum.org/opencollection/api/">Brooklyn Museum&#8217;s API</a>. In looking through an XML sample from their site, I was intrigued by the variety of artists&#8217; materials listed under each object&#8217;s &#8220;medium&#8221; attribute. When I look at art in museum&#8217;s I&#8217;m often left guessing by the signage, wondering what process the artist used in order to get a material to behave in a specific way. So, I thought it would be interesting to reduce a description of a work to the media used to create it, then compile a new work out of images of those media (e.g. a work made of glass and walnut transformed and remade with images tagged &#8220;glass&#8221; and &#8220;walnut&#8221;). My code for getting the artist and materials data out of the XML returned by a keyword search is here:</p>
<blockquote><p>import org.dom4j.Document;<br />
import org.dom4j.DocumentFactory;<br />
import org.dom4j.io.SAXReader;<br />
import org.dom4j.Element;<br />
import java.util.List;<br />
import java.util.HashMap;<br />
import java.net.URLEncoder;</p>
<p>public class BrookMuse {</p>
<p>public static void main(String[] args) throws Exception {</p>
<p>String keyword = args[0];</p>
<p>SAXReader reader = new SAXReader();<br />
EasyHTTPGet getter = new EasyHTTPGet(<br />
&#8220;http://www.brooklynmuseum.org/opencollection/api/?method=collection.search&amp;version=1&amp;api_key=[API KEY]&amp;keyword=&#8221; + keyword<br />
);</p>
<p>Document document = reader.read(getter.responseAsInputStream());<br />
List works = document.selectNodes(&#8220;//items/object&#8221;);</p>
<p>for (Object o: works) {<br />
Element work = (Element)o;</p>
<p>List artists = work.selectNodes(&#8220;artists/artist&#8221;);</p>
<p>if (artists.size() &gt; 0) {<br />
Element firstArtist = (Element)artists.get(0);<br />
String artist = firstArtist.attributeValue(&#8220;name&#8221;);<br />
String medium = work.attributeValue(&#8220;medium&#8221;);<br />
System.out.println(artist + &#8220;: &#8221; + medium);<br />
}</p>
<p>else{<br />
String medium = work.attributeValue(&#8220;medium&#8221;);<br />
System.out.println(&#8220;Unknown: &#8221; + medium);<br />
}<br />
}<br />
}<br />
}</p></blockquote>
<p>It returns a list that looks ike this (e.g. with search term &#8220;noguchi&#8221;):</p>
<blockquote><p>Unknown: Low fired earthenware pottery, reassembled from fragments<br />
Isamu Noguchi: Terracotta, plaster<br />
Isamu Noguchi: Glass, walnut<br />
Isamu Noguchi: Bakelite plastic</p></blockquote>
<p>Now on to gathering some images&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://carolineabrown.com/2009/04/artists-materials-via-the-brooklyn-museum-api/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>InformationOverlord</title>
		<link>http://carolineabrown.com/2009/03/informationoverlord/</link>
		<comments>http://carolineabrown.com/2009/03/informationoverlord/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 22:27:16 +0000</pubDate>
		<dc:creator>Caroline</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[Programming A to Z]]></category>

		<guid isPermaLink="false">http://carolineabrown.com/?p=640</guid>
		<description><![CDATA[Sometimes keeping up with all of the reading I&#8217;d like to do leaves me crushed by information overload, so for Programming A to Z this week I built a simple program to tell me whether or not I should bother reading a given document. Our assignment was to augment, modify, or replace one of our [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes keeping up with all of the reading I&#8217;d like to do leaves me crushed by information overload, so for Programming A to Z this week I built a simple program to tell me whether or not I should bother reading a given document. Our assignment was to augment, modify, or replace one of our in-class examples, so I modified Adam&#8217;s <a title="Bayesed and Confused" href="http://www.decontextualize.com/teaching/a2z/bayesed-and-confused/">BayesClassifier</a> program. My version of the classifier, <a title="InformationOverlord" href="http://carolineabrown.com/files/InformationOverlord.txt">InformationOverlord</a>, requires input of at least two texts; it compares the specified text to the first (one or more) texts, and advises you to read or discard the specified text based on its comparison score. For instance, if I particularly enjoyed <a title="roughing it" href="http://www.gutenberg.org/etext/3177">Mark Twain&#8217;s Roughing It</a> and was wondering if I might also like <a title="the wasteland" href="http://www.gutenberg.org/etext/1321">The Wasteland by T.S. Eliot</a> I could use InformationOverlord to make a recommendation for me:</p>
<div id="attachment_642" class="wp-caption alignnone" style="width: 630px"><a href="http://carolineabrown.com/blog/wp-content/uploads/2009/03/overlord_drivel1.png" rel="shadowbox[post-640];player=img;"><img class="size-full wp-image-642" title="overlord_drivel1" src="http://carolineabrown.com/blog/wp-content/uploads/2009/03/overlord_drivel1.png" alt="overlord_drivel1" width="620" height="82" /></a><p class="wp-caption-text">Don&#39;t bother reading this drivel.</p></div>
<p>On the other hand, if I ask it to tell me whether or not I ought to read the works of Jane Austen, based on my interest in Shakespeare&#8217;s sonnets, it tells me something different:</p>
<div id="attachment_643" class="wp-caption alignnone" style="width: 605px"><a href="http://carolineabrown.com/blog/wp-content/uploads/2009/03/overlord_readthis.png" rel="shadowbox[post-640];player=img;"><img class="size-full wp-image-643" title="overlord_readthis" src="http://carolineabrown.com/blog/wp-content/uploads/2009/03/overlord_readthis.png" alt="You should definitely read this." width="595" height="29" /></a><p class="wp-caption-text">You should definitely read this.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://carolineabrown.com/2009/03/informationoverlord/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use Desire as an Anchor</title>
		<link>http://carolineabrown.com/2009/03/use-desire-as-an-anchor/</link>
		<comments>http://carolineabrown.com/2009/03/use-desire-as-an-anchor/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 22:19:48 +0000</pubDate>
		<dc:creator>Caroline</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[Programming A to Z]]></category>

		<guid isPermaLink="false">http://carolineabrown.com/?p=613</guid>
		<description><![CDATA[Over Spring Break we had two assignments to finish for Programming A to Z. The first was to modify, augment, or create a program based on our in-class examples of context-free grammars. I originally planned to create a grammar for walking&#8211; some sort of computer-generated dérive&#8211; but the weather hasn&#8217;t been particularly conducive to walking. [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_617" class="wp-caption alignnone" style="width: 320px"><a href="http://www.rtqe.net/ObliqueStrategies/"><img class="size-thumbnail wp-image-617" title="Oblique Strategies" src="http://carolineabrown.com/blog/wp-content/uploads/2009/03/oblique_box-310x150.gif" alt="Oblique Strategies Box" width="310" height="150" /></a><p class="wp-caption-text">Oblique Strategies Box</p></div>
<p>Over Spring Break we had two assignments to finish for Programming A to Z. The first was to modify, augment, or create a program based on our <a title="context-free-as-in-speech" href="http://www.decontextualize.com/teaching/a2z/context-free-as-in-speech/">in-class examples of context-free grammars</a>. I originally planned to create a grammar for walking&#8211; some sort of computer-generated dérive&#8211; but the weather hasn&#8217;t been particularly conducive to walking. This dreary March weather has put me into a bit of a creative slump, so I decided to make something to help shake my brain up a bit: I wrote a <a href="http://carolineabrown.com/blog/wp-content/uploads/2009/03/strategy.txt">grammar</a> based on the <a title="Oblique Strategies" href="http://www.rtqe.net/ObliqueStrategies/Ed3.html">1979 edition of Brain Eno &amp; Peter Schmidt&#8217;s Oblique Strategies</a>, and I fed it to Adam&#8217;s ContextFilter. It&#8217;s a little wonky since the structures of Eno &amp; Schmidt&#8217;s instructions are so diverse, but it&#8217;s spit out a few interesting phrases so far. Here are a few of its suggestions:</p>
<blockquote><p>breathe more deeply</p>
<p>burn more often</p>
<p>disconnect from always time</p>
<p>decorate dirty disciplined things</p>
<p>consider cascades</p>
<p>build and abandon extravagant transitions</p>
<p>destroy sections</p>
<p>burn normal cascades and build first instruments</p>
<p>dirty an easement</p>
<p>don&#8217;t be frightened to display and discard</p>
<p>use desire as an anchor</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://carolineabrown.com/2009/03/use-desire-as-an-anchor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Menagerie 2: A2z Midterm Code</title>
		<link>http://carolineabrown.com/2009/03/menagerie-2-a2z-midterm-code/</link>
		<comments>http://carolineabrown.com/2009/03/menagerie-2-a2z-midterm-code/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 18:09:23 +0000</pubDate>
		<dc:creator>Caroline</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[Programming A to Z]]></category>

		<guid isPermaLink="false">http://carolineabrown.com/?p=513</guid>
		<description><![CDATA[




This is the code for the main class of our creature-maker:
import java.util.HashMap;
HashMap words = new HashMap();
String[] lines;
String oneLine;
String animalName;
PImage head;

PImage body;
PImage legs;
PFont font;
void setup() {
background(random(100, 255), random(100, 255), random(100, 255));
animalName=&#8221;";
font = loadFont(&#8220;Goudy-Bold-70.vlw&#8221;);
size(700, 700);
words.put(&#8220;horsehead.png&#8221;, &#8220;H&#8221;);
words.put(&#8220;bluejayhead.png&#8221;, &#8220;Bl&#8221;);
words.put(&#8220;staghead.png&#8221;, &#8220;St&#8221;);
words.put(&#8220;horsebody.png&#8221;, &#8220;or&#8221;);
words.put(&#8220;bluejaybody.png&#8221;, &#8220;ue&#8221;);
words.put(&#8220;stagbody.png&#8221;, &#8220;a&#8221;);
words.put(&#8220;horselegs.png&#8221;, &#8220;se&#8221;);
words.put(&#8220;bluejaylegs.png&#8221;, &#8220;jay&#8221;);
words.put(&#8220;staglegs.png&#8221;, &#8220;g&#8221;);
}
void draw() {
//puts file into contextFilter object, collectString retreives output that
//would normally be printed, [...]]]></description>
			<content:encoded><![CDATA[<div class="mceTemp">
<dl id="attachment_516" class="wp-caption alignnone" style="width: 429px;">
<dt class="wp-caption-dt"><a href="http://carolineabrown.com/blog/wp-content/uploads/2009/03/blag1.png" rel="shadowbox[post-513];player=img;"><img class="size-full wp-image-516" title="Blag" src="http://carolineabrown.com/blog/wp-content/uploads/2009/03/blag1.png" alt="Blag" width="419" height="419" /></a></dt>
</dl>
</div>
<p>This is the code for the main class of our creature-maker:</p>
<p>import java.util.HashMap;<br />
HashMap words = new HashMap();<br />
String[] lines;<br />
String oneLine;<br />
String animalName;<br />
PImage head;<br />
<span id="more-513"></span><br />
PImage body;<br />
PImage legs;<br />
PFont font;</p>
<p>void setup() {<br />
background(random(100, 255), random(100, 255), random(100, 255));</p>
<p>animalName=&#8221;";<br />
font = loadFont(&#8220;Goudy-Bold-70.vlw&#8221;);</p>
<p>size(700, 700);</p>
<p>words.put(&#8220;horsehead.png&#8221;, &#8220;H&#8221;);<br />
words.put(&#8220;bluejayhead.png&#8221;, &#8220;Bl&#8221;);<br />
words.put(&#8220;staghead.png&#8221;, &#8220;St&#8221;);<br />
words.put(&#8220;horsebody.png&#8221;, &#8220;or&#8221;);<br />
words.put(&#8220;bluejaybody.png&#8221;, &#8220;ue&#8221;);<br />
words.put(&#8220;stagbody.png&#8221;, &#8220;a&#8221;);<br />
words.put(&#8220;horselegs.png&#8221;, &#8220;se&#8221;);<br />
words.put(&#8220;bluejaylegs.png&#8221;, &#8220;jay&#8221;);<br />
words.put(&#8220;staglegs.png&#8221;, &#8220;g&#8221;);</p>
<p>}</p>
<p>void draw() {</p>
<p>//puts file into contextFilter object, collectString retreives output that<br />
//would normally be printed, puts into oneLine String<br />
oneLine = new ContextFilter().collectString(createReader(&#8220;animals.txt&#8221;));<br />
lines = oneLine.split(&#8221; &#8220;);</p>
<p>//for debugging<br />
for (int i = 0; i &lt; lines.length; i++) {<br />
String t = lines[i];<br />
if (words.containsKey(t)) {<br />
animalName = animalName + words.get(t);<br />
}<br />
}</p>
<p>//we&#8217;ll have<br />
head = loadImage(lines[0]);<br />
body = loadImage(lines[1]);<br />
legs = loadImage(lines[2]);</p>
<p>image(head, 0, 0);<br />
image(body, 0, 0);<br />
image(legs, 0, 0);</p>
<p>println(animalName);<br />
textFont(font);<br />
textAlign(CENTER);<br />
fill(0);<br />
text(animalName, width/2, 620);</p>
<p>noLoop();<br />
}</p>
<p>void mousePressed() {<br />
background(random(100, 255), random(100, 255), random(100, 255));<br />
animalName=&#8221;";<br />
redraw();<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://carolineabrown.com/2009/03/menagerie-2-a2z-midterm-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Menagerie 2: A2Z Midterm</title>
		<link>http://carolineabrown.com/2009/03/menagerie-2-huegs-blags/</link>
		<comments>http://carolineabrown.com/2009/03/menagerie-2-huegs-blags/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 17:46:04 +0000</pubDate>
		<dc:creator>Caroline</dc:creator>
				<category><![CDATA[Animals People and Those In Between]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[Programming A to Z]]></category>

		<guid isPermaLink="false">http://carolineabrown.com/?p=480</guid>
		<description><![CDATA[Bryan Lence and I developed a creature-maker for our Programming A to Z midterm. We based the program on a simple context-free grammar defining our animal structures, and applied that grammar to a Processing sketch based on Adam Parrish&#8217;s ContextFilter. Each click of the mouse while the sketch is running assembles a new animal assembled [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_490" class="wp-caption alignnone" style="width: 451px"><a href="http://carolineabrown.com/blog/wp-content/uploads/2009/03/hueg1.png" rel="shadowbox[post-480];player=img;"><img class="size-full wp-image-490" title="Hueg" src="http://carolineabrown.com/blog/wp-content/uploads/2009/03/hueg1.png" alt="Hueg (large)" width="441" height="443" /></a><p class="wp-caption-text">Hueg</p></div>
<p><a title="Bryan Lence" href="http://blence.com/">Bryan Lence</a> and I developed a creature-maker for our <a title="a2z" href="http://a2z.decontextualize.com/">Programming A to Z</a> midterm. We based the program on a simple <a title="animal grammar" href="http://carolineabrown.com/files/animals.txt">context-free grammar</a> defining our animal structures, and applied that grammar to a Processing sketch based on Adam Parrish&#8217;s <a title="conextfilter" href="http://www.decontextualize.com/teaching/a2z/context-free-as-in-speech/">ContextFilter</a>. Each click of the mouse while the sketch is running assembles a new animal assembled from parts of a horse, a stag, and a blue jay that we created using Photoshop and Illustrator.</p>
]]></content:encoded>
			<wfw:commentRss>http://carolineabrown.com/2009/03/menagerie-2-huegs-blags/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Markov&#8217;s Menagerie</title>
		<link>http://carolineabrown.com/2009/02/markovs-menagerie/</link>
		<comments>http://carolineabrown.com/2009/02/markovs-menagerie/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 21:39:49 +0000</pubDate>
		<dc:creator>Caroline</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[Programming A to Z]]></category>

		<guid isPermaLink="false">http://carolineabrown.com/blog/?p=445</guid>
		<description><![CDATA[
This week&#8217;s assignment for Programming A to Z was to modify or augment our in-class example of a Markov chain. Somehow during class I got the idea to make a program that would create imaginary creatures by analyzing n-grams from a list of animals. I created a list of creatures from a medieval bestiary, and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://carolineabrown.com/blog/wp-content/uploads/2009/02/the-unicorn-at-bay.jpg" rel="shadowbox[post-445];player=img;"><img class="alignnone size-thumbnail wp-image-579" title="The Unicorn at Bay" src="http://carolineabrown.com/blog/wp-content/uploads/2009/02/the-unicorn-at-bay-310x150.jpg" alt="The Unicorn at Bay" width="310" height="150" /></a></p>
<p>This week&#8217;s assignment for Programming A to Z was to modify or augment our in-class example of a Markov chain. Somehow during class I got the idea to make a program that would create imaginary creatures by analyzing n-grams from a list of animals. I created a <a title="bestiary" href="http://itp.nyu.edu/~cab513/beasts.txt">list of creatures</a> from a medieval bestiary, and made a few simple changes to Adam&#8217;s <a title="A Markov Distinction" href="http://www.decontextualize.com/teaching/a2z/a-markov-distinction/">MarkovFilter</a> example. Here are some examples of creatures created by the program: <em>kitelerowl</em>,<strong> </strong><em>elockdawk</em>,<strong> </strong><em>swatyr</em>,<strong> </strong><em>bonomelizarr</em>,<strong> </strong><em>hydrowhawk</em>,<strong> </strong><em>heleonewt</em> and, my favorite, <em>hootalaphoot</em>. This is the code for Bestiary.java:</p>
<blockquote><p>import com.decontextualize.a2z.TextFilter;<br />
public class Bestiary extends TextFilter {<br />
public static void main(String[] args) {<br />
new Bestiary().run();<br />
}<br />
Markov mark = new Markov(2, 10);<br />
public void eachLine(String line) {<br />
mark.feedLine(line);<br />
}<br />
public void end() {<br />
println(mark.generateLine());<br />
}<br />
}</p></blockquote>
<p>I would like to eventually narrow down the list of possible animal components, create images for each, and develop a Processing sketch to assemble composites of the animals as the algorithm pieces them together.</p>
]]></content:encoded>
			<wfw:commentRss>http://carolineabrown.com/2009/02/markovs-menagerie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Succinct Scrivener</title>
		<link>http://carolineabrown.com/2009/02/succinct-scrivener/</link>
		<comments>http://carolineabrown.com/2009/02/succinct-scrivener/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 21:41:49 +0000</pubDate>
		<dc:creator>Caroline</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[Programming A to Z]]></category>

		<guid isPermaLink="false">http://carolineabrown.com/blog/?p=448</guid>
		<description><![CDATA[
Imagine my surprise, nay, my consternation, when without moving from his privacy, Bartleby in a singularly mild, firm voice, replied, I would prefer not to.
But in quite as clear a one came the previous reply, I would prefer not to.
I would prefer not to, said he.
I would prefer not to, he said, and gently disappeared [...]]]></description>
			<content:encoded><![CDATA[<blockquote>
<p style="text-align: left;">Imagine my surprise, nay, my consternation, when without moving from his privacy, Bartleby in a singularly mild, firm voice, replied, I would prefer not to.<br />
But in quite as clear a one came the previous reply, I would prefer not to.<br />
I would prefer not to, said he.<br />
I would prefer not to, he said, and gently disappeared behind the screen.<br />
Why do you refuse?  I would prefer not to.<br />
I would prefer not to.<br />
I would prefer not to.<br />
Will you tell me, Bartleby, where you were born?  I would prefer not to.<br />
Will you tell me any thing about yourself?  I would prefer not to.<br />
At present I would prefer not to be a little reasonable, was his mildly cadaverous reply.<br />
I would prefer not to quit you, he replied, gently emphasizing the not.<br />
Now what sort of business would you like to engage in?  Would you like to re-engage in copying for some one?  No; I would prefer not to make any change.<br />
Too much confinement, I cried, why you keep yourself confined all the time!  I would prefer not to take a clerkship, he rejoined, as if to settle that little item at once.<br />
No:  at present I would prefer not to make any change at all.</p></blockquote>
<p>Our assignment for Programming Ato Z this week was to use regular expressions in Java to transform or analyze a text. I immediately thought of <a title="Bartleby text" href="http://itp.nyu.edu/~cab513/bartleby.txt">Herman Melville&#8217;s Bartleby, the Scrivener</a> and imagined it might be fun to extract all the instances of Bartleby&#8217;s assertion: &#8220;I would prefer not to&#8230;&#8221; The block quote above is the output from the following code:</p>
<blockquote><p>import com.decontextualize.a2z.TextFilter;<br />
import java.util.regex.*;<br />
public class Bartleby3 extends TextFilter {<br />
public static void main(String[] args) {<br />
new Bartleby3().run();<br />
}<br />
private String contents = new String();<br />
public void begin() {<br />
println(&#8220;Starting Succinct Scrivener&#8230;&#8221;);<br />
}<br />
public void eachLine(String line) {<br />
String tempString=line.replaceAll(&#8220;\&#8221;", &#8220;&#8221;);<br />
contents += tempString + &#8221; &#8220;;<br />
}<br />
public void end() {<br />
String[] temp;<br />
temp = contents.split(&#8220;\\.&#8221;);<br />
for(int i =0; i &lt;temp.length ; i++){<br />
Pattern p = Pattern.compile(&#8220;[Ii] would prefer not &#8220;);<br />
Matcher m = p.matcher(temp[i]);<br />
if (m.find()) {<br />
println((temp[i])+&#8221;.&#8221;);<br />
}<br />
}<br />
}<br />
}</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://carolineabrown.com/2009/02/succinct-scrivener/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jabberwookie</title>
		<link>http://carolineabrown.com/2009/02/jabberwookie/</link>
		<comments>http://carolineabrown.com/2009/02/jabberwookie/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 04:17:57 +0000</pubDate>
		<dc:creator>Caroline</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[Programming A to Z]]></category>

		<guid isPermaLink="false">http://itp.nyu.edu/~cab513/blog/?p=371</guid>
		<description><![CDATA[For Programming A to Z this week we were asked to use Java to create a text:
Create a program (using, e.g., the tools presented in class) that behaves like a UNIX text processing program (such as cat, grep, tr, etc.). Your program should take text as input (any text, or a particular text of your [...]]]></description>
			<content:encoded><![CDATA[<p>For <a title="Programming A to Z" href="http://a2z.decontextualize.com/">Programming A to Z</a> this week we were asked to use Java to create a text:</p>
<blockquote><p>Create a program (using, e.g., the tools presented in class) that behaves like a UNIX text processing program (such as <code>cat</code>, <code>grep</code>, <code>tr</code>, etc.). Your program should take text as input (any text, or a particular text of your choosing) and output a version of the text that has been filtered and/or munged. Your program should use at least one method of Java’s <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html">String</a> class that we didn’t discuss in class.</p>
<p>Be creative, insightful, or intentionally banal. Optional: Use the program that you created in tandem with another UNIX command line utility.</p></blockquote>
<p>I wanted to create a completely silly text this week, so I based my assignment on Lewis Carroll&#8217;s poem,  <a title="Jabberwocky" href="http://itp.nyu.edu/~cab513/jabberwocky.txt">The Jabberwocky</a>, replacing a&#8217;s with o&#8217;s. Here&#8217;s the code:</p>
<blockquote><p>import com.decontextualize.a2z.TextFilter;<br />
public class JabberMoshy extends TextFilter {<br />
public static void main(String[] args) {<br />
JabberMoshy j = new JabberMoshy();<br />
j.run();<br />
}<br />
public void begin(){<br />
}<br />
public void eachLine(String line) {<br />
String tmpString = line.replace(&#8216;a&#8217;,'o&#8217;);<br />
println(tmpString);<br />
}<br />
public void end(){<br />
}<br />
}</p></blockquote>
<p>Here&#8217;s the command line input:</p>
<blockquote><p>caroline-browns-computer:~/atoz caroline$ javac JabberMoshy.java<br />
caroline-browns-computer:~/atoz caroline$ java JabberMoshy &lt;jabberwocky.txt</p></blockquote>
<p>And here&#8217;s the result:</p>
<blockquote><p>&#8216;Twos brillig, ond the slithy toves<br />
Did gyre ond gimble in the wobe:<br />
All mimsy were the borogoves,<br />
And the mome roths outgrobe.</p>
<p>&#8220;Bewore the Jobberwock, my son!<br />
The jows thot bite, the clows thot cotch!<br />
Bewore the Jubjub bird, ond shun<br />
The frumious Bondersnotch!&#8221;</p>
<p>He took his vorpol sword in hond:<br />
Long time the monxome foe he sought&#8211;<br />
So rested he by the Tumtum tree,<br />
And stood owhile in thought.</p>
<p>And, os in uffish thought he stood,<br />
The Jobberwock, with eyes of flome,<br />
Come whiffling through the tulgey wood,<br />
And burbled os it come!</p>
<p>One two! One two! And through ond through<br />
The vorpol blode went snicker-snock!<br />
He left it deod, ond with its heod<br />
He went golumphing bock.</p>
<p>&#8220;And host thou sloin the Jobberwock?<br />
Come to my orms, my beomish boy!<br />
O frobjous doy! Collooh! Colloy!&#8221;<br />
He chortled in his joy.</p>
<p>&#8216;Twos brillig, ond the slithy toves<br />
Did gyre ond gimble in the wobe:<br />
All mimsy were the borogoves,<br />
And the mome roths outgrobe.</p></blockquote>
<p>Next steps: Make the replace function case-insensitive, replace multiple characters.</p>
]]></content:encoded>
			<wfw:commentRss>http://carolineabrown.com/2009/02/jabberwookie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
