<?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>TamarZiv@ITP</title>
	<atom:link href="http://www.tamarziv.com/itp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tamarziv.com/itp</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 27 Mar 2011 22:26:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>W13-Final</title>
		<link>http://www.tamarziv.com/itp/w13-final/</link>
		<comments>http://www.tamarziv.com/itp/w13-final/#comments</comments>
		<pubDate>Fri, 14 May 2010 18:34:21 +0000</pubDate>
		<dc:creator>tamarziv</dc:creator>
				<category><![CDATA[H79.2273 - The World Pixel by Pixel]]></category>
		<category><![CDATA[H79.2480 - Nature of Code]]></category>

		<guid isPermaLink="false">http://www.tamarziv.com/itp/?p=498</guid>
		<description><![CDATA[This is Spectre,  A ghostly video installation.
Thank you Daniel Shiffman and Danny Rozin for making this happen

]]></description>
			<content:encoded><![CDATA[<p>This is Spectre,  A ghostly video installation.<br />
Thank you Daniel Shiffman and Danny Rozin for making this happen</p>
<p><object width="600" height="450"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=11739671&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=11739671&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="600" height="450"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tamarziv.com/itp/w13-final/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>W13-Hey Ho, Let&#8217;s Go</title>
		<link>http://www.tamarziv.com/itp/w13-hey-ho-lets-go/</link>
		<comments>http://www.tamarziv.com/itp/w13-hey-ho-lets-go/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 19:01:41 +0000</pubDate>
		<dc:creator>tamarziv</dc:creator>
				<category><![CDATA[H79.2778 - Reading and Writing Electronic Text]]></category>

		<guid isPermaLink="false">http://www.tamarziv.com/itp/?p=476</guid>
		<description><![CDATA[ha ha hammer ha ha ha ha hammer ha I walk my parlor floor,
ha ha hammer ha ha ha ha hammer ha I walk my parlor floor,
ha ha hammer ha ha ha ha hammer ha I walk my parlor floor,
ha ha hammer ha ha ha ha hammer ha I walk my parlor floor,
ha ha hammer ha ha ha ha hammer ha I walk my parlor floor,]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gutenberg.org/files/16786/16786.txt" target=new>Mangled source</a><br />
<a href="http://www.sing365.com/music/lyric.nsf/PrintLyrics?OpenForm&#038;ParentUnid=22E29EA2F3F7671E48256A0D0028E2E1" target=new>The structure channeled</a></p>
<p><em>O O O  mourning, I walk my parlor floor,<br />
At him here, and Beneath the vernal moon-o-oh, I walk my parlor floor,<br />
When the hours of day appeared, And the long-disused, dismantled youth,<br />
friends! friends! friends! Until I find release;<br />
I sit upon the sands alone; fleeing all discreet,<br />
in me, me, me, me, me.</p>
<p>O O O  mourning, I walk my parlor floor,<br />
At him here, and Beneath the vernal moon-o-oh, I walk my parlor floor,<br />
From all that curses yonder bound! And long-dismantled youth,<br />
friends! friends! friends! before I get dismissed;<br />
I sit upon the sands alone; fleeing all a void,<br />
in me, me, me, me, me.</p>
<p>O O O  mourning, I walk my parlor floor,<br />
At him here, and Beneath the vernal moon-o-oh, I walk my parlor floor,<br />
From all that curses yonder! She battled underneath,<br />
friends! friends! friends! I shall not be too soon;<br />
I sit upon the sands alone, before I am released,<br />
of me, me, me, me, me.</p>
<p>ha ha hammer, ha ha ha ha hammer ha, I walk my parlor floor,<br />
ha ha hammer, ha ha ha ha hammer ha, I walk my parlor floor,<br />
ha ha hammer, ha ha ha ha hammer ha, I walk my parlor floor,<br />
ha ha hammer, ha ha ha ha hammer ha, I walk my parlor floor,<br />
</em><br />
</br><br />
</br><br />
</br><br />
<strong>Code:</strong><br />
</br></p>
<div class="codecolorer-container python blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;"># Anon class is used to get rid of poem titles, authors and comments</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># builds dictionary from source text, and replaces words from a different text which start with the same letter</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">random</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">re</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># use regular expressions</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> markov<br />
<br />
<span style="color: #808080; font-style: italic;">#source_file = sys.argv[1] &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # first argument passed on command line, sys.argv[0] will be the name of the script file</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Break the text into lines</span><br />
<span style="color: #808080; font-style: italic;"># filter out unwanted content</span><br />
<span style="color: #808080; font-style: italic;"># globals</span><br />
<br />
I_Lines = <span style="color: #008000;">dict</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
dict_lines = <span style="color: #008000;">dict</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
linecount = <span style="color: #ff4500;">255</span><br />
oh_list = <span style="color: #008000;">list</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
no_list = <span style="color: #008000;">list</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
bamp_list = <span style="color: #008000;">list</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
hurry_list = <span style="color: #008000;">list</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
before_I = <span style="color: #008000;">list</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
<br />
<br />
<span style="color: #ff7700;font-weight:bold;">def</span> clean_text<span style="color: black;">&#40;</span>raw_text<span style="color: black;">&#41;</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># create a dict of markoved text</span><br />
&nbsp; &nbsp; clean_text = <span style="color: #483d8b;">&quot;&quot;</span><br />
&nbsp; &nbsp; n = <span style="color: #ff4500;">2</span><br />
&nbsp; &nbsp; mark2 = markov.<span style="color: black;">MarkovGenerator</span><span style="color: black;">&#40;</span>n, <span style="color: #ff4500;">14000</span><span style="color: black;">&#41;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">#create a markov object</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> line <span style="color: #ff7700;font-weight:bold;">in</span> raw_text: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># reading lines from txt</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; line = line.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; line = <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;.+[A-Z]+(<span style="color: #000099; font-weight: bold;">\.</span>|<span style="color: #000099; font-weight: bold;">\.</span><span style="color: #000099; font-weight: bold;">\&quot;</span>|<span style="color: #000099; font-weight: bold;">\?</span>)$&quot;</span>,<span style="color: #483d8b;">''</span>, line<span style="color: black;">&#41;</span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># get rid of titles</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; line = <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;^<span style="color: #000099; font-weight: bold;">\s</span>*(<span style="color: #000099; font-weight: bold;">\S</span>+|<span style="color: #000099; font-weight: bold;">\S</span><span style="color: #000099; font-weight: bold;">\b</span><span style="color: #000099; font-weight: bold;">\S</span>)$&quot;</span>, <span style="color: #483d8b;">''</span>, line<span style="color: black;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># get rid of short lines</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; line = <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;(<span style="color: #000099; font-weight: bold;">\:</span>|<span style="color: #000099; font-weight: bold;">\?</span>|<span style="color: #000099; font-weight: bold;">\?</span><span style="color: #000099; font-weight: bold;">\&quot;</span>)$|^<span style="color: #000099; font-weight: bold;">\(</span>|<span style="color: #000099; font-weight: bold;">\)</span>$|<span style="color: #000099; font-weight: bold;">\]</span>$&quot;</span>, <span style="color: #483d8b;">''</span>, line<span style="color: black;">&#41;</span> &nbsp; <span style="color: #808080; font-style: italic;"># get rid of questions and colons etc.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; line = <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;^<span style="color: #000099; font-weight: bold;">\(</span>.+<span style="color: #000099; font-weight: bold;">\)</span>.{,1}$&quot;</span>, <span style="color: #483d8b;">''</span>, line<span style="color: black;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># get rid of bracketed lines</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; line = <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;^.{,2}<span style="color: #000099; font-weight: bold;">\.</span>$&quot;</span>, <span style="color: #483d8b;">''</span>, line<span style="color: black;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># get rid of numbering</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; line = <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;^I'm<span style="color: #000099; font-weight: bold;">\b</span>&quot;</span>, <span style="color: #483d8b;">''</span>, line<span style="color: black;">&#41;</span> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># get rid of numbering</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; line = <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\b</span><span style="color: #000099; font-weight: bold;">\*</span><span style="color: #000099; font-weight: bold;">\b</span>&quot;</span>, <span style="color: #483d8b;">''</span>, line<span style="color: black;">&#41;</span> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># get rid of *&nbsp; </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; templine = line<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\b</span>[Bb]efore I<span style="color: #000099; font-weight: bold;">\b</span>.+$'</span>, templine<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset = line.<span style="color: black;">find</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot; before&quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> offset <span style="color: #66cc66;">!</span>= -<span style="color: #ff4500;">1</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; before_I.<span style="color: black;">append</span><span style="color: black;">&#40;</span>templine<span style="color: black;">&#91;</span>offset+<span style="color: #ff4500;">1</span>:<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; tempword = line.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> tempword:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># get lists for oh-no</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\b</span><span style="color: #000099; font-weight: bold;">\w</span>[aeiou]<span style="color: #000099; font-weight: bold;">\b</span>'</span>, i<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; no_list.<span style="color: black;">append</span><span style="color: black;">&#40;</span>i<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\b</span><span style="color: #000099; font-weight: bold;">\w</span>[aeiou]<span style="color: #000099; font-weight: bold;">\w</span><span style="color: #000099; font-weight: bold;">\w</span><span style="color: #000099; font-weight: bold;">\b</span>'</span>, i<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bamp_list.<span style="color: black;">append</span><span style="color: black;">&#40;</span>i<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\b</span>[aeiou]<span style="color: #000099; font-weight: bold;">\w</span><span style="color: #000099; font-weight: bold;">\b</span>&quot;</span>, i<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; oh_list.<span style="color: black;">append</span><span style="color: black;">&#40;</span>i<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\b</span><span style="color: #000099; font-weight: bold;">\w</span>+[!]'</span>, i<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hurry_list.<span style="color: black;">append</span><span style="color: black;">&#40;</span>i<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> line.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>: &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># get rid of empty lines</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">continue</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mark2.<span style="color: black;">feed</span><span style="color: black;">&#40;</span>line<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>linecount<span style="color: black;">&#41;</span>:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">#sort by length</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; makeMarkovs = mark2.<span style="color: black;">generate</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; temp_line = makeMarkovs<br />
&nbsp; &nbsp; &nbsp; &nbsp; words = temp_line.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; counter = <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>words<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> counter <span style="color: #ff7700;font-weight:bold;">in</span> dict_lines: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># set keys and values</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dict_lines<span style="color: black;">&#91;</span>counter<span style="color: black;">&#93;</span>.<span style="color: black;">append</span><span style="color: black;">&#40;</span>temp_line<span style="color: black;">&#41;</span> &nbsp; <span style="color: #808080; font-style: italic;"># append word to the value of that number</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># looks like {'3':['the','big']...} </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dict_lines<span style="color: black;">&#91;</span>counter<span style="color: black;">&#93;</span> = <span style="color: black;">&#91;</span>temp_line<span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> dict_lines<br />
&nbsp; &nbsp; <br />
<span style="color: #ff7700;font-weight:bold;">def</span> i_text<span style="color: black;">&#40;</span>clean_text<span style="color: black;">&#41;</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Dict of lines starting with I</span><br />
&nbsp; &nbsp; I_lines = <span style="color: #483d8b;">&quot;&quot;</span><br />
&nbsp; &nbsp; n = <span style="color: #ff4500;">2</span><br />
&nbsp; &nbsp; mark = markov.<span style="color: black;">MarkovGenerator</span><span style="color: black;">&#40;</span>n, <span style="color: #ff4500;">14000</span><span style="color: black;">&#41;</span> &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">#create a markov object</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> line <span style="color: #ff7700;font-weight:bold;">in</span> clean_text: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># reading lines from txt</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">#mark.feed(line)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; line = line.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; line = <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;.+[A-Z]+(<span style="color: #000099; font-weight: bold;">\.</span>|<span style="color: #000099; font-weight: bold;">\.</span><span style="color: #000099; font-weight: bold;">\&quot;</span>|<span style="color: #000099; font-weight: bold;">\?</span>)$&quot;</span>,<span style="color: #483d8b;">''</span>, line<span style="color: black;">&#41;</span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># get rid of titles</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; line = <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;^<span style="color: #000099; font-weight: bold;">\s</span>*(<span style="color: #000099; font-weight: bold;">\S</span>+|<span style="color: #000099; font-weight: bold;">\S</span><span style="color: #000099; font-weight: bold;">\b</span><span style="color: #000099; font-weight: bold;">\S</span>)$&quot;</span>, <span style="color: #483d8b;">''</span>, line<span style="color: black;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># get rid of short lines</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; line = <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;(<span style="color: #000099; font-weight: bold;">\:</span>|<span style="color: #000099; font-weight: bold;">\?</span>|<span style="color: #000099; font-weight: bold;">\?</span><span style="color: #000099; font-weight: bold;">\&quot;</span>)$|^<span style="color: #000099; font-weight: bold;">\(</span>|<span style="color: #000099; font-weight: bold;">\)</span>$|<span style="color: #000099; font-weight: bold;">\]</span>$&quot;</span>, <span style="color: #483d8b;">''</span>, line<span style="color: black;">&#41;</span> &nbsp; <span style="color: #808080; font-style: italic;"># get rid of questions and colons etc.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; line = <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;^<span style="color: #000099; font-weight: bold;">\(</span>.+<span style="color: #000099; font-weight: bold;">\)</span>.{,1}$&quot;</span>, <span style="color: #483d8b;">''</span>, line<span style="color: black;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># get rid of bracketed lines</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; line = <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;^.{,2}<span style="color: #000099; font-weight: bold;">\.</span>$&quot;</span>, <span style="color: #483d8b;">''</span>, line<span style="color: black;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># get rid of numbering</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; line = <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;^I'm<span style="color: #000099; font-weight: bold;">\b</span>&quot;</span>, <span style="color: #483d8b;">''</span>, line<span style="color: black;">&#41;</span> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># get rid of numbering</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; line = <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\b</span><span style="color: #000099; font-weight: bold;">\*</span><span style="color: #000099; font-weight: bold;">\b</span>&quot;</span>, <span style="color: #483d8b;">''</span>, line<span style="color: black;">&#41;</span> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># get rid of *&nbsp; &nbsp; &nbsp; </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'^I<span style="color: #000099; font-weight: bold;">\b</span><span style="color: #000099; font-weight: bold;">\s</span><span style="color: #000099; font-weight: bold;">\b</span>.+'</span>, line<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mark.<span style="color: black;">feed</span><span style="color: black;">&#40;</span>line<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>linecount<span style="color: black;">&#41;</span>:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># create a dict off the markov results</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; makeMarkovs = mark.<span style="color: black;">generate</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; temp_line = makeMarkovs<br />
&nbsp; &nbsp; &nbsp; &nbsp; words = temp_line.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; counter = <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>words<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> counter <span style="color: #ff7700;font-weight:bold;">in</span> I_Lines:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; I_Lines<span style="color: black;">&#91;</span>counter<span style="color: black;">&#93;</span>.<span style="color: black;">append</span><span style="color: black;">&#40;</span>temp_line<span style="color: black;">&#41;</span>&nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># append word to the value of that number</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># looks like {'3':['the','big']...} </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; I_Lines<span style="color: black;">&#91;</span>counter<span style="color: black;">&#93;</span> = <span style="color: black;">&#91;</span>temp_line<span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> I_Lines&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># return</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">def</span> get_lines_from_file<span style="color: black;">&#40;</span>filename<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; raw_text = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>filename<span style="color: black;">&#41;</span> &nbsp; <br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> raw_text<br />
<br />
<span style="color: #808080; font-style: italic;">#run the functions</span><br />
lines_from_file = get_lines_from_file<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;WBP-III_edit.txt&quot;</span><span style="color: black;">&#41;</span><br />
I_lines_from_file = get_lines_from_file<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;WBP-III_edit.txt&quot;</span><span style="color: black;">&#41;</span><br />
clean = clean_text<span style="color: black;">&#40;</span>lines_from_file<span style="color: black;">&#41;</span><br />
i_sentences = i_text<span style="color: black;">&#40;</span>I_lines_from_file<span style="color: black;">&#41;</span><br />
<br />
<br />
<span style="color: #808080; font-style: italic;"># debugging station:</span><br />
<span style="color: #808080; font-style: italic;">#print dict_lines</span><br />
<span style="color: #808080; font-style: italic;">#print I_Lines</span><br />
<span style="color: #808080; font-style: italic;">#print no</span><br />
<span style="color: #808080; font-style: italic;">#print oh</span><br />
<span style="color: #808080; font-style: italic;">#print before_I</span><br />
<span style="color: #808080; font-style: italic;">#print twenty</span><br />
<span style="color: #808080; font-style: italic;">#print four_hours_to_go</span><br />
<span style="color: #808080; font-style: italic;">#print hurry_list</span><br />
<br />
<span style="color: #808080; font-style: italic;"># variables</span><br />
four_hours_to_go = <span style="color: #483d8b;">&quot;&quot;</span><br />
twenty = <span style="color: #483d8b;">&quot;&quot;</span><br />
to_go = <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>dict_lines<span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
to_go_words = to_go.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#41;</span><br />
twenty = to_go_words<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><br />
offset = <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>twenty<span style="color: black;">&#41;</span><br />
four_hours_to_go = to_go<span style="color: black;">&#91;</span>offset:<span style="color: #ff4500;">6</span><span style="color: black;">&#93;</span><br />
bamp = <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>bamp_list<span style="color: black;">&#41;</span><br />
ba = bamp<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span>:<span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># more variables</span><br />
I_wanna_be_sedated = <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>I_Lines<span style="color: black;">&#91;</span><span style="color: #ff4500;">5</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
Twenty_twenty_twenty_four_hours_to_go = twenty+<span style="color: #483d8b;">&quot; &quot;</span>+twenty+<span style="color: #483d8b;">&quot; &quot;</span>+twenty+<span style="color: #483d8b;">&quot; &quot;</span>+four_hours_to_go<br />
Nothin_to_do = <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>dict_lines<span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
no_where_to_go = <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>dict_lines<span style="color: black;">&#91;</span><span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
Just_get_me_to_the_airport = <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>dict_lines<span style="color: black;">&#91;</span><span style="color: #ff4500;">6</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
put_me_on_a_plane = <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>dict_lines<span style="color: black;">&#91;</span><span style="color: #ff4500;">5</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
hurry = <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>hurry_list<span style="color: black;">&#41;</span><br />
before_I_go_insane = <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>before_I<span style="color: black;">&#41;</span><br />
I_cant_control_my_fingers = <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>I_Lines<span style="color: black;">&#91;</span><span style="color: #ff4500;">6</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
I_cant_control_my_brain = <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>I_Lines<span style="color: black;">&#91;</span><span style="color: #ff4500;">6</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
oh = <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>oh_list<span style="color: black;">&#41;</span><br />
no = <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>no_list<span style="color: black;">&#41;</span><br />
Just_put_me_in_a_wheelchair = <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>dict_lines<span style="color: black;">&#91;</span><span style="color: #ff4500;">6</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
get_me_to_the_show = <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>dict_lines<span style="color: black;">&#91;</span><span style="color: #ff4500;">5</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
I_gotta_go = <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>I_Lines<span style="color: black;">&#91;</span><span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
I_cant_control_my_toes = <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>I_Lines<span style="color: black;">&#91;</span><span style="color: #ff4500;">6</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
Ba_ba_bamp_ba = ba+<span style="color: #483d8b;">&quot; &quot;</span>+ba+<span style="color: #483d8b;">&quot; &quot;</span>+bamp+<span style="color: #483d8b;">&quot; &quot;</span>+ba<br />
ba_ba_ba_bamp_ba = &nbsp;ba+<span style="color: #483d8b;">&quot; &quot;</span>+ba+<span style="color: #483d8b;">&quot; &quot;</span>+ba+<span style="color: #483d8b;">&quot; &quot;</span>+bamp+<span style="color: #483d8b;">&quot; &quot;</span>+ba<br />
<br />
<span style="color: #808080; font-style: italic;"># Hey ho let's go !</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">print</span> Twenty_twenty_twenty_four_hours_to_go +<span style="color: #483d8b;">&quot; &quot;</span>+ I_wanna_be_sedated<br />
<span style="color: #ff7700;font-weight:bold;">print</span> Nothin_to_do + <span style="color: #483d8b;">&quot; and &quot;</span> + no_where_to_go +<span style="color: #483d8b;">&quot;-o-oh &quot;</span>+ I_wanna_be_sedated<br />
<span style="color: #ff7700;font-weight:bold;">print</span> Just_get_me_to_the_airport +<span style="color: #483d8b;">&quot; &quot;</span> + put_me_on_a_plane<br />
<span style="color: #ff7700;font-weight:bold;">print</span> hurry+<span style="color: #483d8b;">&quot; &quot;</span>+hurry+<span style="color: #483d8b;">&quot; &quot;</span>+hurry + <span style="color: #483d8b;">&quot; &quot;</span> + before_I_go_insane<br />
<span style="color: #ff7700;font-weight:bold;">print</span> I_cant_control_my_fingers &nbsp;+ <span style="color: #483d8b;">&quot; &quot;</span> + &nbsp;I_cant_control_my_brain<br />
<span style="color: #ff7700;font-weight:bold;">print</span> oh + <span style="color: #483d8b;">&quot; &quot;</span> + no + <span style="color: #483d8b;">&quot; &quot;</span> + no + <span style="color: #483d8b;">&quot; &quot;</span> + no + <span style="color: #483d8b;">&quot; &quot;</span> + no + <span style="color: #483d8b;">&quot; &quot;</span> + no<br />
<br />
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><br />
<br />
<br />
<span style="color: #ff7700;font-weight:bold;">print</span> Twenty_twenty_twenty_four_hours_to_go +<span style="color: #483d8b;">&quot; &quot;</span>+ I_wanna_be_sedated<br />
<span style="color: #ff7700;font-weight:bold;">print</span> Nothin_to_do + <span style="color: #483d8b;">&quot; and &quot;</span> + no_where_to_go +<span style="color: #483d8b;">&quot;-o-oh &quot;</span>+ I_wanna_be_sedated<br />
<span style="color: #ff7700;font-weight:bold;">print</span> Just_put_me_in_a_wheelchair + <span style="color: #483d8b;">&quot; and &quot;</span> + put_me_on_a_plane<br />
<span style="color: #ff7700;font-weight:bold;">print</span> hurry+<span style="color: #483d8b;">&quot; &quot;</span>+hurry+<span style="color: #483d8b;">&quot; &quot;</span>+hurry + <span style="color: #483d8b;">&quot; &quot;</span> + before_I_go_insane<br />
<span style="color: #ff7700;font-weight:bold;">print</span> I_cant_control_my_fingers &nbsp;+ <span style="color: #483d8b;">&quot; &quot;</span> + I_cant_control_my_brain<br />
<span style="color: #ff7700;font-weight:bold;">print</span> oh + <span style="color: #483d8b;">&quot; &quot;</span> + no + <span style="color: #483d8b;">&quot; &quot;</span> + no + <span style="color: #483d8b;">&quot; &quot;</span> + no + <span style="color: #483d8b;">&quot; &quot;</span> + no + <span style="color: #483d8b;">&quot; &quot;</span> + no<br />
<br />
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">print</span> Twenty_twenty_twenty_four_hours_to_go +<span style="color: #483d8b;">&quot; &quot;</span>+ I_wanna_be_sedated<br />
<span style="color: #ff7700;font-weight:bold;">print</span> Nothin_to_do + <span style="color: #483d8b;">&quot; and &quot;</span> + no_where_to_go +<span style="color: #483d8b;">&quot;-o-oh &quot;</span>+ I_wanna_be_sedated<br />
<span style="color: #ff7700;font-weight:bold;">print</span> Just_put_me_in_a_wheelchair + <span style="color: #483d8b;">&quot; &quot;</span> + get_me_to_the_show<br />
<span style="color: #ff7700;font-weight:bold;">print</span> hurry+<span style="color: #483d8b;">&quot; &quot;</span>+hurry+<span style="color: #483d8b;">&quot; &quot;</span>+hurry + <span style="color: #483d8b;">&quot; &quot;</span> + I_gotta_go<br />
<span style="color: #ff7700;font-weight:bold;">print</span> I_cant_control_my_fingers &nbsp;+ <span style="color: #483d8b;">&quot; &quot;</span> + I_cant_control_my_toes<br />
<span style="color: #ff7700;font-weight:bold;">print</span> oh + <span style="color: #483d8b;">&quot; &quot;</span> + no + <span style="color: #483d8b;">&quot; &quot;</span> + no + <span style="color: #483d8b;">&quot; &quot;</span> + no + <span style="color: #483d8b;">&quot; &quot;</span> + no + <span style="color: #483d8b;">&quot; &quot;</span> + no<br />
<br />
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">print</span> Ba_ba_bamp_ba + <span style="color: #483d8b;">&quot; &quot;</span> + ba_ba_ba_bamp_ba +<span style="color: #483d8b;">&quot; &quot;</span>+ I_wanna_be_sedated<br />
<span style="color: #ff7700;font-weight:bold;">print</span> Ba_ba_bamp_ba + <span style="color: #483d8b;">&quot; &quot;</span> + ba_ba_ba_bamp_ba +<span style="color: #483d8b;">&quot; &quot;</span>+ I_wanna_be_sedated<br />
<span style="color: #ff7700;font-weight:bold;">print</span> Ba_ba_bamp_ba + <span style="color: #483d8b;">&quot; &quot;</span> + ba_ba_ba_bamp_ba +<span style="color: #483d8b;">&quot; &quot;</span>+ I_wanna_be_sedated<br />
<span style="color: #ff7700;font-weight:bold;">print</span> Ba_ba_bamp_ba + <span style="color: #483d8b;">&quot; &quot;</span> + ba_ba_ba_bamp_ba +<span style="color: #483d8b;">&quot; &quot;</span>+ I_wanna_be_sedated</div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.tamarziv.com/itp/w13-hey-ho-lets-go/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>W09-Final Proposal</title>
		<link>http://www.tamarziv.com/itp/w09-final-proposal/</link>
		<comments>http://www.tamarziv.com/itp/w09-final-proposal/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 16:22:40 +0000</pubDate>
		<dc:creator>tamarziv</dc:creator>
				<category><![CDATA[H79.2480 - Nature of Code]]></category>

		<guid isPermaLink="false">http://www.tamarziv.com/itp/?p=466</guid>
		<description><![CDATA[Idea: fragmenting live video into particles systems.
A few initial test done, not yet incorporating particles systems. Motion detection would define the birth of the particles, the sprite itself, may potentially a &#8220;moth&#8221;, hopefully&#8230;..
OpenFrameworks test apps
Here are some examples that use video data and break them down into particles systems:

The motion and color effects are kinda [...]]]></description>
			<content:encoded><![CDATA[<p>Idea: fragmenting live video into particles systems.<br />
A few initial test done, not yet incorporating particles systems. Motion detection would define the birth of the particles, the sprite itself, may potentially a &#8220;moth&#8221;, hopefully&#8230;..</p>
<p><a href="http://itp.nyu.edu/~tz346/w09/testApps.zip">OpenFrameworks test apps</a></p>
<p>Here are some examples that use video data and break them down into particles systems:</p>
<p><object width="600" height="338"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=8355624&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=8355624&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="600" height="338"></embed></object></p>
<p>The motion and color effects are kinda the direction for the final piece, hopefully&#8230;.</p>
<p><object width="600" height="342"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=7663952&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff0179&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=7663952&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff0179&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="600" height="342"></embed></object><br />
</br><br />
This is where it is at the moment&#8230;.</p>
<p><img src="http://www.tamarziv.com/itp/wp-content/themes/tma/images/uploads/nocbig.jpg" alt="nocbig" title="nocbig" width="600" height="417" class="alignnone size-full wp-image-472" /></p>
<p></br></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tamarziv.com/itp/w09-final-proposal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Barney&#8217;s Regular Depression</title>
		<link>http://www.tamarziv.com/itp/barneys-regular-depression-not-yet/</link>
		<comments>http://www.tamarziv.com/itp/barneys-regular-depression-not-yet/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 20:10:39 +0000</pubDate>
		<dc:creator>tamarziv</dc:creator>
				<category><![CDATA[H79.2778 - Reading and Writing Electronic Text]]></category>

		<guid isPermaLink="false">http://www.tamarziv.com/itp/?p=443</guid>
		<description><![CDATA[to being However,
However, plans or
abate. a Mixed Episode
every a Major Depressive Episode
mood to these guilt or are However,
during However, mild However, toxin or Moreover, 
be one&#8217;s predict
predict these lowed
unless an irreversible dementia
often a Major Depressive Episode
wish of prior fully lowed are predict
review predict self predict being lowed predict
an other failure
failure aches high
return an irreversible dementia
often [...]]]></description>
			<content:encoded><![CDATA[<p>to being However,<br />
However, plans or<br />
abate. a Mixed Episode<br />
every a Major Depressive Episode<br />
mood to these guilt or are However,<br />
during However, mild However, toxin or Moreover, </p>
<p>be one&#8217;s predict<br />
predict these lowed<br />
unless an irreversible dementia<br />
often a Major Depressive Episode<br />
wish of prior fully lowed are predict<br />
review predict self predict being lowed predict</p>
<p>an other failure<br />
failure aches high<br />
return an irreversible dementia<br />
often an increased appetite<br />
this to areas sense high For failure<br />
sales. failure When failure every high feature </p>
<p>or these objects<br />
objects least to<br />
sleep, a Mixed Episode<br />
fully a Major Depressive Episode<br />
they to there begin to and objects<br />
plays, objects Less objects aches to defects </p>
<p>an there frustrated.<br />
frustrated. guilt is<br />
plans, an irreversible dementia<br />
fully an increased appetite<br />
also as child down is for frustrated.<br />
think, frustrated. than frustrated. night is frustrated. </p>
<p>of chief pauses<br />
pauses often has<br />
better a week period<br />
pains a general medical condition<br />
less or Other deny, has the pauses<br />
always pauses with pauses there has focuses </p>
<p>do often treated,<br />
treated, bowel signs<br />
sweets an irreversible dementia<br />
sleep a Major Depressive Episode<br />
from of which toxin signs the treated,<br />
sales. treated, from treated, weeks signs depressed, </p>
<p>of worst grades<br />
grades other and<br />
unless a week thought<br />
there an increased appetite<br />
have by would twice and the grades<br />
asleep grades than grades these and includes </p>
<p>be least easily<br />
easily early in<br />
better a Mixed Episode<br />
worst an increased appetite<br />
eat. of there these in and easily<br />
having easily have easily would in Family </p>
<p>be manic concentration.<br />
concentration. there to<br />
sales. a week period<br />
Those a Major Depressive Episode<br />
than a myocardial infarction signs to the concentration.<br />
memory concentration. used concentration. these to exertion. </p>
<p>at count sadness.<br />
sadness. often not<br />
before an irreversible dementia<br />
plans an increased appetite<br />
when a week thought these not for sadness.<br />
rather sadness. away sadness. count not muteness. </p>
<p>by Those infarction,<br />
infarction, Those abuse<br />
dumps&#8221; a week period<br />
signs a Major Depressive Episode<br />
sick a week thought there abuse and infarction,<br />
cases, infarction, that infarction, quite abuse definition, </p>
<p>or often interpersonal<br />
interpersonal looks or<br />
middle a week thought<br />
toxin an increased appetite<br />
they a week period bowel or and interpersonal<br />
dearly interpersonal with interpersonal one&#8217;s or terminal </p>
<p>to least infarction,<br />
infarction, night one<br />
person a Mixed Episode<br />
drawn a Major Depressive Episode<br />
gain a myocardial infarction seeks one for infarction,<br />
toward infarction, food infarction, looks one direction, </p>
<p>or &#8220;down negative<br />
negative fully often<br />
during an irreversible dementia<br />
there a general medical condition<br />
most a Mixed Episode quite often the negative<br />
waking negative some negative often often subjective </p>
<p>be other pauses<br />
pauses often be<br />
person a week thought<br />
loved a general medical condition<br />
with a week period guilt be the pauses<br />
sweets pauses face pauses night be excuses </p>
<p>no other pains<br />
pains being week<br />
nearly a Mixed Episode<br />
worst a Major Depressive Episode<br />
have an irreversible dementia areas week for pains<br />
sales. pains mood pains skin, week gains </p>
<p>in sense Frequently<br />
Frequently fully four<br />
become a week thought<br />
sense a Major Depressive Episode<br />
Some a myocardial infarction often four the Frequently<br />
return Frequently mild Frequently which four subsequently </p>
<p>an about symptoms<br />
symptoms there eat.<br />
unable a myocardial infarction<br />
deny, an increased appetite<br />
must a Mixed Episode angry eat. The symptoms<br />
before symptoms they symptoms tasks eat. symptoms </p>
<p>Yes, Barney has taken a turn to the worst, now he&#8217;s using general expressions to express his depressions, there are three different dictionaries, one is general, the other is set to match the 3 last characters of the word for rhyming sake, the last, is a dictionary of sentences beginning with the letter a, to match the following diagram. </p>
<p><em>I love you<br />
You love me<br />
we&#8217;re a happy family<br />
with a great big hug<br />
and a kiss from me to you<br />
won&#8217;t you say you love me too</p>
<p>3 Words, 1 You, 1 Love<br />
3 Words, 1 You, 1 Love, 1 Me<br />
4 Words, one We<br />
5 Words, with a<br />
6 Words, with a<br />
7 Words, __ you ___, you love me too [rhymes with you]</p>
<p>w(z) w(any) w(x)<br />
w(x) w(z) w(y)<br />
w(any) w(a any*2)<br />
with w(a any*3)<br />
and w(a any*2) w(y) to w(x)<br />
won&#8217;t w(x) w(any) w(x) w(z) w(y) too-([-3:] of w(y))</em><br />
</br><br />
</br></p>
<div class="codecolorer-container python blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># builds dictionary from source text, and replaces words from a different text which start with the same letter</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">random</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">re</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># use regular expressions</span><br />
<br />
source_alpha = <span style="color: #008000;">dict</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># dictionary of all words in first text</span><br />
source_endings = <span style="color: #008000;">dict</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># dictionary of all words ending with same 3 letters&nbsp; &nbsp; </span><br />
source_a = <span style="color: #008000;">dict</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># dictionary of all strings beginning with the letter a </span><br />
<br />
source_file = <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># first argument passed on command line, sys.argv[0] will be the name of the script file</span><br />
<br />
ignoreList = <span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;),&quot;</span>, <span style="color: #483d8b;">&quot;).&quot;</span>, <span style="color: #483d8b;">&quot;Major&quot;</span>, <span style="color: #483d8b;">&quot;major&quot;</span>, <span style="color: #483d8b;">&quot;(&quot;</span>, <span style="color: #483d8b;">&quot;AS).&quot;</span>, <span style="color: #483d8b;">&quot;A3).&quot;</span>, <span style="color: #483d8b;">&quot;A9).&quot;</span>, <span style="color: #483d8b;">&quot;(e.g.,&quot;</span>, <span style="color: #483d8b;">&quot;E).&quot;</span>, <span style="color: #483d8b;">&quot;(i.e.,&quot;</span><span style="color: black;">&#93;</span><br />
ignoreIndex = <span style="color: #008000;">int</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
ignoreIndex = <span style="color: #ff4500;">0</span><br />
<br />
<span style="color: #808080; font-style: italic;"># create a dictionary of words from the text</span><br />
<span style="color: #808080; font-style: italic;"># read each line from source file; split each line into words; store each</span><br />
<span style="color: #808080; font-style: italic;"># word in the source_alpha dictionary, according to which letter it starts with</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> line <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>source_file<span style="color: black;">&#41;</span>: &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># reading lines from major_dep.txt</span><br />
&nbsp; &nbsp; line = line.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; words = line.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> word <span style="color: #ff7700;font-weight:bold;">in</span> words:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># loops through each of the words &nbsp; &nbsp; &nbsp; </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>word<span style="color: black;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># check to make sure we have a large word</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lengthWord = <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>word<span style="color: black;">&#41;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># get first letter of word</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># if we've already seen this number, append to list</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> lengthWord <span style="color: #ff7700;font-weight:bold;">in</span> source_alpha:&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source_alpha<span style="color: black;">&#91;</span>lengthWord<span style="color: black;">&#93;</span>.<span style="color: black;">append</span><span style="color: black;">&#40;</span>word<span style="color: black;">&#41;</span> &nbsp; <span style="color: #808080; font-style: italic;"># append word to the value of that number</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># looks like {'3':['the','big']...} </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source_alpha<span style="color: black;">&#91;</span>lengthWord<span style="color: black;">&#93;</span> = <span style="color: black;">&#91;</span>word<span style="color: black;">&#93;</span> &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># specify that a new list is made</span><br />
<br />
<br />
<span style="color: #ff7700;font-weight:bold;">for</span> key <span style="color: #ff7700;font-weight:bold;">in</span> source_alpha:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># go through each key in the dict</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> key <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> regect <span style="color: #ff7700;font-weight:bold;">in</span> ignoreList: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># for each word in regects</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> item <span style="color: #ff7700;font-weight:bold;">in</span> source_alpha<span style="color: black;">&#91;</span>key<span style="color: black;">&#93;</span>:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># itirate through members of list</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> regect == item:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># if word in list is a regect</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># &nbsp; print regect + ' before ' + str(source_alpha[key])</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source_alpha<span style="color: black;">&#91;</span>key<span style="color: black;">&#93;</span>.<span style="color: black;">pop</span><span style="color: black;">&#40;</span>source_alpha<span style="color: black;">&#91;</span>key<span style="color: black;">&#93;</span>.<span style="color: black;">index</span><span style="color: black;">&#40;</span>regect<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>&nbsp; <span style="color: #808080; font-style: italic;">#pop it out of the list</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># &nbsp; print regect + ' after ' + str(source_alpha[key])</span><br />
<br />
<span style="color: #808080; font-style: italic;">#print source_alpha</span><br />
<br />
<span style="color: #808080; font-style: italic;"># source_alpha will be a dictionary whose keys are strings and whose values</span><br />
<span style="color: #808080; font-style: italic;"># are lists.</span><br />
<span style="color: #808080; font-style: italic;"># uncomment this to see what the data structure created above looks like</span><br />
<span style="color: #808080; font-style: italic;">#print source_alpha</span><br />
<br />
<span style="color: #808080; font-style: italic;"># source_endings will have values of words that share the same 3 last charecters</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> line <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>source_file<span style="color: black;">&#41;</span>: &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># reading lines from major_dep.txt</span><br />
&nbsp; &nbsp; line = line.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; words = line.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> word <span style="color: #ff7700;font-weight:bold;">in</span> words:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># loops through each of the words &nbsp; &nbsp; &nbsp; </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>word<span style="color: black;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">4</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># check to make sure we have a large word</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span>word <span style="color: #66cc66;">!</span>= <span style="color: #483d8b;">&quot;major&quot;</span><span style="color: black;">&#41;</span>: &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ending = word<span style="color: black;">&#91;</span>-<span style="color: #ff4500;">3</span>:<span style="color: black;">&#93;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># get the last 3 letters</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># if we've already seen this number, append to list</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> ending <span style="color: #ff7700;font-weight:bold;">in</span> source_endings:&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> word <span style="color: #ff7700;font-weight:bold;">in</span> source_endings<span style="color: black;">&#91;</span>ending<span style="color: black;">&#93;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ignore = <span style="color: #483d8b;">&quot;true&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source_endings<span style="color: black;">&#91;</span>ending<span style="color: black;">&#93;</span>.<span style="color: black;">append</span><span style="color: black;">&#40;</span>word<span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># append word to the value of that number</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># looks like {'ing':['thing','biging']...}&nbsp; </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source_endings<span style="color: black;">&#91;</span>ending<span style="color: black;">&#93;</span> = <span style="color: black;">&#91;</span>word<span style="color: black;">&#93;</span> &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># specify that a new list is made</span><br />
<br />
<span style="color: #808080; font-style: italic;"># print source_endings</span><br />
<br />
<span style="color: #808080; font-style: italic;"># source_a will have values of strings begining with the letter a</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> line <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>source_file<span style="color: black;">&#41;</span>: &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># reading lines from major_dep.txt</span><br />
&nbsp; &nbsp; line = line.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> match_obj <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">finditer</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;(<span style="color: #000099; font-weight: bold;">\b</span>[Aa]<span style="color: #000099; font-weight: bold;">\b</span>|<span style="color: #000099; font-weight: bold;">\b</span>[Aa]n<span style="color: #000099; font-weight: bold;">\b</span>) (.{2,})(<span style="color: #000099; font-weight: bold;">\.</span>)&quot;</span>, line<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; a_something1 = match_obj.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># loops through each of the words</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; a_something2 = match_obj.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># loops through each of the words &nbsp; &nbsp; &nbsp; </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; words = a_something2.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; num_words = <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>words<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># print a_something1 +&quot; &quot;+ a_something2</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># print num_words</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> num_words <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">1</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># check to make sure we have a large word</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a_len = <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>words<span style="color: black;">&#41;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># get the last 3 letters</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># if we've already seen this number, append to list</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> a_len <span style="color: #ff7700;font-weight:bold;">in</span> source_a: &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> a_something2 <span style="color: #ff7700;font-weight:bold;">in</span> source_a<span style="color: black;">&#91;</span>a_len<span style="color: black;">&#93;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ignore = <span style="color: #483d8b;">&quot;true&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source_a<span style="color: black;">&#91;</span>a_len<span style="color: black;">&#93;</span>.<span style="color: black;">append</span><span style="color: black;">&#40;</span>a_something1+<span style="color: #483d8b;">&quot; &quot;</span>+a_something2<span style="color: black;">&#41;</span> &nbsp; <span style="color: #808080; font-style: italic;"># append word to the value of that number</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># looks like {'ing':['thing','biging']...}&nbsp; </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source_a<span style="color: black;">&#91;</span>a_len<span style="color: black;">&#93;</span> = <span style="color: black;">&#91;</span>a_something1+<span style="color: #483d8b;">&quot; &quot;</span>+a_something2<span style="color: black;">&#93;</span> &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># specify that a new list is made</span><br />
<span style="color: #808080; font-style: italic;"># print source_a</span><br />
<br />
<br />
<br />
<br />
<br />
<br />
<span style="color: #808080; font-style: italic;"># read each line from standard input; split line into words; for each word,</span><br />
<span style="color: #808080; font-style: italic;"># get a random word beginning with the same letter from source_alpha</span><br />
<br />
<br />
replace_1 = source_endings<span style="color: black;">&#91;</span><span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span> source_endings.<span style="color: black;">keys</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span> <span style="color: #808080; font-style: italic;"># how do I delete keys with too little values?</span><br />
replace_you = <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>replace_1<span style="color: black;">&#41;</span><br />
replace_2 = source_alpha<span style="color: black;">&#91;</span><span style="color: #dc143c;">random</span>.<span style="color: black;">randrange</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">2</span>,<span style="color: #ff4500;">6</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><br />
replace_me&nbsp; = <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>replace_2<span style="color: black;">&#41;</span><br />
replace_3 = source_alpha<span style="color: black;">&#91;</span><span style="color: #dc143c;">random</span>.<span style="color: black;">randrange</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">4</span>,<span style="color: #ff4500;">8</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><br />
replace_love&nbsp; &nbsp; = <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>replace_3<span style="color: black;">&#41;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># read each line from standard input; split line into words; for each word,</span><br />
<span style="color: #808080; font-style: italic;"># get a random word beginning with the same letter from source_alpha</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> line <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdin</span>:<br />
&nbsp; &nbsp; line = line.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; line = <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\b</span>[Aa] h.{2,}&quot;</span>, <span style="color: #483d8b;">&quot;xxx&quot;</span>, line<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; line = <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\b</span>[Aa] kiss&quot;</span>, <span style="color: #483d8b;">&quot;kiss&quot;</span>, line<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; line = <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\b</span>[Aa] g.{2,}&quot;</span>, <span style="color: #483d8b;">&quot;yyy&quot;</span>, line<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; words = line.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; output = <span style="color: #483d8b;">&quot;&quot;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> word <span style="color: #ff7700;font-weight:bold;">in</span> words:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>word<span style="color: black;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lengthWord = <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>word<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> lengthWord <span style="color: #ff7700;font-weight:bold;">in</span> source_alpha:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> lengthWord <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span>:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source_words = source_alpha<span style="color: black;">&#91;</span>lengthWord+<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;[yY]ou&quot;</span>, word<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output += replace_you<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">elif</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;[mM]e&quot;</span>, word<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output += replace_me<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">elif</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;t<span style="color: #000099; font-weight: bold;">\w</span><span style="color: #000099; font-weight: bold;">\w</span><span style="color: #000099; font-weight: bold;">\b</span>&quot;</span>, word<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rhyme = <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>replace_1<span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># make sure it's different than replace_you</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output += rhyme<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">elif</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;xxx&quot;</span>, word<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source_words2 = source_a<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output += &nbsp;<span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>source_words2<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">elif</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;kiss&quot;</span>, word<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source_words2 = source_a<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output += &nbsp;<span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>source_words2<span style="color: black;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">elif</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;yyy&quot;</span>, word<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source_words3 = source_a<span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output += <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>source_words3<span style="color: black;">&#41;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>: &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output += <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>source_words<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output += word<br />
&nbsp; &nbsp; &nbsp; &nbsp; output += <span style="color: #483d8b;">&quot; &quot;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> output</div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.tamarziv.com/itp/barneys-regular-depression-not-yet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>W4-Barney is dead</title>
		<link>http://www.tamarziv.com/itp/barney-is-down/</link>
		<comments>http://www.tamarziv.com/itp/barney-is-down/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 20:27:56 +0000</pubDate>
		<dc:creator>tamarziv</dc:creator>
				<category><![CDATA[H79.2778 - Reading and Writing Electronic Text]]></category>

		<guid isPermaLink="false">http://www.tamarziv.com/itp/?p=414</guid>
		<description><![CDATA[<blockquote>I with you
You mood me
death a drawn sleep,
than a death big hug
and a than with me to some
least you say you have me too 
</blockquote>
My program this week is based on alpha_replace and attempts to exploit the absurd innocence of <a href="http://www.stlyrics.com/songs/d/disney6472/iloveyoubarney511798.html" target="new">Barney</a>, and cross it over with a dictionary built out of the <a href="http://en.wikipedia.org/wiki/Diagnostic_and_Statistical_Manual_of_Mental_Disorders" target="new">DSM-IV</a> section regarding major depression. ]]></description>
			<content:encoded><![CDATA[<blockquote><p>I with you<br />
You mood me<br />
death a drawn sleep,<br />
than a death big hug<br />
and a than with me to some<br />
least you say you have me too </p></blockquote>
<p></br><br />
</br></p>
<blockquote><p>I which you<br />
You which me<br />
nearly a making persist<br />
areas a either big hug<br />
and a &#8220;down &#8220;down me to death<br />
sleep, you say you every me too </p></blockquote>
<p></br><br />
</br></p>
<blockquote><p>being when<br />
from every<br />
having weight amount,<br />
sleep person loss mood<br />
when Major other loss<br />
nearly lose when with abuse Many </p></blockquote>
<p></br><br />
</br></p>
<blockquote><p>
I being they<br />
with twice can<br />
plays, a think, colitis<br />
gains a person lose when<br />
when a noted being may and they<br />
abate. that with make prior for with </p></blockquote>
<p></br><br />
</br></p>
<p><strong>Program does:</strong> My program this week is based on alpha_replace and attempts to exploit the absurd innocence of <a href="http://www.stlyrics.com/songs/d/disney6472/iloveyoubarney511798.html" target="new">Barney</a>, and cross it over with a dictionary built out of the <a href="http://en.wikipedia.org/wiki/Diagnostic_and_Statistical_Manual_of_Mental_Disorders" target="new">DSM-IV</a> section regarding major depression. </p>
<p><strong>Program gets:</strong> input from an OCR version of the DSM chapter, breaks it into dictionary entries according to the number of letters in each word as keys, each key is assigned a list of words of the set key&#8217;s length. The program also reads in a file </p>
<p><strong>Program outputs:</strong> and replaces words from the original song which are more than 2 characters long with those from the dictionary (the word taken from the dictionary is one character longer than the source word) and prints out a morbid ditty as an output. Filtering is performed on the values in the dictionary to remove frequently used words such as &#8220;Major&#8221;, due to the capricious nature of the OCR translation, further filtering is needed to remove the OCR&#8217;s faulty translation and other characters and sections mentioned in the text that impair the poetic nature of the outcome, regular expressions would probably help here&#8230; </p>
<p><strong>What is does not do:</strong> is manage to bring out enough of the barniesque into the end result, thus not really achieving it&#8217;s goal, it would take some more precision in the selection process on the string level, rather than just using a random method, in fact, most of the poems this code generate are useless at the moment, hopefully I&#8217;ll manage improving on that in the future. The biggest challenge in this however, was the attempt to exclude specific strings off the list of each key&#8217;s value, that was a partial success since I didn&#8217;t manage excluding substrings, only full words within the list. </p>
<p></br><br />
</br></p>
<div class="codecolorer-container python blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># builds dictionary from source text, and replaces words from a different text which start with the same letter</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">random</span><br />
<br />
source_len = <span style="color: #008000;">dict</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># python len_replace8.py major_dep.txt &lt; barney.txt </span><br />
source_file = <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># first argument passed on command line, sys.argv[0] will be the name of the script file</span><br />
<br />
ignoreList = <span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;)&quot;</span>, <span style="color: #483d8b;">&quot;Major&quot;</span>, <span style="color: #483d8b;">&quot;major&quot;</span><span style="color: black;">&#93;</span><br />
ignoreIndex = <span style="color: #008000;">int</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
ignoreIndex = <span style="color: #ff4500;">0</span><br />
<br />
<br />
<span style="color: #808080; font-style: italic;"># read each line from source file; split each line into words; store each</span><br />
<span style="color: #808080; font-style: italic;"># word in the source_alpha dictionary, according to which letter it starts with</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> line <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>source_file<span style="color: black;">&#41;</span>: &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># reading lines from major_dep.txt</span><br />
&nbsp; &nbsp; line = line.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> thing <span style="color: #ff7700;font-weight:bold;">in</span> ignoreList:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> thing <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #ff7700;font-weight:bold;">in</span> line:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; words = line.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> word <span style="color: #ff7700;font-weight:bold;">in</span> words:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># loops through each of the words &nbsp; &nbsp; &nbsp; </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>word<span style="color: black;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">2</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># check to make sure we have a large word</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lengthWord = <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>word<span style="color: black;">&#41;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># get first letter of word</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># if we've already seen this number, append to list</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> lengthWord <span style="color: #ff7700;font-weight:bold;">in</span> source_len: &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source_len<span style="color: black;">&#91;</span>lengthWord<span style="color: black;">&#93;</span>.<span style="color: black;">append</span><span style="color: black;">&#40;</span>word<span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># append word to the value of that letter</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># looks like {'3':['the','big']...}</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source_len<span style="color: black;">&#91;</span>lengthWord<span style="color: black;">&#93;</span> = <span style="color: black;">&#91;</span>word<span style="color: black;">&#93;</span> &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># specify that a new list is made</span><br />
<br />
<span style="color: #808080; font-style: italic;"># source_alpha will be a dictionary whose keys are strings and whose values</span><br />
<span style="color: #808080; font-style: italic;"># are lists.</span><br />
<span style="color: #808080; font-style: italic;"># uncomment this to see what the data structure created above looks like</span><br />
<span style="color: #808080; font-style: italic;">#print source_alpha</span><br />
<br />
<span style="color: #808080; font-style: italic;"># read each line from standard input; split line into words; for each word,</span><br />
<span style="color: #808080; font-style: italic;"># get a random word beginning with the same letter from source_alpha</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> line <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdin</span>:<br />
&nbsp; line = line.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; words = line.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; output = <span style="color: #483d8b;">&quot;&quot;</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> word <span style="color: #ff7700;font-weight:bold;">in</span> words:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>word<span style="color: black;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span>:<br />
&nbsp; &nbsp; &nbsp; lengthWord = <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>word<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> lengthWord <span style="color: #ff7700;font-weight:bold;">in</span> source_len:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> lengthWord <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">2</span>: &nbsp; <span style="color: #808080; font-style: italic;"># only replace words with more than 2 chars (preserve some of the original structure)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source_words = source_len<span style="color: black;">&#91;</span>lengthWord+<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> &nbsp;<span style="color: #808080; font-style: italic;"># output a value a char longer than the original</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output += <span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>source_words<span style="color: black;">&#41;</span> &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># randomly choose a string from the value list</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output += word<br />
&nbsp; &nbsp; &nbsp; &nbsp; output += <span style="color: #483d8b;">&quot; &quot;</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> output</div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.tamarziv.com/itp/barney-is-down/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>W03-OrbitalBrush</title>
		<link>http://www.tamarziv.com/itp/w03-orbitalbrush/</link>
		<comments>http://www.tamarziv.com/itp/w03-orbitalbrush/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 17:13:38 +0000</pubDate>
		<dc:creator>tamarziv</dc:creator>
				<category><![CDATA[H79.2273 - The World Pixel by Pixel]]></category>

		<guid isPermaLink="false">http://www.tamarziv.com/itp/?p=409</guid>
		<description><![CDATA[This app is a simple manipulation of <a href="http://itp.nyu.edu/pixels/s10/Class_2/PxP-Paint-Pixels.zip" target='new'>PxP Paint Pixels</a>. The brush itself is a gradient, determined by the distance of the pixels within the brush from the location of the mouse, the brush itself is then offset from the mouse location and orbits around it, in order to do so, I have moved it to the draw loop. The arrow keys mapped to control the brush size.]]></description>
			<content:encoded><![CDATA[<p><a href='http://itp.nyu.edu/~tz346/PxP/w03/PxP_W03-orbitalBrush.zip' >OrbitalBrush Source</a> | <a href='http://itp.nyu.edu/~tz346/PxP/w03/OrbitalBrush.app.zip'  target='new'>Download the app</a></p>
<p><img src='http://www.tamarziv.com/itp/wp-content/themes/tma/images/uploads/orbitBrush.jpg' alt='PXP'  width=650><br />
</br><br />
This app is a simple manipulation of <a href="http://itp.nyu.edu/pixels/s10/Class_2/PxP-Paint-Pixels.zip" target='new'>PxP Paint Pixels</a>. The brush itself is a gradient, determined by the distance of the pixels within the brush from the location of the mouse, the brush itself is then offset from the mouse location and orbits around it, in order to do so, I have moved it to the draw loop. The arrow keys mapped to control the brush size.</p>
<p></br><br />
</br></p>
<div class="codecolorer-container cpp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff0000; font-style: italic;">/*&nbsp; &nbsp; &nbsp; ITP Pixel by Pixel <br />
&nbsp; &nbsp; &nbsp; &nbsp; Paint pixels<br />
&nbsp; &nbsp; &nbsp; &nbsp; drag mouse to paint<br />
&nbsp; &nbsp; &nbsp; &nbsp; Danny Rozin 2010<br />
*/</span><br />
<br />
<span style="color: #339900;">#include &quot;testApp.h&quot;</span><br />
<span style="color: #0000ff;">int</span> R<span style="color: #000080;">=</span><span style="color: #0000dd;">255</span>,G<span style="color: #000080;">=</span><span style="color: #0000dd;">255</span>,B<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span>, brushSize <span style="color: #000080;">=</span><span style="color: #0000dd;">20</span>, percent <span style="color: #000080;">=</span> <span style="color: #0000dd;">550</span><span style="color: #008080;">;</span> <span style="color: #0000ff;">float</span> theta <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> &nbsp;<br />
<span style="color: #666666;">//************** Everything you want to happen once in the begining, but don't draw anything to the creen here a it will not work ****************</span><br />
<br />
<span style="color: #0000ff;">void</span> testApp<span style="color: #008080;">::</span><span style="color: #007788;">setup</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>&nbsp; &nbsp;<br />
&nbsp; &nbsp; ofBackground<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">255</span>,<span style="color: #0000dd;">255</span>,<span style="color: #0000dd;">255</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// background color </span><br />
&nbsp; &nbsp; ofSetFrameRate<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">30</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> &nbsp;<br />
&nbsp; &nbsp; width <span style="color: #000080;">=</span> ofGetWidth<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; height <span style="color: #000080;">=</span> ofGetHeight<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; ourTexture <span style="color: #000080;">=</span> <span style="color: #000040;">*</span> <span style="color: #0000dd;">new</span> ofTexture<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// create an ofTexture to hold our image info</span><br />
&nbsp; &nbsp; ourTexture.<span style="color: #007788;">allocate</span><span style="color: #008000;">&#40;</span>width, height, GL_RGB<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// allocate memory for the ofTextue (This is RGB no Alpha)</span><br />
&nbsp; &nbsp; ourPixels <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> <span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">char</span><span style="color: #008000;">&#91;</span>width<span style="color: #000040;">*</span>height<span style="color: #000040;">*</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// create a pixel array to keep our processed pixel data (RGB, no Alpha).</span><br />
&nbsp; &nbsp; ofEnableAlphaBlending<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// turn on alpha blending</span><br />
&nbsp; &nbsp; ofEnableSmoothing<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #666666;">//******************This time we put most of the interesting stuff into the mouseDragged method cause we want to paint only when we drag************</span><br />
<span style="color: #0000ff;">void</span> testApp<span style="color: #008080;">::</span><span style="color: #007788;">mouseDragged</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y, <span style="color: #0000ff;">int</span> button<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span> &nbsp; <br />
<span style="color: #0000ff;">float</span> mouseXOff <span style="color: #000080;">=</span> mouseX<span style="color: #000040;">+</span><span style="color: #0000dd;">sin</span><span style="color: #008000;">&#40;</span>ofRadToDeg<span style="color: #008000;">&#40;</span>theta<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #0000ff;">float</span> mouseYOff <span style="color: #000080;">=</span> mouseY<span style="color: #000040;">+</span><span style="color: #0000dd;">sin</span><span style="color: #008000;">&#40;</span>ofRadToDeg<span style="color: #008000;">&#40;</span>theta<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
<span style="color: #666666;">//&nbsp; R+=ofRandom(-10,10);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // let the R,G,B values wonder arround randomly...</span><br />
<span style="color: #666666;">//&nbsp; R=ofClamp(R,0,255); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // but make sure they are still 0- 255</span><br />
<span style="color: #666666;">//&nbsp; </span><br />
<span style="color: #666666;">//&nbsp; G+=ofRandom(-10,10);</span><br />
<span style="color: #666666;">//&nbsp; G=ofClamp(G,0,255);</span><br />
<span style="color: #666666;">//&nbsp; </span><br />
<span style="color: #666666;">//&nbsp; B+=ofRandom(-10,10);</span><br />
<span style="color: #666666;">//&nbsp; B=ofClamp(B,0,255);</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; ofEnableSmoothing<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0000ff;">int</span> colorOffset <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> x<span style="color: #000080;">=</span>mouseXOff<span style="color: #000040;">-</span>brushSize<span style="color: #008080;">;</span>x<span style="color: #000080;">&lt;</span> mouseXOff<span style="color: #000040;">+</span>brushSize<span style="color: #008080;">;</span>x<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// repeat loop of 50 x 50 pixels around the mouse</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> y<span style="color: #000080;">=</span>mouseYOff<span style="color: #000040;">-</span>brushSize<span style="color: #008080;">;</span>y<span style="color: #000080;">&lt;</span> mouseYOff<span style="color: #000040;">+</span>brushSize<span style="color: #008080;">;</span>y<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// if (ofRandom(0,1000) &gt; percent){ </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>x<span style="color: #000080;">&gt;</span><span style="color: #0000dd;">0</span> &nbsp;<span style="color: #000040;">&amp;&amp;</span> y<span style="color: #000080;">&gt;</span><span style="color: #0000dd;">0</span> <span style="color: #000040;">&amp;&amp;</span> y<span style="color: #000080;">&lt;</span> height<span style="color: #008000;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// check that we are not accessing pixels outside the bounds of our array &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>ofDist<span style="color: #008000;">&#40;</span>x,y,mouseXOff,mouseYOff<span style="color: #008000;">&#41;</span><span style="color: #000080;">&lt;</span> brushSize<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// constrict the brush to a circle by checking that the pixel is not more than... </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">int</span> colorOffset <span style="color: #000080;">=</span> ofMap<span style="color: #008000;">&#40;</span>ofDist<span style="color: #008000;">&#40;</span>x,y,mouseXOff,mouseYOff<span style="color: #008000;">&#41;</span>,<span style="color: #0000dd;">0</span>,brushSize,<span style="color: #0000dd;">0</span>,<span style="color: #0000dd;">255</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; R<span style="color: #000080;">=</span><span style="color: #0000dd;">255</span><span style="color: #000040;">-</span>colorOffset<span style="color: #008080;">;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// let the R,G,B values wonder arround randomly...</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; R<span style="color: #000080;">=</span>ofClamp<span style="color: #008000;">&#40;</span>R,<span style="color: #0000dd;">10</span>,<span style="color: #0000dd;">255</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// but make sure they are still 0- 255</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; G<span style="color: #000080;">=</span><span style="color: #0000dd;">255</span><span style="color: #000040;">-</span>colorOffset<span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; G<span style="color: #000080;">=</span>ofClamp<span style="color: #008000;">&#40;</span>G,<span style="color: #0000dd;">10</span>,<span style="color: #0000dd;">255</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; B<span style="color: #000080;">=</span><span style="color: #0000dd;">255</span><span style="color: #000040;">-</span>colorOffset<span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; B<span style="color: #000080;">=</span>ofClamp<span style="color: #008000;">&#40;</span>B,<span style="color: #0000dd;">10</span>,<span style="color: #0000dd;">255</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ourSetPixel<span style="color: #008000;">&#40;</span>x,y,R,G,B,width,ourPixels<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #008000;">&#125;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">//&nbsp; brushSize away from the mouse &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">//} </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span> &nbsp; <br />
<br />
&nbsp; &nbsp; <br />
<span style="color: #008000;">&#125;</span><br />
<br />
<br />
<span style="color: #666666;">//********************************************* Code in draw() execute every frame, &nbsp;**********************************************************</span><br />
<span style="color: #0000ff;">void</span> testApp<span style="color: #008080;">::</span><span style="color: #007788;">draw</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span> &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0000ff;">float</span> offset <span style="color: #000080;">=</span> <span style="color: #0000dd;">2</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">float</span> mouseXOff <span style="color: #000080;">=</span> mouseX<span style="color: #000040;">+</span>offset<span style="color: #000040;">*</span>brushSize<span style="color: #000040;">*</span><span style="color: #0000dd;">cos</span><span style="color: #008000;">&#40;</span>ofRadToDeg<span style="color: #008000;">&#40;</span>theta<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #0000ff;">float</span> mouseYOff <span style="color: #000080;">=</span> mouseY<span style="color: #000040;">+</span>offset<span style="color: #000040;">*</span>brushSize<span style="color: #000040;">*</span><span style="color: #0000dd;">sin</span><span style="color: #008000;">&#40;</span>ofRadToDeg<span style="color: #008000;">&#40;</span>theta<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <br />
<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0000ff;">int</span> colorOffset <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> x<span style="color: #000080;">=</span>mouseXOff<span style="color: #000040;">-</span>brushSize<span style="color: #008080;">;</span>x<span style="color: #000080;">&lt;</span> mouseXOff<span style="color: #000040;">+</span>brushSize<span style="color: #008080;">;</span>x<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// repeat loop of 50 x 50 pixels around the mouse</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> y<span style="color: #000080;">=</span>mouseYOff<span style="color: #000040;">-</span>brushSize<span style="color: #008080;">;</span>y<span style="color: #000080;">&lt;</span> mouseYOff<span style="color: #000040;">+</span>brushSize<span style="color: #008080;">;</span>y<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// if (ofRandom(0,1000) &gt; percent){ </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>x<span style="color: #000080;">&gt;</span><span style="color: #0000dd;">0</span> &nbsp;<span style="color: #000040;">&amp;&amp;</span> y<span style="color: #000080;">&gt;</span><span style="color: #0000dd;">0</span> <span style="color: #000040;">&amp;&amp;</span> y<span style="color: #000080;">&lt;</span> height<span style="color: #008000;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// check that we are not accessing pixels outside the bounds of our array &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>ofDist<span style="color: #008000;">&#40;</span>x,y,mouseXOff,mouseYOff<span style="color: #008000;">&#41;</span><span style="color: #000080;">&lt;</span> brushSize<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// constrict the brush to a circle by checking that the pixel is not more than... </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">int</span> colorOffset <span style="color: #000080;">=</span> ofMap<span style="color: #008000;">&#40;</span>ofDist<span style="color: #008000;">&#40;</span>x,y,mouseXOff,mouseYOff<span style="color: #008000;">&#41;</span>,<span style="color: #0000dd;">0</span>,brushSize,<span style="color: #0000dd;">0</span>,<span style="color: #0000dd;">255</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; R<span style="color: #000080;">=</span><span style="color: #0000dd;">255</span><span style="color: #000040;">-</span>colorOffset<span style="color: #008080;">;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// let the R,G,B values wonder arround randomly...</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; R<span style="color: #000080;">=</span>ofClamp<span style="color: #008000;">&#40;</span>R,<span style="color: #0000dd;">0</span>,<span style="color: #0000dd;">255</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// but make sure they are still 0- 255</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; G<span style="color: #000080;">=</span><span style="color: #0000dd;">255</span><span style="color: #000040;">-</span>colorOffset<span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; G<span style="color: #000080;">=</span>ofClamp<span style="color: #008000;">&#40;</span>G,<span style="color: #0000dd;">0</span>,<span style="color: #0000dd;">255</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; B<span style="color: #000080;">=</span><span style="color: #0000dd;">255</span><span style="color: #000040;">-</span>colorOffset<span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; B<span style="color: #000080;">=</span>ofClamp<span style="color: #008000;">&#40;</span>B,<span style="color: #0000dd;">0</span>,<span style="color: #0000dd;">255</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ourSetPixel<span style="color: #008000;">&#40;</span>x,y,R,G,B,width,ourPixels<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #008000;">&#125;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">//&nbsp; brushSize away from the mouse &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">//} </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span> theta<span style="color: #000040;">+</span><span style="color: #000080;">=</span> <span style="color:#800080;">0.0001</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span> &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; ourTexture.<span style="color: #007788;">loadData</span><span style="color: #008000;">&#40;</span>ourPixels, width, height, GL_RGB<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// This loads the pixels array into the OF texture</span><br />
&nbsp; &nbsp; ourTexture.<span style="color: #007788;">draw</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span>,<span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// this draws the texture to the screen</span><br />
&nbsp; &nbsp; <span style="color: #0000dd;">printf</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;percent = %i <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>, percent<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// prints our variable to the console</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; ofEllipse<span style="color: #008000;">&#40;</span>mouseXOff, mouseYOff, <span style="color: #0000dd;">10</span>, <span style="color: #0000dd;">10</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<span style="color: #008000;">&#125;</span><br />
<br />
<br />
<span style="color: #666666;">//********************** &nbsp;Pixel by Pixel course method that sets a pixel RGB in an x, y position in a pixel array ***********************</span><br />
<span style="color: #0000ff;">void</span> testApp<span style="color: #008080;">::</span><span style="color: #007788;">ourSetPixel</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> horizontal,<span style="color: #0000ff;">int</span> vertical,<span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">char</span> R,<span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">char</span> G,<span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">char</span> B,<span style="color: #0000ff;">int</span> arrayWidth, <span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">char</span> pixels<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">int</span> thisPixel <span style="color: #000080;">=</span> <span style="color: #0000dd;">3</span><span style="color: #000040;">*</span><span style="color: #008000;">&#40;</span>arrayWidth <span style="color: #000040;">*</span> vertical <span style="color: #000040;">+</span>horizontal<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; pixels<span style="color: #008000;">&#91;</span>thisPixel<span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>R<span style="color: #008080;">;</span><br />
&nbsp; &nbsp; pixels<span style="color: #008000;">&#91;</span>thisPixel<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>G<span style="color: #008080;">;</span><br />
&nbsp; &nbsp; pixels<span style="color: #008000;">&#91;</span>thisPixel<span style="color: #000040;">+</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>B<span style="color: #008080;">;</span><br />
<span style="color: #008000;">&#125;</span><br />
<br />
<br />
<span style="color: #666666;">//--------------------------------------------------------------</span><br />
<span style="color: #0000ff;">void</span> testApp<span style="color: #008080;">::</span><span style="color: #007788;">keyPressed</span> &nbsp;<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> key<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>key <span style="color: #000080;">==</span> &nbsp;OF_KEY_UP<span style="color: #008000;">&#41;</span> brushSize<span style="color: #000040;">++</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>key <span style="color: #000080;">==</span> &nbsp;OF_KEY_DOWN<span style="color: #008000;">&#41;</span> brushSize<span style="color: #000040;">--</span><span style="color: #008080;">;</span><br />
<br />
<span style="color: #008000;">&#125;</span><br />
<span style="color: #0000ff;">void</span> testApp<span style="color: #008080;">::</span><span style="color: #007788;">update</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><span style="color: #008000;">&#125;</span><br />
<span style="color: #0000ff;">void</span> testApp<span style="color: #008080;">::</span><span style="color: #007788;">mouseMoved</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y <span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span> <span style="color: #008000;">&#125;</span><br />
<span style="color: #0000ff;">void</span> testApp<span style="color: #008080;">::</span><span style="color: #007788;">keyReleased</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> key<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span> &nbsp;<span style="color: #008000;">&#125;</span><br />
<span style="color: #0000ff;">void</span> testApp<span style="color: #008080;">::</span><span style="color: #007788;">mousePressed</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y, <span style="color: #0000ff;">int</span> button<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><span style="color: #008000;">&#125;</span><br />
<span style="color: #0000ff;">void</span> testApp<span style="color: #008080;">::</span><span style="color: #007788;">mouseReleased</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>&nbsp; <span style="color: #008000;">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.tamarziv.com/itp/w03-orbitalbrush/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>W2-Torbreck Australian</title>
		<link>http://www.tamarziv.com/itp/w2-torbreck-australian/</link>
		<comments>http://www.tamarziv.com/itp/w2-torbreck-australian/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 23:16:21 +0000</pubDate>
		<dc:creator>tamarziv</dc:creator>
				<category><![CDATA[H79.2778 - Reading and Writing Electronic Text]]></category>

		<guid isPermaLink="false">http://www.tamarziv.com/itp/?p=389</guid>
		<description><![CDATA[
<blockquote>excellent. This deep
drowning opens with a pleasant
well
drowning with this
dry and quite prolonged. This
drowning the will enhance
the need for more of it. I</blockquote>

The program generates luscious, dry and full bodied poetry from wine reviews. The program expects a text file, cuts the line after "is" is found and prints, if "is" is not found it searches for "wine" and replaces it with "drowning", The resulting poem is then outputted into a text file. Source wine review is found <a href="http://www.kenswineguide.com/wine.php?wine=2457">here</a>]]></description>
			<content:encoded><![CDATA[<p><strong>Torbreck Australian</strong></p>
<blockquote><p>excellent. This deep<br />
drowning opens with a pleasant<br />
well<br />
drowning with this<br />
dry and quite prolonged. This<br />
drowning the will enhance<br />
the need for more of it. I</p></blockquote>
<p><span id="more-389"></span></p>
<p><strong>Description:</strong><br />
The program generates luscious, dry and full bodied poetry from wine reviews. It&#8217;s quite simple, and attempts to exploit the form of language used in this kind of writing and how one can quite simply push it into the realm of cheap romantic poetry. The program expects a text file, cuts the line after &#8220;is&#8221; is found and prints, if &#8220;is&#8221; is not found it searches for &#8220;wine&#8221; and replaces it with &#8220;drowning&#8221;, The resulting poem is then outputted into a text file. Source wine review is found <a href="http://www.kenswineguide.com/wine.php?wine=2457">here</a><br />
</br><br />
</br><br />
<strong>Code:</strong><br />
</br></br></p>
<div class="codecolorer-container python blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span><br />
searchstr = <span style="color: #483d8b;">&quot; is &quot;</span><br />
searchstr2 = <span style="color: #483d8b;">&quot; wine &quot;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> line <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdin</span>:<br />
&nbsp; line = line.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; offset = line.<span style="color: black;">find</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot; is &quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; offset2 = line.<span style="color: black;">find</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot; wine &quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> searchstr <span style="color: #ff7700;font-weight:bold;">in</span> line:<br />
&nbsp; &nbsp; &nbsp;<span style="color: #ff7700;font-weight:bold;">print</span> line<span style="color: black;">&#91;</span>offset+<span style="color: #ff4500;">4</span>:<span style="color: black;">&#93;</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">elif</span> searchstr2 <span style="color: #ff7700;font-weight:bold;">in</span> line:<br />
&nbsp; &nbsp; line = line.<span style="color: black;">replace</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'wine'</span>, <span style="color: #483d8b;">'drowning'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> line<span style="color: black;">&#91;</span>offset2+<span style="color: #ff4500;">1</span>:<span style="color: black;">&#93;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.tamarziv.com/itp/w2-torbreck-australian/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>W02-Pixel x Pixel</title>
		<link>http://www.tamarziv.com/itp/w02-pixel-x-pixel/</link>
		<comments>http://www.tamarziv.com/itp/w02-pixel-x-pixel/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 18:22:44 +0000</pubDate>
		<dc:creator>tamarziv</dc:creator>
				<category><![CDATA[H79.2273 - The World Pixel by Pixel]]></category>

		<guid isPermaLink="false">http://www.tamarziv.com/itp/?p=349</guid>
		<description><![CDATA[Basically starting off the animated circles example, but using triangles, a random position for one vertex, and two animated vertexes shared by all  triangles, when the two shared vertexes combine, the triangle becomes a line and therefore create a gradation and shift into white.]]></description>
			<content:encoded><![CDATA[<p><a href='http://itp.nyu.edu/~tz346/PxP/w02/PxP_Tri.zip' >Triangles</a> | <a href='http://itp.nyu.edu/~tz346/PxP/w02/PxP_Tri.zip'  target='new'>Download the apps</a></p>
<p><img src='http://www.tamarziv.com/itp/wp-content/themes/tma/images/uploads/pxp_02.jpg' alt='PXP'  width=650></p>
<p>Basically starting off the animated circles example, but using triangles, a random position for one vertex, and two animated vertexes shared by all  triangles, when the two shared vertexes combine, the triangle becomes a line and therefore create a gradation and shift into white.<br />
</br><br />
</br></p>
<div class="codecolorer-container cpp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff0000; font-style: italic;">/*&nbsp; &nbsp; &nbsp; ITP Pixel by Pixel <br />
&nbsp; &nbsp; &nbsp; &nbsp; circles<br />
&nbsp; &nbsp; &nbsp; &nbsp; move mouse to interact<br />
&nbsp; &nbsp; &nbsp; &nbsp; Danny Rozin 2009<br />
*/</span><br />
<br />
<span style="color: #339900;">#include &quot;testApp.h&quot; </span><br />
<br />
<span style="color: #666666;">//**** if you are lazy you can put some global variables here, but it is bad practice and will not work for complex data types (put in testApp.h) &nbsp;********</span><br />
<span style="color: #0000ff;">const</span> <span style="color: #0000ff;">int</span> numOfCircles<span style="color: #000080;">=</span><span style="color: #0000dd;">1000</span><span style="color: #008080;">;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// creating a constant integer and giving it a value, </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// In C when you create an array you have to give it a constant not a variable</span><br />
<span style="color: #0000ff;">int</span> positionsX<span style="color: #008000;">&#91;</span>numOfCircles<span style="color: #008000;">&#93;</span>, positionsY<span style="color: #008000;">&#91;</span>numOfCircles<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// two arrays to hold the locations of our circles</span><br />
<span style="color: #0000ff;">float</span> angle <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> <br />
<span style="color: #666666;">// ofTriangle(float x1, float y1, float x2, float y2, float x3, float y3)</span><br />
<br />
<span style="color: #666666;">//************** Everything you want to happen once in the begining, but don't draw anything to the screen here a it will not work ****************</span><br />
<span style="color: #0000ff;">void</span> testApp<span style="color: #008080;">::</span><span style="color: #007788;">setup</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>&nbsp; &nbsp;<br />
&nbsp; &nbsp; ofBackground<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">255</span>,<span style="color: #0000dd;">255</span>,<span style="color: #0000dd;">255</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// background color </span><br />
&nbsp; &nbsp; ofSetColor<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span>,<span style="color: #0000dd;">0</span>,<span style="color: #0000dd;">0</span>,<span style="color: #0000dd;">10</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// color of lines and fills</span><br />
&nbsp; &nbsp; ofEnableAlphaBlending<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> &nbsp;<br />
&nbsp; &nbsp; ofEnableSmoothing<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> &nbsp;<br />
&nbsp; &nbsp; ofSetLineWidth<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> &nbsp;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;</span> numOfCircles<span style="color: #008080;">;</span>i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// we want our random positions to stay the same, so we put them into our </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; positionsX<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span> ofRandom<span style="color: #008000;">&#40;</span><span style="color: #000040;">-</span>ofGetWidth<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">*</span><span style="color: #0000dd;">2</span>,ofGetWidth<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">*</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#41;</span> <span style="color: #008080;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// global arrays, otherwise, the circles would randomize every frame and it would flicker</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; positionsY<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span> ofRandom<span style="color: #008000;">&#40;</span><span style="color: #000040;">-</span>ofGetHeight<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">*</span><span style="color: #0000dd;">2</span>,ofGetHeight<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">*</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#41;</span> <span style="color: #008080;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span><br />
<br />
<br />
<br />
<span style="color: #666666;">//********************************************* Code in draw() executes every frame, &nbsp;**********************************************************</span><br />
<span style="color: #0000ff;">void</span> testApp<span style="color: #008080;">::</span><span style="color: #007788;">draw</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span> &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>angle <span style="color: #000080;">&lt;=</span> <span style="color: #0000dd;">360</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">float</span> r <span style="color: #000080;">=</span> <span style="color:#800080;">30.0f</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">float</span> theta <span style="color: #000080;">=</span> angle<span style="color: #008080;">;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">float</span> radians <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span>angle <span style="color: #000040;">*</span> pi<span style="color: #008000;">&#41;</span><span style="color: #000040;">/</span><span style="color:#800080;">180.0</span><span style="color: #008080;">;</span> <br />
&nbsp; &nbsp; <span style="color: #0000ff;">float</span> offSetCenterX <span style="color: #000080;">=</span> r <span style="color: #000040;">*</span> <span style="color: #0000dd;">cos</span><span style="color: #008000;">&#40;</span>radians<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">float</span> offSetCenterY <span style="color: #000080;">=</span> r <span style="color: #000040;">*</span> <span style="color: #0000dd;">sin</span><span style="color: #008000;">&#40;</span>radians<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666;">// float offSetCenterX = 20 ;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;</span>numOfCircles<span style="color: #008080;">;</span>i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0000ff;">float</span> distance <span style="color: #000080;">=</span> <span style="color: #0000dd;">sqrt</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>positionsX<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #000040;">-</span> mouseX<span style="color: #008000;">&#41;</span><span style="color: #000040;">*</span> <span style="color: #008000;">&#40;</span>positionsX<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #000040;">-</span> mouseX<span style="color: #008000;">&#41;</span>&nbsp; <span style="color: #000040;">+</span> &nbsp; <span style="color: #008000;">&#40;</span>positionsY<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #000040;">-</span> mouseY<span style="color: #008000;">&#41;</span><span style="color: #000040;">*</span> <span style="color: #008000;">&#40;</span>positionsY<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #000040;">-</span> mouseY<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008080;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; ofFill<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// turn the fill on, we want black circles</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ofSetColor<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span>,<span style="color: #0000dd;">0</span>,<span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// ofSetColor(255-distance/3,255-distance/3,255-distance/3);&nbsp; &nbsp; &nbsp; &nbsp; // just for fun, make the circles darker as they grt distant</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">//ofCircle(positionsX[i] ,positionsY[i],distance/ 10);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; ofTriangle<span style="color: #008000;">&#40;</span>positionsX<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span>, positionsY<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span>, ofGetWidth<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">/</span><span style="color: #0000dd;">2</span><span style="color: #000040;">-</span>offSetCenterX<span style="color: #000040;">-</span>r<span style="color: #000040;">/</span><span style="color: #0000dd;">2</span>, ofGetHeight<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">/</span><span style="color: #0000dd;">2</span><span style="color: #000040;">-</span>offSetCenterX<span style="color: #000040;">-</span>r<span style="color: #000040;">/</span><span style="color: #0000dd;">2</span>, mouseX, mouseY<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">//ofTriangle(positionsX[i], positionsY[i], ofGetWidth()/2, ofGetHeight()/2, mouseX, mouseY);</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; ofNoFill<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// turn the fill of, we want to draw a white line around each circle</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ofSetColor<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">255</span>,<span style="color: #0000dd;">255</span>,<span style="color: #0000dd;">255</span>,<span style="color: #0000dd;">255</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; ofTriangle<span style="color: #008000;">&#40;</span>positionsX<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span>, positionsY<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span>, ofGetWidth<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">/</span><span style="color: #0000dd;">2</span><span style="color: #000040;">-</span>offSetCenterX<span style="color: #000040;">-</span>r<span style="color: #000040;">/</span><span style="color: #0000dd;">2</span>, ofGetHeight<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">/</span><span style="color: #0000dd;">2</span><span style="color: #000040;">-</span>offSetCenterX<span style="color: #000040;">-</span>r<span style="color: #000040;">/</span><span style="color: #0000dd;">2</span>, mouseX, mouseY<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">//ofTriangle(positionsX[i], positionsY[i], ofGetWidth()/2, ofGetHeight()/2, mouseX, mouseY);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">//ofTriangle(positionsX[i], positionsY[i], ofGetWidth()/2, ofGetHeight()/2, mouseX, mouseY);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">//ofCircle(positionsX[i] ,positionsY[i],distance/ 10);&nbsp; &nbsp; &nbsp; </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; angle <span style="color: #000040;">+</span><span style="color: #000080;">=</span> <span style="color:#800080;">0.001</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>angle <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span><span style="color: #008000;">&#125;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// display the result on the screen </span><br />
&nbsp; &nbsp; <span style="color: #0000dd;">printf</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;%f <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>, ofGetFrameRate<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// put the frame rate into the console </span><br />
<span style="color: #008000;">&#125;</span><br />
<br />
<br />
<br />
<br />
<span style="color: #666666;">//**************** Code in update() execute every frame, but don't draw anything here cause it won't work, in general put most stuff into draw() *************</span><br />
<span style="color: #0000ff;">void</span> testApp<span style="color: #008080;">::</span><span style="color: #007788;">update</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #666666;">//--------------------------------------------------------------</span><br />
<span style="color: #0000ff;">void</span> testApp<span style="color: #008080;">::</span><span style="color: #007788;">keyPressed</span> &nbsp;<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> key<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span> <span style="color: #008000;">&#125;</span><br />
<br />
<br />
<span style="color: #666666;">//--------------------------------------------------------------</span><br />
<span style="color: #0000ff;">void</span> testApp<span style="color: #008080;">::</span><span style="color: #007788;">keyReleased</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> key<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span> &nbsp;<span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #666666;">//--------------------------------------------------------------</span><br />
<span style="color: #0000ff;">void</span> testApp<span style="color: #008080;">::</span><span style="color: #007788;">mouseMoved</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y <span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span> <span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #666666;">//--------------------------------------------------------------</span><br />
<span style="color: #0000ff;">void</span> testApp<span style="color: #008080;">::</span><span style="color: #007788;">mouseDragged</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y, <span style="color: #0000ff;">int</span> button<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #666666;">//--------------------------------------------------------------</span><br />
<span style="color: #0000ff;">void</span> testApp<span style="color: #008080;">::</span><span style="color: #007788;">mousePressed</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y, <span style="color: #0000ff;">int</span> button<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span> &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #666666;">//--------------------------------------------------------------</span><br />
<span style="color: #0000ff;">void</span> testApp<span style="color: #008080;">::</span><span style="color: #007788;">mouseReleased</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>&nbsp; <span style="color: #008000;">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.tamarziv.com/itp/w02-pixel-x-pixel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>W01 &#8211; Fire Pixel</title>
		<link>http://www.tamarziv.com/itp/w01-fire-pixel/</link>
		<comments>http://www.tamarziv.com/itp/w01-fire-pixel/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 21:53:21 +0000</pubDate>
		<dc:creator>tamarziv</dc:creator>
				<category><![CDATA[H79.2273 - The World Pixel by Pixel]]></category>

		<guid isPermaLink="false">http://www.tamarziv.com/itp/?p=352</guid>
		<description><![CDATA[<iframe align="center" src="http://www.flickr.com/photos/poserama/sets/72157623179074269/show/" frameBorder="0" scrolling="no" width="100%" class="feat_content_iframe_land2"></iframe>]]></description>
			<content:encoded><![CDATA[<p><iframe align="center" src="http://www.flickr.com/photos/poserama/sets/72157623179074269/show/" frameBorder="0" scrolling="no" width="650" height=488 class="feat_content_iframe_land2"></iframe><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tamarziv.com/itp/w01-fire-pixel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>W11-14-Animation</title>
		<link>http://www.tamarziv.com/itp/w11-14-animation/</link>
		<comments>http://www.tamarziv.com/itp/w11-14-animation/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 20:25:29 +0000</pubDate>
		<dc:creator>tamarziv</dc:creator>
				<category><![CDATA[H79.2004 - Communications Lab]]></category>

		<guid isPermaLink="false">http://www.tamarziv.com/itp/?p=303</guid>
		<description><![CDATA[
Created by Julio Terra and myself
]]></description>
			<content:encoded><![CDATA[<p><object width="650" height="528"><param name="movie" value="http://www.youtube.com/v/_QVtSMCo8Aw&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/_QVtSMCo8Aw&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="650" height="528"></embed></object></p>
<p>Created by Julio Terra and myself</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tamarziv.com/itp/w11-14-animation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>W13-sonicPoetry</title>
		<link>http://www.tamarziv.com/itp/sonicpoetry/</link>
		<comments>http://www.tamarziv.com/itp/sonicpoetry/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 15:35:19 +0000</pubDate>
		<dc:creator>tamarziv</dc:creator>
				<category><![CDATA[H79.2301 - Introduction to Physical Computing]]></category>

		<guid isPermaLink="false">http://www.tamarziv.com/itp/?p=283</guid>
		<description><![CDATA[<iframe align="center" src="http://www.flickr.com/photos/poserama/sets/72157622946888790/show/" frameBorder="0" scrolling="no" width="100%" class="feat_content_iframe_land2"></iframe>]]></description>
			<content:encoded><![CDATA[<p> An electrically amplified typewriter, for composing and performing sonic poetry/prose/etc</p>
<p><iframe align="center" src="http://www.flickr.com/photos/poserama/sets/72157622946888790/show/" frameBorder="0" scrolling="no" width="650" height=488 class="feat_content_iframe_land2"></iframe><br/></p>
<p>Using a Remington portable typewriter, I plan to tap into the mechanical heart of the typewriter and extract and amplify the magnetic resonance generated by it&#8217;s usage. By positioning various triggers, strings and springs I hope to enhance it&#8217;s range of expression. All the different effects and pickups will be triggered by typing, so in effect, notation for the piece performed or composed is mixed within and becomes part of the text, or code printed on paper. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.tamarziv.com/itp/sonicpoetry/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

