<?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></title>
	<atom:link href="http://briansabbeth.com/processing/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://briansabbeth.com/processing</link>
	<description></description>
	<lastBuildDate>Mon, 04 Oct 2010 22:06:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Up and Down</title>
		<link>http://briansabbeth.com/processing/?p=573</link>
		<comments>http://briansabbeth.com/processing/?p=573#comments</comments>
		<pubDate>Mon, 04 Oct 2010 22:06:36 +0000</pubDate>
		<dc:creator>BriBriBri</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://briansabbeth.com/processing/?p=573</guid>
		<description><![CDATA[On the up side, I am enrolled in Hunter College and will be taking a Com Sci major. On the down side. I&#8217;m behind on my processing because I needed to catch up on Math, which I haven&#8217;t taken since &#8230; <a href="http://briansabbeth.com/processing/?p=573">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>On the up side, I am enrolled in Hunter College and will be taking a Com Sci major.  </p>
<p>On the down side.  I&#8217;m behind on my processing because I needed to catch up on Math, which I haven&#8217;t taken since the 10th grade.   In the last 4 weeks I have gone through 3 notebooks and for the first time in my life I have carpel tunnels in my right wrist./</p>
<p>Gotta say though I am psyched to be in school.  My first test is tomorrow.  If I do well a new P5 post will be up soon.  </p>
<p>Miss it here.</p>
<p>With frosty aloufness,<br />
Brian Sabbeth</p>
]]></content:encoded>
			<wfw:commentRss>http://briansabbeth.com/processing/?feed=rss2&amp;p=573</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>9.2 A-Z Array&#8217;s using Shiffman&#8217;s Snake</title>
		<link>http://briansabbeth.com/processing/?p=452</link>
		<comments>http://briansabbeth.com/processing/?p=452#comments</comments>
		<pubDate>Mon, 13 Sep 2010 20:28:45 +0000</pubDate>
		<dc:creator>BriBriBri</dc:creator>
				<category><![CDATA[arrays]]></category>

		<guid isPermaLink="false">http://briansabbeth.com/processing/?p=452</guid>
		<description><![CDATA[Whats funny is that I almost called this &#8220;Playing with Schiffman&#8217;s Snake.&#8221; Starting School has kicked my P5ing down a bit. Getting back to business now. Here should be everything I need to know about arrays. Its still not clear &#8230; <a href="http://briansabbeth.com/processing/?p=452">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://openprocessing.org/visuals/?visualID=11994"><img src="http://briansabbeth.com/processing/wp-content/uploads/2010/09/Screen-shot-2010-09-13-at-4.24.52-PM.png" alt="" title="openprocessing.org" width="98" height="99" class="alignleft size-full wp-image-568" /></a><br />
Whats funny is that I almost called this &#8220;Playing with Schiffman&#8217;s Snake.&#8221;<br />
Starting School has kicked my P5ing down a bit.  Getting back to business now.  Here should be everything I need to know about arrays.  Its still not clear enough but I&#8217;m working on it.<br />
<strong><br />
Arrays:</strong>  anytime a program requires multiple instances of similar data its useful to use an array(if not necessary).<br />
While <em><strong>variables</strong></em> allow programs to track single points of information over a period time, <em><strong>arrays</strong></em> can point to multiple pieces of information.  An <em><strong>array</strong></em> is a list of variables that keeps track of its own order.<br />
In an array each <strong>element</strong> within a list has a unique <strong>index</strong> value. An <strong>index</strong> value is an integer value that designates its position within a list. <strong>*</strong>Starting with 0 an array with 10 elements has array index values ranging from 0 &#8211; 9 </p>
<p><strong><br />
Using an Array</strong>:<br />
There are a couple things to remember when we declare, create and assign an array.<br />
1) Arrays can be any datatype  including objects.<br />
2) They are of fixed size.<br />
3) You always have the steps 1)declare 2) create and 3) assign.  </p>
<p>An array declaration is written as follows:<br />
type declaration + [<em>"empty brackets"</em>] + the array name.<br />
<em>example</em><br />
<strong>int[]myArray; </strong> //<em>declaration</em></p>
<p>You would then create the array by following the declaration with <strong><em>new</em> </strong><em>operator</em> + type+ ["<em>the size of the array"</em>] ;<br />
<em>example</em><br />
<strong>int[] myArray = new int [100];</strong>//creation</strong><br />
The keyword <strong>new</strong> is what allocates space in the computers memory to store the array&#8217;s data. </p>
<p>After the array is created then values can be assgned to it:<br />
<strong>int[] myArray = new int[3]; </strong>// <em>declare and create</em><br />
<strong>myArray [0] = 3; </strong> //<em>assign value</em><br />
<strong>myArray[1] = 2;</strong> //<em>assign value</em><br />
<strong>myArray[2] = 1;</strong>//<em>assign value</em><br />
Each element of the array is individually referred to by specifying its index, starting with [0].<br />
______________________________________________________<br />
<strong><br />
Using Loops to Fill Arrays</strong><br />
A for loop can be used to store data inside of an array and to access array elements.  A for loop or even a while loop can be used very effectively,I&#8217;m going to stick with the for loop for brevity&#8217;s sake.<br />
Example from <a href="http://processing.org/learning/books/#reasfry">Processing, a Programmers Handbook </a><br />
<strong>int[] data = {19,40,75,76,77};<br />
for (int i = 0; i<ins datetime="2010-09-13T18:42:43+00:00"><</ins>data.length; i++){<br />
line(data[i], 0, data[i],100);<br />
}</strong><br />
______________________________________________________</p>
<p><strong>Shaking Schiffman&#8217;s Snake</strong>(hahahaha)<br />
Program a trail that will follow the mouse by using 2 arrays, one to store the horizontal and one to store the verticle mouse locations.</p>
<p><strong>Step 1</strong><br />
Declare  2 arrays that will hold the last 120 mouseX and mouseY positions.<br />
int [] xpos = new int[120];<br />
int [] ypos = new int[120];</p>
<p><strong>Step 2</strong><br />
In the setup() initialize the arrays using a for loop.<br />
 for (int i = 0; i < xpos.length; i++){<br />
    xpos [i] = 0;<br />
    ypos [i] = 0;<br />
  }<br />
}</p>
<p><strong>Step 3</strong><br />
 Shifting the Array Values:</p>
<p>  for (int i = 0; i < xpos.length - 1; i++){<br />
    xpos[i] = xpos [i+1];<br />
    ypos[i] = ypos [i+1];<br />
  }</p>
<p><strong>Step 4</strong><br />
Drawing the new location:<br />
 xpos[xpos.length -1] = mouseX;<br />
  ypos[ypos.length -1] = mouseY;</p>
<p><strong>Step 5</strong><br />
Draw Everything:</p>
<p>for (int i = 0; i < xpos.length; i++){<br />
    noStroke();<br />
    fill(255 - i*5);<br />
    ellipse(xpos[i], ypos[i], i-120,i-120);<br />
  }<br />
}<br />
View the Sketch at my open processing page.  <a href="http://openprocessing.org/visuals/?visualID=11994">http://openprocessing.org/visuals/?visualID=11994</a></p>
]]></content:encoded>
			<wfw:commentRss>http://briansabbeth.com/processing/?feed=rss2&amp;p=452</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Tutorial 9.1: Arrays Continued</title>
		<link>http://briansabbeth.com/processing/?p=435</link>
		<comments>http://briansabbeth.com/processing/?p=435#comments</comments>
		<pubDate>Tue, 31 Aug 2010 18:36:48 +0000</pubDate>
		<dc:creator>BriBriBri</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://briansabbeth.com/processing/?p=435</guid>
		<description><![CDATA[//Info: http://processingjs.org/reference JitterBug[] bugs = new JitterBug[33];; void setup(){ size(480, 120); background(0); smooth(); for (int i = 0; i]]></description>
			<content:encoded><![CDATA[<p><script type="application/processing">
//Info: http://processingjs.org/reference
JitterBug[] bugs = new JitterBug[33];;

void setup(){

  size(480, 120);
  background(0);
  smooth();
  for (int i = 0; i<bugs.length; i++){
    float x = random(width);
    float y = random(height);
    int r = i+ 2;
    bugs[i] = new JitterBug(x,y,r);
  }
 

}

void draw(){
for(int i = 0; i<bugs.length; i++){
  bugs[i].move();
  bugs[i].display();
}
}
class JitterBug{
 float x;
 float y;
 int diameter;
 float speed = 2.5;

  JitterBug (float tempX, float tempY, int tempDiameter){
    x = tempX;
    y = tempY;
    diameter = tempDiameter;
  }
  
  void move(){
   x += random(-speed, speed);
   y += random(-speed, speed);
   x = constrain(x,0,width);
   y = constrain(y,0,height);
  }
  
  void display(){
    fill(rndColor(), rndColor(), rndColor());
    colorMode(HSB);
    ellipse(x,y,diameter, diameter);   
  }
    
   float rndColor(){

     float newColor = random(0,255);
     return newColor;
  
 }
     
}
</script></p>
<p>This part of the code is right out of  <a href="http://oreilly.com/catalog/0636920000570">Getting Started with Processing </a><br />
<strong>Code</strong></p>
<p>JitterBug[] bugs = new JitterBug[33];;</p>
<p>void setup(){</p>
<p>  size(480, 120);<br />
  background(0);<br />
  smooth();<br />
  for (int i = 0; i<bugs.length; i++){<br />
    float x = random(width);<br />
    float y = random(height);<br />
    int r = i+ 2;<br />
    bugs[i] = new JitterBug(x,y,r);<br />
  }</p>
<p>}</p>
<p>void draw(){<br />
for(int i = 0; i<bugs.length; i++){<br />
  bugs[i].move();<br />
  bugs[i].display();<br />
}<br />
}</p>
<p>The JitterBug class is exactly the same as it was in the <a href="http://briansabbeth.com/processing/?p=377">Object Oriented Programming tutorial</a> that I posted last week.<br />
I will post more notes on this this evening(specifically on how the array works).  For now if anyone sees this you can goto my last exercise on arrays <a href="http://briansabbeth.com/processing/?p=408">here</a> and download the notes Another thing  to note is that I am adjusting this blog a bit so if there is any weirdness let a brotha know.  </p>
<p>Word to your moms, I came to drop bombs.  </p>
]]></content:encoded>
			<wfw:commentRss>http://briansabbeth.com/processing/?feed=rss2&amp;p=435</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial 9: Arrays</title>
		<link>http://briansabbeth.com/processing/?p=408</link>
		<comments>http://briansabbeth.com/processing/?p=408#comments</comments>
		<pubDate>Tue, 31 Aug 2010 16:41:36 +0000</pubDate>
		<dc:creator>BriBriBri</dc:creator>
				<category><![CDATA[arrays]]></category>

		<guid isPermaLink="false">http://briansabbeth.com/processing/?p=408</guid>
		<description><![CDATA[Here are my full notes from these exercises in a rtf.Arrays VOCAB: Element: each item in an array is an element, each element has an index value to mark its position inside the array. Index values begin at 0. USING &#8230; <a href="http://briansabbeth.com/processing/?p=408">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here are my full notes from these exercises in a rtf.<a href='http://briansabbeth.com/processing/wp-content/uploads/2010/08/Arrays.rtf'>Arrays</a><br />
<strong>VOCAB:</strong><br />
<strong>Element</strong>:  each item in an array is an element, each element  has an <strong>index</strong> value to mark its position inside the array. Index values begin at 0.<br />
<strong><br />
USING ARRAYS:</strong><br />
Arrays are similar to working with single variables.  </p>
<p><em>variable    </em><br />
int x ;</p>
<p><em>array </em><br />
int[] x;</p>
<p>With an array you can make unlimited variable values with one line  of code.  </p>
<p>int[] x = new int  [10000];</p>
<p>Arrays can me made from all P5 datatypes.</p>
<p>PImage[] = new PImage[70];</p>
<p><strong><br />
STEPS TO MAKE AN ARRAY:</strong><br />
1. Declare the array and define the data-type ( <strong>int[] x</strong>)<br />
2. Create the array with the keyword &#8220;new&#8221; and define its length ( <strong>int[] x = new int[20]</strong>)<br />
3. Assign values to each element. </p>
<p><strong>Example: </strong><br />
int[] x;                        //declare the array</p>
<p>void setup(){<br />
size(200,200);<br />
x = new int [2];       // create the array\\<br />
x[0]=12;  n          // assign the first value\\<br />
x[1] = 2;            //assign the second value\\<br />
}</p>
<p><script type="application/processing">
//Info: http://processingjs.org/reference

float[] gray = new float[width];
void setup(){

  size(240, 120);
  //gray = new float [width];
  for (int i = 0; i< gray.length; i++){
    gray[i] = random(20,255);
  }
}
void draw(){
  for (int i=0; i <gray.length; i++){
    stroke(0, 0, gray[i]);
    line(i,0,i,height);
  }
}
</script></p>
<p><script type="application/processing">
//Info: http://processingjs.org/reference
int num = 160;
int x[] =  new int[num];
int y[] = new int[num];

void setup(){
 size(240,240);

smooth();
noStroke();
}

void draw(){
 background(0);
 for (int i = x.length-1; i>0; i--){
 x[i]= x[i-1];
 y[i]= y[i-1];
 }
  x[0] =mouseX;
  y[0] = mouseY;
 for(int i = 0; i<x.length; i++){
 fill(random(0,i*4), 1*2, i*2);
 rect(x[i], y[i], random(0,10),random(0,10));
 }
}
</script><br />
<strong>Code:</strong><br />
int num = 160;<br />
int x[] =  new int[num];<br />
int y[] = new int[num];</p>
<p>void setup(){<br />
 size(240,240);<br />
 frameRate(120);<br />
smooth();<br />
noStroke();<br />
}</p>
<p>void draw(){<br />
 background(0);<br />
  for (int i = x.length-1; i>0; i&#8211;){<br />
 //for (int i = x.length-1; i>0; i&#8211;){<br />
 x[i]= x[i-1];<br />
 y[i]= y[i-1];<br />
 }<br />
  x[0] =mouseX;<br />
  y[0] = mouseY;<br />
 for(int i = 0; i<x.length; i++){<br />
 fill(random(0,i*4), 1*2, i*2);<br />
 rect(x[i], y[i], random(0,10),random(0,10));<br />
 }<br />
}<br />
* the framerate is turned down to 60 in order to prevent problemos&#8217;</p>
]]></content:encoded>
			<wfw:commentRss>http://briansabbeth.com/processing/?feed=rss2&amp;p=408</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tutorial 8: Object Oriented Programing in P5</title>
		<link>http://briansabbeth.com/processing/?p=377</link>
		<comments>http://briansabbeth.com/processing/?p=377#comments</comments>
		<pubDate>Mon, 30 Aug 2010 11:59:33 +0000</pubDate>
		<dc:creator>BriBriBri</dc:creator>
				<category><![CDATA[OOP]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[drawing function]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[response]]></category>
		<category><![CDATA[return value]]></category>
		<category><![CDATA[constrain]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[oop]]></category>
		<category><![CDATA[returns]]></category>

		<guid isPermaLink="false">http://briansabbeth.com/processing/?p=377</guid>
		<description><![CDATA[Dont know why but OOP just seems easier inside of P5 as opposed to AS3. Maybe its just because what I am doing is less complicated. //Info: http://processingjs.org/reference JitterBug bug; void setup(){ size(480, 120); smooth(); bug = new JitterBug(width/2, height/2, &#8230; <a href="http://briansabbeth.com/processing/?p=377">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Dont know why but OOP just seems easier inside of P5 as opposed to AS3. Maybe its just because what I am doing is less complicated.  <script type="application/processing">
//Info: http://processingjs.org/reference

JitterBug bug;

void setup(){
  
  size(480, 120);
  smooth();
  bug = new JitterBug(width/2, height/2, 80);
  
}

void draw(){
  bug.move();
  bug.display();
  
}
class JitterBug{
 float x;
 float y;
 int diameter;
 float speed = 2.5;

  JitterBug (float tempX, float tempY, int tempDiameter){
    x = tempX;
    y = tempY;
    diameter = tempDiameter;
  }
  
  void move(){
   x += random(-speed, speed);
   y += random(-speed, speed);
   x = constrain(x,0,width);
   y = constrain(y,0,height);
  }
  
  void display(){
    fill(rndColor(), rndColor(), rndColor());
    ellipse(x,y,diameter, diameter);   
  }
    
   float rndColor(){
     float newColor = random(0,255);
     return newColor;
  
 }
     
}


</script><br />
<strong>SETUP &#038; DRAW</strong><br />
<strong><em>Declare the object with the &#8220;Jitterbug&#8221; data-type  &#038; assign it to the &#8220;bug&#8221; variable . Then initialize the object with the keyword &#8220;new&#8221; + the &#8216;constructor name&#8217;, Fill in the parameters (x, y, and diameter)</em></strong><br />
JitterBug bug;<br />
void setup(){<br />
  size(480, 120);<br />
  smooth();<br />
  bug = new JitterBug(width/2, height/2, 80);</p>
<p>}<br />
<strong><em>The Jitterbug class&#8217;s methods are joined to the object through the dot(.)operator. </em></strong><br />
void draw(){<br />
  bug.move();<br />
  bug.display();</p>
<p>}<br />
<strong>JITTERBUG CLASS</strong><br />
<strong><em>Block</em></strong><br />
class JitterBug{<br />
 float x;<br />
 float y;<br />
 int diameter;<br />
 float speed = 2.5;<br />
<strong><em>Constructor</em></strong><br />
  JitterBug (float tempX, float tempY, int tempDiameter){<br />
    x = tempX;<br />
    y = tempY;<br />
    diameter = tempDiameter;<br />
  }<br />
<strong><em>Methods called from draw</strong>(move, display, rndColor).</em></strong><br />
  void move(){<br />
   x += random(-speed, speed);<br />
   y += random(-speed, speed);<br />
   x = constrain(x,0,width);<br />
   y = constrain(y,0,height);<br />
  }<br />
<em><strong> Sets the color, position and size of the ellipse</strong></em><br />
void display(){<br />
    fill(rndColor(), rndColor(), rndColor());<br />
    ellipse(x,y,diameter, diameter);<br />
  }</p>
<p><strong><em>the rndColor method calculates the color and returns its value to the display method</em></strong><br />
   float rndColor(){<br />
     float newColor = random(0,255);<br />
     return newColor;<br />
 }<br />
}</p>
<p>Hasta La Vista.<br />
Senor Briano</p>
]]></content:encoded>
			<wfw:commentRss>http://briansabbeth.com/processing/?feed=rss2&amp;p=377</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Loops 2  (Iteration defined)</title>
		<link>http://briansabbeth.com/processing/?p=337</link>
		<comments>http://briansabbeth.com/processing/?p=337#comments</comments>
		<pubDate>Mon, 30 Aug 2010 00:59:49 +0000</pubDate>
		<dc:creator>BriBriBri</dc:creator>
				<category><![CDATA[loops]]></category>

		<guid isPermaLink="false">http://briansabbeth.com/processing/?p=337</guid>
		<description><![CDATA[//Info: http://processingjs.org/reference void setup(){ size(300,300); background (0); stroke(0); noFill(); } void draw(){ for (float x = 0; x < width; x+=10){ for (float y = 0; y< width; y+=10){ stroke(251,150,130); fill(0,0,random(1,255)); if (mouseX =x &#124;&#124; mouseYy){ fill(0,random(1,255),0); } rect(x,y,10,10); } &#8230; <a href="http://briansabbeth.com/processing/?p=337">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><script type="application/processing">
//Info: http://processingjs.org/reference
void setup(){
  size(300,300);
  background (0);
  stroke(0);
  noFill();
}

void draw(){
 
  for (float x = 0; x < width; x+=10){
       for (float y = 0; y< width; y+=10){
         stroke(251,150,130);
         fill(0,0,random(1,255));
          if (mouseX <= x+10/2 && mouseX >=x || mouseY<= y+20/2 && mouseY>y){
          fill(0,random(1,255),0);
          }
         rect(x,y,10,10); 
  }
}
}
</script><br />
Just so its clear I thought I would go back over this properly. My write-up on loops should have included the following notes taken from <a href="http://processing.org/learning/books/#reasfry">Processing</a></p>
<p><strong>Iteration</strong>:<br />
 The act of repeating a process usually with the aim of approaching a desired goal or target or result.<br />
<strong>Nesting</strong>:<br />
Nesting one structure within another compounds the effect of a loop.  If you have a loop that draws 9 points (runs 9 times) and nest another loop within it that also draws 9 points you get <em> 9 points x 9 points = 81 points </em>.  </p>
<p><strong>Example:</strong><br />
<strong>for(loop){ </strong> <em>  does something 9 times</em><br />
*     *  <strong> for(loop){</strong>   <em>does something 9 times</em><br />
      <em> does something 81 times;</em><br />
    }<br />
}</p>
<p>In the above case for each single time the outer loop runs it will run the inner loop 9 times.  In other words the inner loop runs a complete cycle for each single <strong>iteration</strong> of the outer loop structure.</p>
<p><script type="application/processing">
//Info: http://processingjs.org/reference


fill(255,76,0);
stroke(0);
smooth();
for (int y = 0; y<=100; y+=10){
  for (int x = 0; x<=100; x+=10){
   fill((x+y) *1.4);
    rect(x, y, 10, 10);  
     stroke( (x+y) *1.4, 0, 0, 140 );
    line(-125,-125,x,y);
  }
}
</script><br />
<strong>Code</strong></p>
<p>fill(255,76,0);<br />
stroke(0);<br />
smooth();<br />
for (int y = 0; y<=100; y+=10){<br />
  for (int x = 0; x<=100; x+=10){<br />
   fill((x+y) *1.4);<br />
    rect(x, y, 10, 10);<br />
     stroke( (x+y) *1.4, 0, 0, 140 );<br />
    line(-125,-125,x,y);<br />
  }<br />
}<ins datetime="2010-08-30T00:49:05+00:00"></ins></p>
<p><strong>Heres the code from the top sketch:</strong><br />
void setup(){<br />
  size(300,300);<br />
  background (0);<br />
  stroke(0);<br />
  noFill();<br />
}</p>
<p>void draw(){</p>
<p>  for (float x = 0; x < width; x+=10){<br />
       for (float y = 0; y< width; y+=10){<br />
         stroke(251,150,130);<br />
         fill(0,0,random(1,255));<br />
          if (mouseX <= x+10/2 &#038;&#038; mouseX >=x || mouseY<= y+20/2 &#038;&#038; mouseY>y){<br />
          fill(0,random(1,255),0);<br />
          }<br />
         rect(x,y,10,10);<br />
    }<br />
  }<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://briansabbeth.com/processing/?feed=rss2&amp;p=337</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Book-Notes: Returning Values</title>
		<link>http://briansabbeth.com/processing/?p=313</link>
		<comments>http://briansabbeth.com/processing/?p=313#comments</comments>
		<pubDate>Sun, 29 Aug 2010 23:30:04 +0000</pubDate>
		<dc:creator>BriBriBri</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://briansabbeth.com/processing/?p=313</guid>
		<description><![CDATA[This should fit in with the Function&#8217;s tut. Returning values is something I previously have not done in P5 and in terms of OOP is very useful. My synopsis of Getting Started with Processing&#8217;s explanation of return values is that &#8230; <a href="http://briansabbeth.com/processing/?p=313">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This should fit in with the <a href="http://briansabbeth.com/processing/?p=282&#038;preview=true&#038;preview_id=282&#038;preview_nonce=2f54b31fee">Function&#8217;s tut</a>. Returning values is something I previously have not done in P5 and in terms of OOP is very useful.</p>
<p>My synopsis of <a href="www.processing.org">Getting Started with Processing&#8217;s</a> explanation of <strong>return values</strong> is that a function  will make a specific calculation and then return the value of that calculation to the main program, or the part of the program that calls it. Also a function that returns a value can be and is frequently used as a parameter in another function .<br />
<strong>Example</strong><br />
<em>point(random(width), random(height));</em><br />
The <em>point&#8217;s </em>parameters come from the returned <em>random value</em> (<em>random</em> is a function).</p>
<p>Its done this way&#8211;(from <a href="processing.org">Getting Started with Processing </a>Example 8-8):<br />
<strong>void setup</strong>(){<br />
float yourWeight = 132;<br />
float marsWeight = calculateMars(yourWeight);<br />
println(marsWeight);<br />
}<br />
//the important thing here is the datatype <em>float</em> which returns a floating-point value as told by the last line in the function<em> return newWeight</em>;</p>
<p>float calculateMars(float w){<br />
float newWeight  = w* 0.38;<br />
return newWeight;<br />
}<br />
//  My  current weight on mars is 100.7.  My weight on mars should be 93.1</p>
]]></content:encoded>
			<wfw:commentRss>http://briansabbeth.com/processing/?feed=rss2&amp;p=313</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial 7: Function</title>
		<link>http://briansabbeth.com/processing/?p=282</link>
		<comments>http://briansabbeth.com/processing/?p=282#comments</comments>
		<pubDate>Sat, 28 Aug 2010 20:21:56 +0000</pubDate>
		<dc:creator>BriBriBri</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://briansabbeth.com/processing/?p=282</guid>
		<description><![CDATA[One funny little thing in AS3 that I never got right was parameters. I don&#8217;t really understand why, but I never used them and always found a way to get around them. I&#8217;m happy to say those days are over. &#8230; <a href="http://briansabbeth.com/processing/?p=282">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One funny little thing in AS3 that I never got right was parameters.  I don&#8217;t really understand why, but I never used them and always found a way to get around them.  I&#8217;m happy to say those days are over.  Below is example 8-7 from <a href="processing.org">Getting Started with P5ing</a> modified to pass different shades of green randomly  into a function that draws an owl:<br />
<script type="application/processing">
//Info: http://processingjs.org/reference

void setup(){

  size(490, 120);
  smooth(); 
}
void draw (){
 background(04);
 randomSeed(0);

  for (int i = 35; i<width+40; i+=40){

    int reds = int(random(0,102));
    int greens = int (random(100,202));
    int blues = int (random(0,102));
    float scalar = (random(.225, 1.0));


    owl(i,110, reds, greens, blues, scalar);
  }
}

void owl(int x, int y, int r, int g, int b, float s){
  pushMatrix();
  translate(x,y);
  scale(s);
  stroke(r, g, b); 
  strokeWeight  (70);
  line(0,-35,0,-65);// body
  noStroke();
  fill(255);
  ellipse(-17.5, -65,35,35);
  ellipse(17.5, -65,35,35);
  arc(0,-65,70,70, 0, PI);
  fill(0);
  ellipse(-14, -65,8,8);
  ellipse(14, -65,8,8);
  quad(0,-58,4,-51,0,-44,-4,-51);

  popMatrix();
}
</script><br />
You may notice that nothing has compiles in the sketch window.  The code works in my PDE.  im looking into  this.  right now<br />
<strong><br />
Code:</strong><br />
void setup(){</p>
<p>  size(490, 120);<br />
  smooth();<br />
}<br />
void draw (){<br />
 background(04);<br />
 randomSeed(0);</p>
<p>  for (int i = 35; i<width+40; i+=40){</p>
<p>    int reds = int(random(0,102));<br />
    int greens = int (random(100,202));<br />
    int blues = int (random(0,102));<br />
    float scalar = (random(.225, 1.0));</p>
<p>    owl(i,110, reds, greens, blues, scalar);<br />
  }<br />
}</p>
<p>void owl(int x, int y, int r, int g, int b, float s){<br />
  pushMatrix();<br />
  translate(x,y);<br />
  scale(s);<br />
  stroke(r, g, b);<br />
  strokeWeight  (70);<br />
  line(0,-35,0,-65);// body<br />
  noStroke();<br />
  fill(255);<br />
  ellipse(-17.5, -65,35,35);<br />
  ellipse(17.5, -65,35,35);<br />
  arc(0,-65,70,70, 0, PI);<br />
  fill(0);<br />
  ellipse(-14, -65,8,8);<br />
  ellipse(14, -65,8,8);<br />
  quad(0,-58,4,-51,0,-44,-4,-51);</p>
<p>  popMatrix();<br />
}</p>
<p><script type="application/processing">
//Info: http://processingjs.org/reference
void setup(){
  size (720,480);
  smooth();
  strokeWeight(2);
  ellipseMode(RADIUS);
}

void draw(){
  drawRobot(120,420,110,140);
  drawRobot(270, 460, 260, 95);
  drawRobot(420, 310, 80, 10);
  drawRobot(570, 300, 180, 45); 

}


void drawRobot(int x, int y, int bodyHeight, int neckHeight){
  int radius = 45;
  int ny = y - bodyHeight - neckHeight - radius;
//neck
  stroke(102);
  line(x+2, y-bodyHeight, x+2, ny);
  line(x+12, y-bodyHeight, x+12, ny);
  line(x+22, y-bodyHeight, x+22, ny);
//Antennae
line(x+12, ny, x-18, ny-43);
line(x+12, ny, x+42, ny-99);
line(x+12, ny, x+78, ny+15);
//Body
fill(102);
ellipse(x,y-33,33,33);
fill(0);
rect(x-45, y-bodyHeight, 90, bodyHeight-33);
fill(102);
rect(x-45, y-bodyHeight+17, 90, 6);
//head
fill(0);
ellipse(x+12, ny, radius, radius);
fill(255);
ellipse(x+24, ny-6, 14, 14);
fill(0);
fill(153);
ellipse(x, ny-8, 5, 5);
ellipse(x+30, ny-26, 4, 4);
ellipse(x+41, ny+6, 5, 5);


}

</script></p>
<p><strong>Code</strong>(straight out of the<a href="http://processing.org/learning/books/#reasfry2"> book</a> with no modification just so I could test whats happening to the above sketch):  </p>
<p>void setup(){<br />
  size (720,480);<br />
  smooth();<br />
  strokeWeight(2);<br />
  ellipseMode(RADIUS);<br />
}</p>
<p>void draw(){<br />
  drawRobot(120,420,110,140);<br />
  drawRobot(270, 460, 260, 95);<br />
  drawRobot(420, 310, 80, 10);<br />
  drawRobot(570, 300, 180, 45); </p>
<p>}</p>
<p>void drawRobot(int x, int y, int bodyHeight, int neckHeight){<br />
  int radius = 45;<br />
  int ny = y &#8211; bodyHeight &#8211; neckHeight &#8211; radius;<br />
//neck<br />
  stroke(102);<br />
  line(x+2, y-bodyHeight, x+2, ny);<br />
  line(x+12, y-bodyHeight, x+12, ny);<br />
  line(x+22, y-bodyHeight, x+22, ny);<br />
//Antennae<br />
line(x+12, ny, x-18, ny-43);<br />
line(x+12, ny, x+42, ny-99);<br />
line(x+12, ny, x+78, ny+15);<br />
//Body<br />
fill(102);<br />
ellipse(x,y-33,33,33);<br />
fill(0);<br />
rect(x-45, y-bodyHeight, 90, bodyHeight-33);<br />
fill(102);<br />
rect(x-45, y-bodyHeight+17, 90, 6);<br />
//head<br />
fill(0);<br />
ellipse(x+12, ny, radius, radius);<br />
fill(255);<br />
ellipse(x+24, ny-6, 14, 14);<br />
fill(0);<br />
fill(153);<br />
ellipse(x, ny-8, 5, 5);<br />
ellipse(x+30, ny-26, 4, 4);<br />
ellipse(x+41, ny+6, 5, 5);</p>
<p>}</p>
]]></content:encoded>
			<wfw:commentRss>http://briansabbeth.com/processing/?feed=rss2&amp;p=282</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial 6: Motion</title>
		<link>http://briansabbeth.com/processing/?p=253</link>
		<comments>http://briansabbeth.com/processing/?p=253#comments</comments>
		<pubDate>Fri, 27 Aug 2010 01:44:37 +0000</pubDate>
		<dc:creator>BriBriBri</dc:creator>
				<category><![CDATA[color]]></category>
		<category><![CDATA[drawing function]]></category>
		<category><![CDATA[motion]]></category>

		<guid isPermaLink="false">http://briansabbeth.com/processing/?p=253</guid>
		<description><![CDATA[Have to comment more this later, for now all I have the time to say is that motion is fun in P5. Will post code to this in a bit: //Info: http://processingjs.org/reference /*we can make circular motion when using sin() &#8230; <a href="http://briansabbeth.com/processing/?p=253">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Have to comment more this later,  for now all  I have the time to say is that motion is fun in P5.  </p>
<p>Will post code to this in a bit:<br />
<script type="application/processing">
//Info: http://processingjs.org/reference
/*we can make circular motion when using sin() and cos() together.  Cos() values 
 provide the x-coordinates and sin() values are used for the y-coordinates.
 To change the radius of the motion you multiply sin() & cos() by the scalar
 variable.  */


float angle = 0.1;
float offset = 160;
float scalar = 30;
//fucking with speed gets nutty
float speed = .25;

void setup(){
  size(320,320);
  smooth();
  background(0);
}

void draw(){
  float x = offset + cos(angle)* scalar;
  float y = offset + sin(angle)* scalar;


  angle+= speed;
  if((x>300)&&(y>300)){
 fill(random(9),random(247),random(0));
  ellipse(x,y,10,10);
    scalar = -speed;
  
  }else{
 fill(random(9),random(247),random(0));
    scalar+=speed;
    ellipse(x,y,10,10);
  }
}
</script><br />
/*we can make circular motion when using sin() and cos() together.  cos() values<br />
 provide the x-coordinates and sin() values are used for the y-coordinates.<br />
 To change the radius of the motion you multiply sin() &#038; cos() by the scalar<br />
 variable.  */<br />
float angle = 0.1;<br />
float offset = 160;<br />
float scalar = 30;<br />
//fucking with speed gets nutty<br />
float speed = .25;</p>
<p>void setup(){<br />
  size(320,320);<br />
  smooth();<br />
  background(0);<br />
}<br />
void draw(){<br />
  float x = offset + cos(angle)* scalar;<br />
  float y = offset + sin(angle)* scalar;<br />
  angle+= speed;<br />
  fill(random(9),random(247),random(0));<br />
  ellipse(x,y,10,10);<br />
  if((x>300)&#038;&#038;(y>300)){<br />
  scalar = -speed;<br />
  }else{<br />
  scalar+=speed;<br />
  }<br />
}</p>
<p><script type="application/processing">
float speed = 1.5;
int diameter = 20;
float x;
float y;

void setup(){
size(240,120);
smooth();
x=width/2;
y=height/2;
background(30);
}
//Re-maps a number from one range to another. In the example above, the number '25' is converted from a value in the range 0..100 into a value that ranges from the left edge (0) to the right edge (width) of the screen. 

//Numbers outside the range are not clamped to 0 and 1, because out-of-range values are often intentional and useful.

void draw(){
 
 x+= random (-speed,speed); 
 y+= random (-speed, speed);
 
 //constrains value to not exceed a maximum and minimum value
 // constrain (value, min, max)
 x = constrain(x,0,width);
 y = constrain(y,0,height);
 fill (217,242,random(73));
 ellipse(x,y,diameter, diameter);
}
</script><br />
<strong>Code:</strong><br />
float speed = 2.5;<br />
int diameter = 20;<br />
float x;<br />
float y;</p>
<p>void setup(){<br />
size(240,120);<br />
smooth();<br />
x=width/2;<br />
y=height/2;<br />
background(30);<br />
}<br />
//Re-maps a number from one range to another. In the example above, the number &#8217;25&#8242; is converted from a value in the range 0..100 into a value that ranges from the left edge (0) to the right edge (width) of the screen. </p>
<p>//Numbers outside the range are not clamped to 0 and 1, because out-of-range values are often intentional and useful.</p>
<p>void draw(){</p>
<p> x+= random (-speed,speed);<br />
 y+= random (-speed, speed);</p>
<p> //constrains value to not exceed a maximum and minimum value<br />
 // constrain (value, min, max)<br />
 x = constrain(x,0,width);<br />
 y = constrain(y,0,height);<br />
 fill (217,242,random(73));<br />
 ellipse(x,y,diameter, diameter);<br />
}<br />
<script type="application/processing">
//Info: http://processingjs.org/reference
/*we can make circular motion when using sin() and cos() together.  cos() values 
 provide the x-coordinates and sin() values are used for the y-coordinates.
 To change the radius of the motion you multiply sin() & cos() by the scalar
 variable.  */
float angle = 0.1;
float offset = 160;
float scalar = 30;
//fucking with speed gets nutty
float speed = .25;

void setup(){
  size(320,320);
  smooth();
  background(0);
}
void draw(){
  float x = offset + cos(angle)* scalar;
  float y = offset + sin(angle)* scalar;
 float z= random(62,255);
 z *=30;
  angle+= speed;

 
  
  if((x>300)&&(y>300)){
  scalar = -scalar;
  ellipse(x,y,5,5);
  }else{
  fill(z,z,z);
  ellipse(x,y,5,5);
  scalar+=speed;
  }
}

</script></p>
]]></content:encoded>
			<wfw:commentRss>http://briansabbeth.com/processing/?feed=rss2&amp;p=253</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial 5:  Response</title>
		<link>http://briansabbeth.com/processing/?p=214</link>
		<comments>http://briansabbeth.com/processing/?p=214#comments</comments>
		<pubDate>Wed, 25 Aug 2010 13:27:05 +0000</pubDate>
		<dc:creator>BriBriBri</dc:creator>
				<category><![CDATA[color]]></category>
		<category><![CDATA[response]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://briansabbeth.com/processing/?p=214</guid>
		<description><![CDATA[Coming from a background in Flash, I gotta say that I am impressed with with P5&#8242;s speed. The below example is pretty damn smooth(click to change color): //Info: http://processingjs.org/reference //easing float x; float y; float easing = .05; float diameter &#8230; <a href="http://briansabbeth.com/processing/?p=214">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Coming from a background in Flash, I gotta say that I am impressed with with P5&#8242;s speed.  The below example is pretty damn smooth(click to change color):<br />
<script type="application/processing">
//Info: http://processingjs.org/reference
//easing

float x;
float y;
float easing = .05;
float diameter = 12;

void setup(){
size(620,220);
background(0);
smooth(); 
}
void draw(){
float targetX = mouseX;
float targetY = mouseY;
float weight = dist(mouseX, mouseY, pmouseX, pmouseY);

x+=(targetX-x)*easing;
y+=(targetY-y)*easing;

if (mousePressed==true){
  fill(random(255),random(255),0);
}else{
  fill(0,random(255),random(255));
}
if(weight<40){
ellipse(x,y,8+(weight*easing)+3,8+(weight*easing)+3);
}else{
ellipse(x-3,y-3,8,8);
}
println(weight);
}
</script><br />
But maybe just as sweet as the speed  are the built in variables and functions I just picked up: <strong> pmouseX </strong> &#038; <strong>pmouseY</strong>(previousMouseX and PreviousMouseY) which can be used to calculate the speed of the mouse.  Its so easy to do when you use the <strong>dist</strong> function: <strong>dist(mouseX,mouseY,pmouseX, pmouseY); </strong>.<br />
<strong>Code:</strong><br />
//magic worm<br />
float x;<br />
float y;<br />
float easing = .05;<br />
float diameter = 12;</p>
<p>void setup(){<br />
size(220,220);<br />
background(0);<br />
smooth();<br />
}<br />
void draw(){<br />
float targetX = mouseX;<br />
float targetY = mouseY;<br />
float weight = dist(mouseX, mouseY, pmouseX, pmouseY);</p>
<p>x+=(targetX-x)*easing;<br />
y+=(targetY-y)*easing;</p>
<p>if (mousePressed==true){<br />
  fill(random(255),random(255),0);<br />
}else{<br />
  fill(0,random(255),random(255));<br />
}<br />
if(weight<40){<br />
ellipse(x,y,8+(weight*easing)+3,8+(weight*easing)+3);<br />
}else{<br />
ellipse(x-3,y-3,8,8);<br />
}<br />
println(weight);<br />
}</p>
<p>This sketch also uses the mousePressed statement.  I call it a statement rather than an event because it's called from an <strong>if statement</strong>.   It seems that key-presses(char) work the same way.  Another new thing in this tut is <strong>easing</strong>:<br />
<strong>float easing = .05;</strong><br />
<strong>y+=(targetY-y)*easing;</strong><br />
This calculation is extremely useful for smoothing out the way the circles follow the mouse.   The value Y keeps getting closer to the targetY (mouseY).  The lower the value of Y the slower the circle creeps up to the mouse. </p>
<p>See page 57 of<a href="http://processing.org/learning/books/"> Getting Started with Processin</a>g for an easing diagram</p>
<p>Heres Mr P5 Robot Updated again<br />
<script type="application/processing">
//Info: http://processingjs.org/reference


float  x = 60;//x coordinate
float y = 440;//ycoordinate
int radius = 45;
int bodyHeight=160;
int neckHeight = 70;

float easing = .02;

void setup(){
size (360,480);
smooth();
strokeWeight(2);
}

void draw(){
int targetX = mouseX;
x +=(targetX-x) * easing;

 if (mousePressed){
 neckHeight =  16;
 bodyHeight = 90;
 }else{
   neckHeight = 70;
   bodyHeight = 160;
}

float ny = y - bodyHeight - neckHeight - radius;
background (204,0,0);
//neck
stroke (102);
line(x+12, y-bodyHeight, x+12, ny);

//antennae
line(x+12, ny, x-18, ny-43);
line(x+12, ny, x+42, ny-99);
line(x+12, ny, x+78, ny-15);

//body
noStroke();
fill(102);
ellipse(x,y-33,33,33);
fill(0);
rect(x-25, y-bodyHeight, 50, bodyHeight-33);

//head
fill(0);
ellipse(x+12, ny, radius, radius);
fill(255);
ellipse(x+24, ny-6, 14, 14);
fill(0);
ellipse(x+24, ny-6, 3, 3);
}

</script></p>
]]></content:encoded>
			<wfw:commentRss>http://briansabbeth.com/processing/?feed=rss2&amp;p=214</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial 4: Loops and Vars</title>
		<link>http://briansabbeth.com/processing/?p=173</link>
		<comments>http://briansabbeth.com/processing/?p=173#comments</comments>
		<pubDate>Tue, 24 Aug 2010 13:18:25 +0000</pubDate>
		<dc:creator>BriBriBri</dc:creator>
				<category><![CDATA[loops]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://briansabbeth.com/processing/?p=173</guid>
		<description><![CDATA[Lots of stuff today so the comments here may not be the best. //Info: http://processingjs.org/reference void setup(){ size(480,480); background(0); smooth(); } void draw(){ for (int y = 20; y]]></description>
			<content:encoded><![CDATA[<p>Lots of stuff today so the comments here may not be the best.<br />
<script type="application/processing">
//Info: http://processingjs.org/reference
void setup(){
size(480,480);
background(0);
smooth();
}

void draw(){
for (int y = 20; y<=height-20; y+= 10){
  for (int x = 20; x<=width-20; x+=10){
    
  fill(255);
    stroke(102);
    
    stroke(0,0,255, 120);
    line(x,y,width/2,height-20);
    ellipse(x,y,4,4);
    
  }
}
}
</script><br />
<strong>Code</strong><br />
size(480,480);<br />
background(0);<br />
smooth();<br />
fill(255);<br />
stroke(102);<br />
for (int y = 20; y<=height-20; y+= 10){<br />
  for (int x = 20; x<=width-20; x+=10){<br />
    ellipse(x,y,4,4);<br />
     stroke(0,0,random(255));<br />
    line(x,y,240,240);<br />
  }<br />
}<br />
The above code shows one <strong>for loop</strong> nested within another. Y defines the Y position of the the ellipse&#8217;s and lines. If Y is less than or equal to the height of the the sketch-20pixels we will keep adding to Y by 10. The nested for loop that defines X says that for every Y we add we add a row of  X&#8217;s in the same way.   </p>
<p><strong>ROBOT TWO</strong><br />
<script type="application/processing">
size(170,480);
background(0);
smooth();
//noStroke();
for (int y=0; y<=height; y+=40){
  for (int x = 0; x<=width; x+=40){
    fill(255, 200);
    ellipse(x,y,40,40);
  }
}

int x = 60;  //coordinate x
int y = 420;  // coordinate y
int bodyHeight = 110;  //neck
int neckHeight = 140;  //body
int radius = 45;//head radius;

int ny = y-bodyHeight - neckHeight - radius;//neckY;

size(170, 480);
smooth();
strokeWeight(2);

ellipseMode(RADIUS);

//neck
stroke(102);
line(x+2, y-bodyHeight, x+2, ny);
line(x+12, y-bodyHeight, x+12, ny);
line(x+22, y-bodyHeight, x+22, ny);

//antenna
line(x+12, ny, x-18, ny-43);
line(x+12, ny, x+42, ny-99);
line(x+12, ny, x+78, ny+15);

//body
noStroke();
fill (102);
ellipse(x,y, 33,33);
fill(0);
rect(x-45, y-bodyHeight, 90, bodyHeight);
fill(102);
rect(x-45, y-bodyHeight+17, 90,20);


//head
fill(0);
ellipse(x+12, ny, radius, radius);
fill(255);
ellipse(x+24, ny-6, 14, 14);
fill(0);
ellipse(x+24, ny-6, 3, 3);

fill(153);
ellipse(x, ny-8, 5, 5);
ellipse(x+30, ny-26, 4, 4);
ellipse(x+41, ny+6, 3, 3);
</script></p>
<p><script type="application/processing">
//Info: http://processingjs.org/reference
size(480,120);

strokeWeight(1);
smooth();
for  (int i=10; i<400; i+=4){
  line(i,40,i+i/2, 80);
  line(i+i/2, 80,i*1.2, 120);
}


</script><br />
<script type="application/processing">
//Info: http://processingjs.org/reference
size(480,480);
background(0);
smooth();
noStroke();
for (int i=0; i<=height; i+=40){
  for (int j = 0; j<=width; j+=40){
    fill(55, 0,random(255));
    ellipse(j,i,40,40);

  }
}

int x = 160;  //coordinate x
int y = 420;  // coordinate y
int bodyHeight = 110;  //neck
int neckHeight = 140;  //body
int radius = 45;//head radius;

int ny = y-bodyHeight - neckHeight - radius;//neckY;


smooth();
strokeWeight(2);

ellipseMode(RADIUS);

//neck
stroke(102);
line(x+2, y-bodyHeight, x+2, ny);
line(x+12, y-bodyHeight, x+12, ny);
line(x+22, y-bodyHeight, x+22, ny);

//antenna
stroke(255);
line(x+12, ny, x-18, ny-43);
line(x+12, ny, x+42, ny-99);
line(x+12, ny, x+78, ny+15);

//body
stroke(255);
strokeWeight(1);
fill (102);
ellipse(x,y, 33,33);
fill(0);
rect(x-45, y-bodyHeight, 90, bodyHeight);
fill(102);
rect(x-45, y-bodyHeight+17, 90,20);


//head
fill(0);
stroke(255);

ellipse(x+12, ny, radius, radius);
fill(255);
ellipse(x+24, ny-6, 14, 14);
fill(0);
ellipse(x+24, ny-6, 3, 3);

fill(153);
ellipse(x, ny-8, 5, 5);
ellipse(x+30, ny-26, 4, 4);
ellipse(x+41, ny+6, 3, 3);

</script><br />
<strong>Code</strong><br />
size(480,480);<br />
background(0);<br />
smooth();<br />
noStroke();<br />
for (int i=0; i<=height; i+=40){<br />
  for (int j = 0; j<=width; j+=40){<br />
    fill(55, 0,random(255));<br />
    ellipse(j,i,40,40);</p>
<p>  }<br />
}</p>
<p>int x = 160;  //coordinate x<br />
int y = 420;  // coordinate y<br />
int bodyHeight = 110;  //neck<br />
int neckHeight = 140;  //body<br />
int radius = 45;//head radius;</p>
<p>int ny = y-bodyHeight &#8211; neckHeight &#8211; radius;//neckY;</p>
<p>smooth();<br />
strokeWeight(2);</p>
<p>ellipseMode(RADIUS);</p>
<p>//neck<br />
stroke(102);<br />
line(x+2, y-bodyHeight, x+2, ny);<br />
line(x+12, y-bodyHeight, x+12, ny);<br />
line(x+22, y-bodyHeight, x+22, ny);</p>
<p>//antenna<br />
stroke(255);<br />
line(x+12, ny, x-18, ny-43);<br />
line(x+12, ny, x+42, ny-99);<br />
line(x+12, ny, x+78, ny+15);</p>
<p>//body<br />
stroke(255);<br />
strokeWeight(1);<br />
fill (102);<br />
ellipse(x,y, 33,33);<br />
fill(0);<br />
rect(x-45, y-bodyHeight, 90, bodyHeight);<br />
fill(102);<br />
rect(x-45, y-bodyHeight+17, 90,20);</p>
<p>//head<br />
fill(0);<br />
stroke(255);</p>
<p>ellipse(x+12, ny, radius, radius);<br />
fill(255);<br />
ellipse(x+24, ny-6, 14, 14);<br />
fill(0);<br />
ellipse(x+24, ny-6, 3, 3);</p>
<p>fill(153);<br />
ellipse(x, ny-8, 5, 5);<br />
ellipse(x+30, ny-26, 4, 4);<br />
ellipse(x+41, ny+6, 3, 3);</p>
<p>This is an improvement on the last robot exercise.  Instead of using straight shapes The tut uses variables to  define things like body height, neck height, x and y coordinates and so on.  </p>
<p>On a more personal note I cannot stress enough how great the P5 books are.   </p>
]]></content:encoded>
			<wfw:commentRss>http://briansabbeth.com/processing/?feed=rss2&amp;p=173</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial 3:  Back to the drawing board</title>
		<link>http://briansabbeth.com/processing/?p=112</link>
		<comments>http://briansabbeth.com/processing/?p=112#comments</comments>
		<pubDate>Tue, 24 Aug 2010 03:40:21 +0000</pubDate>
		<dc:creator>BriBriBri</dc:creator>
				<category><![CDATA[drawing function]]></category>

		<guid isPermaLink="false">http://briansabbeth.com/processing/?p=112</guid>
		<description><![CDATA[This seems to happen to me with programming: I start learning, get some knowledge, think I know something then find out I&#8217;ve just touched the surface. Well it happened here and had I not just gotten a copy of GettingStarted &#8230; <a href="http://briansabbeth.com/processing/?p=112">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This seems to happen to me with programming:  I start learning, get some knowledge, think I know  something  then find out I&#8217;ve just touched the surface.  Well it happened here and had I not just gotten a copy of <a href="http://oreilly.com/catalog/0636920000570">GettingStarted With Processing</a>, I may have missed it.<br />
<script type="application/processing">
//Info: http://processingjs.org/reference
size(400,400);
quad(80,40,60,30,70,90,100,100);

strokeWeight(10);
fill(255);
//ellipse(x,y,w,h)
ellipse (150,150,100,100);

strokeWeight(1);
arc (240, 230,100,100,TWO_PI,HALF_PI+ PI);

triangle (0,300,150,150,150,300);



</script></p>
<p>Here&#8217;s a short &#038; personal <strong>cheat sheet</strong> with whatever shape stuff I know so far:<br />
// line (x1,y1,x2,y2,)<br />
// rect  (x,y, w,h)<br />
//ellipse(x,y,w,h)<br />
//quad(x1,y1,x2,y2,x2,y3,x4,y4)<br />
//triangle(x1, y1,x2, y2, x3, y3);<br />
//arc(x,y,width,height, start, stop);</p>
<p><strong>Stroke Contro</strong>l:<br />
strokeWeight(1);//obvious<br />
//changes the way that the lines are joined;<br />
strokeJoin(ROUND);<br />
strokeJoin(BEVEL);<br />
//changes the way the lines are drawn at their beginning and end;<br />
strokeCap(SQUARE);<br />
strokeCap(ROUND);</p>
<p><strong>USING VERTEX():</strong></p>
<p><script type="application/processing">
size(480,180);

beginShape();
vertex(180,82);
vertex(207,36);
vertex(214, 63);
vertex(407, 11);
vertex(412,30);
vertex(219, 82);
vertex(226, 109);
endShape(CLOSE);

</script></p>
<p>size(480,180);<br />
//start the shape<br />
beginShape();<br />
//x &#038; y coordinates of each point the shape will be drawn through<br />
vertex(180,82);<br />
vertex(207,36);<br />
vertex(214, 63);<br />
vertex(407, 11);<br />
vertex(412,30);<br />
vertex(219, 82);<br />
vertex(226, 109);<br />
//shape complete<br />
endShape(CLOSE);</p>
<p><strong>More from &#8220;GettingStarted With Processing&#8221;</a></strong><br />
So Far up to Chapter 3 and love it. It&#8217;s so simple  and easy to understand so far.  Hopefully chapter 4 will carry on in this spirit.  To give myself the benefit of learning as much as possible here is the P5 Robot:<br />
<script type="application/processing">
//Info: http://processingjs.org/reference
size(720, 480);
smooth();
strokeWeight(2);
background(204);
ellipseMode(RADIUS);

//neck
stroke(102);//grey stroke
line(266,257,266,162);
line(276,257,276,162);
line(286,257,286,162);

//antennae
line(276,155,246,112);
line(276,155,306,56);
line(276,155,342,170);

//body
noStroke();
fill(102);
ellipse(264, 377, 33, 33);
fill(0);
rect(219, 257, 90, 120);
fill(102);
rect(219, 274, 90, 6);

//head

fill(0);
ellipse(264, 155, 45, 45);
fill(255);
ellipse(288, 150, 14, 14);
fill(0);
ellipse(288, 150, 3, 3);
fill(153);
ellipse(263, 148, 5, 5);
ellipse(296, 130, 3, 3);
ellipse(305, 162, 3, 3);
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://briansabbeth.com/processing/?feed=rss2&amp;p=112</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial 2: Color</title>
		<link>http://briansabbeth.com/processing/?p=94</link>
		<comments>http://briansabbeth.com/processing/?p=94#comments</comments>
		<pubDate>Sat, 21 Aug 2010 01:46:06 +0000</pubDate>
		<dc:creator>BriBriBri</dc:creator>
				<category><![CDATA[color]]></category>
		<category><![CDATA[animation]]></category>

		<guid isPermaLink="false">http://briansabbeth.com/processing/?p=94</guid>
		<description><![CDATA[http://processing.org/learning/color/ Handeling color simply in P5 is pretty neat. What I think is super neat is that you can set your own custom color range using colorMode(). This is prettty sweet for RGB color because having 4 channels with a &#8230; <a href="http://briansabbeth.com/processing/?p=94">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://processing.org/learning/color/">http://processing.org/learning/color/</a></p>
<p>Handeling color simply in P5 is pretty neat.  What I think is super neat is that you can set your own  custom color range using colorMode(). This is prettty sweet for RGB color because having 4 channels with a value range from 0 to 255 seems like a bitch when you compare it to having 4 channels with a range of 0 to 100;  So thanks P5 for that one.<br />
<script type="application/processing">
//Info: http://processingjs.org/reference
void setup(){
size (200,200);
background(0);
smooth(); 
}


int a = 10;
float b  =  random(a);
float c  = b*100;
float d = c/50;

void draw(){
  
colorMode(RGB,100,200,1000);
stroke(255);

fill(b,c,d,a);
float e = random (100);  
ellipse(width/2,height/2,e,e);


}







</script></p>
<p><strong>Code:</strong><br />
void setup(){<br />
size (200,200);<br />
background(0);<br />
smooth();<br />
}</p>
<p>int a = 10;<br />
float b  =  random(a);<br />
float c  = b*100;<br />
float d = c/50;</p>
<p>void draw(){<br />
colorMode(RGB,100,200,1000);<br />
stroke(255);</p>
<p>fill (b,c,d,a);<br />
float e = random (100);<br />
ellipse(width/2,height/2,e,e);<br />
}</p>
<p>Basically just messing around with some randomness with the circles. There is a significant difference between the alpha value&#8217;s in this post and the alpha value&#8217;s that are running when compile the sketches on my comp(gotta look into this more).  </p>
<p><strong>HSB &#038; colorMode</strong> <strong>Hue, Saturation, Brightness. </strong> <strong>Hue</strong>: intensity; <strong>Saturation</strong>: degree of purity; <strong>Brightness</strong>: relation to light and dark. <strong>colorMode (mode, range1, range2, range3)</strong> </p>
<p>Color mode changes how P5 interprets color data when changed to HSB. A good idea to follow is when your in HSB set the hue values range from 0-360 and the saturation and brightness range from 0-100.<br />
To set it:<br />
<strong>colorMode(HSB, 360, 100,100);</strong> </p>
<p><script type="application/processing"> 
//Info: http://processingjs.org/reference 
void setup() { 
size(200, 200); frameRate(10); 
} 
void draw() { 
colorMode(HSB); 
for(int i=0; i<100;i++){ 
stroke(i*2.5, 255, 255); 
line(i,0,i,100); 
}
} </script><br />
<strong>Code</strong>:<br />
void draw() {<br />
colorMode(HSB);<br />
for(int i=0; i<100;i++){<br />
stroke(i*2.5, 255, 255);<br />
line(i,0,i,100);<br />
}<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://briansabbeth.com/processing/?feed=rss2&amp;p=94</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Vocab Update</title>
		<link>http://briansabbeth.com/processing/?p=81</link>
		<comments>http://briansabbeth.com/processing/?p=81#comments</comments>
		<pubDate>Fri, 20 Aug 2010 23:59:19 +0000</pubDate>
		<dc:creator>BriBriBri</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[datatype]]></category>
		<category><![CDATA[structure]]></category>
		<category><![CDATA[vocab]]></category>

		<guid isPermaLink="false">http://briansabbeth.com/processing/?p=81</guid>
		<description><![CDATA[from here: http://processing.org/reference/float.html Explains floats. My quick summary of what a float is: A datatype for a number with a decimal point. In yesterday&#8217;s post I used float as a datatype. float a = random(255); float b = 1; float &#8230; <a href="http://briansabbeth.com/processing/?p=81">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>from here:</strong><br />
<a href="http://processing.org/reference/float.html">http://processing.org/reference/float.html</a></p>
<p>Explains floats.  My quick summary of what a <strong>float</strong> is:<br />
A datatype for a number with a decimal point.  In yesterday&#8217;s post I used <strong>float</strong> as a datatype.<br />
float a = random(255);<br />
float b = 1;<br />
float c = b++;</p>
<p>I believe that this was incorrect.  I should have used <strong>int</strong>, the datatype for integers.<br />
float a = random(255);<br />
int b = 1;<br />
int c = b++;</p>
<p>This may seem nit-picky but thats how its gonna have to be! And now on to the learning!</p>
]]></content:encoded>
			<wfw:commentRss>http://briansabbeth.com/processing/?feed=rss2&amp;p=81</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial #1 Simple Drawing:</title>
		<link>http://briansabbeth.com/processing/?p=38</link>
		<comments>http://briansabbeth.com/processing/?p=38#comments</comments>
		<pubDate>Thu, 19 Aug 2010 22:52:55 +0000</pubDate>
		<dc:creator>BriBriBri</dc:creator>
				<category><![CDATA[drawing function]]></category>
		<category><![CDATA[drawing]]></category>
		<category><![CDATA[exercises]]></category>
		<category><![CDATA[getting started]]></category>

		<guid isPermaLink="false">http://briansabbeth.com/processing/?p=38</guid>
		<description><![CDATA[from processing.org. // This was example 2 found at http://processing.org/learning/gettingstarted/. Move your mouse around and you get a white circle, press your mouse and you get a black circle. Code: void setup() { size(480, 120); smooth(); } void draw() { &#8230; <a href="http://briansabbeth.com/processing/?p=38">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>from processing.org.</strong><br />
<script type="application/processing">// <![CDATA[
//Info: http://processingjs.org/reference
void setup(){
 size(600,120);
smooth();
}
void draw()
{
if (mousePressed){
fill(0);
}else{
fill(255);
}
ellipse(mouseX, mouseY, 80, 80);
}
// ]]&gt;</script><br />
This was example 2 found at  <a href="http://processing.org/learning/gettingstarted">http://processing.org/learning/gettingstarted</a>/. Move your mouse around and you get a white circle, press  your mouse and you get a black circle.</p>
<p><strong>Code:</strong><br />
void setup() {<br />
  size(480, 120);<br />
  smooth();<br />
}<br />
void draw() {<br />
  if (mousePressed) {<br />
    fill(0);<br />
  } else {<br />
    fill(255);<br />
  }<br />
  ellipse(mouseX, mouseY, 80, 80);<br />
}</p>
<p>Coming from a background in AS3 its a pretty easy adjustment.  The  differences seem to be as follows:</p>
<p>1) <strong>void</strong>: is declared in the beginning of the function.</p>
<p>2) The built in <strong>draw()</strong> function is similar to AS3&#8242;s enterframe() method and easily handles shapes.    </p>
<p>It was easy to modify:<br />
<script type="application/processing">
//Info: http://processingjs.org/reference
void setup(){
 size(600,120); 
smooth();
}
void draw()
{  
frameRate(30);
if (mousePressed){
fill(255);
ellipse (mouseX, mouseY, 80, 80);
}else{
  fill(255);
  rect (mouseX, mouseY, 80, 80);
}
}
</script><br />
<strong>Code</strong></p>
<p>void setup(){<br />
 size(600,120);<br />
smooth();<br />
}<br />
void draw()<br />
{<br />
frameRate(30);<br />
if (mousePressed){<br />
fill(255);<br />
ellipse (mouseX, mouseY, 80, 80);<br />
}else{<br />
  fill(255);<br />
  rect (mouseX, mouseY, 80, 80);<br />
}<br />
}<br />
</script><br />
___________________________________________________________________<br />
In my version,  the only thing to note is that the we are drawing the shapes within each of the <strong>if</strong> statements (inside of the {then} part of the statement). </p>
<p>Finally here's something a little different:<br />
<script type="application/processing">
//Info: http://processingjs.org/reference

void setup() {
  size(480, 120);
  smooth();
  background(255,0,0);
  frameRate(10);

}


void draw(){
  float a = random(255);
  float b = 1;
  float c = b++;
 
  stroke(255);
  fill(c,b,a);
 

  rect(a,a,a,a);
  
  ellipse(c,c,c,c);

  
}
</script><br />
___________________________________________________________________<br />
<strong>Code</strong></p>
<p>void setup() {<br />
  size(480, 120);<br />
  smooth();<br />
  background(0xff0000);<br />
  frameRate(10);</p>
<p>}</p>
<p>void draw(){<br />
  float a = random(255);<br />
  float b = 1;<br />
  float c = b++;</p>
<p>  stroke(255);<br />
  fill(c,b,a);</p>
<p>  rect(a,a,a,a);</p>
<p>  ellipse(c,c,c,c);</p>
<p>}</p>
<p><script type="application/processing">
//Info: http://processingjs.org/reference

size(200,200);
background(255);
rectMode(CENTER);
rect(100,100,10,100);
smooth();
ellipse(100,38,60,60);
ellipse(100,50,60,10);
ellipse(100,50,10,10);
ellipse(100,40,60,10);
ellipse(100,40,10,10);
ellipse(100,30,60,10);
ellipse(100,30,10,10);

line (95,150,81,160);
line (105,150,120,160);

line (95,70,31,90);
line (105,70,170,90);

</script></p>
]]></content:encoded>
			<wfw:commentRss>http://briansabbeth.com/processing/?feed=rss2&amp;p=38</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Sketches Into WordPress</title>
		<link>http://briansabbeth.com/processing/?p=6</link>
		<comments>http://briansabbeth.com/processing/?p=6#comments</comments>
		<pubDate>Thu, 19 Aug 2010 20:43:12 +0000</pubDate>
		<dc:creator>BriBriBri</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://briansabbeth.com/processing/?p=6</guid>
		<description><![CDATA[First things first. To get a sketch into this blog took all of 5 minutes to figure out. There&#8217;s a WP Plugin that writes a bit of HTML for you called &#8216;Processing&#8217; yay! Just insert your code between the script &#8230; <a href="http://briansabbeth.com/processing/?p=6">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>First things first.  To get a sketch into this blog took all of 5 minutes to figure out.  There&#8217;s a WP Plugin that writes a bit of HTML for you called &#8216;Processing&#8217; yay! Just insert your code between the script tags..</p>
<p>&lt;script type=&#8221;application/processing&#8221;&gt;//Info: http://processingjs.org/reference</p>
<p>//your code goes here.</p>
<p>&lt;/script&gt;</p>
<p><script type="application/processing">// <![CDATA[
//Info: http://processingjs.org/reference
void setup() {
	size(200, 200);
	frameRate(10);
}
void draw() {
	background(#ffffff);
	ellipse(100, 100, random(50), random(50));
}
// ]]&gt;</script></p>
<p>The above sketch is what comes with the plugin.  Below is a simple sketch I made.<br />
<script type="application/processing">// <![CDATA[
//Info: http://processingjs.org/reference
void setup() {
	size(100, 100);
	frameRate(12);
}
float y = 0.0;

void draw()
{
frameRate(30);
background(200);
y = y + .5;
line(0,y,100,y);
}
// ]]&gt;</script></p>
]]></content:encoded>
			<wfw:commentRss>http://briansabbeth.com/processing/?feed=rss2&amp;p=6</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello world!</title>
		<link>http://briansabbeth.com/processing/?p=1</link>
		<comments>http://briansabbeth.com/processing/?p=1#comments</comments>
		<pubDate>Thu, 19 Aug 2010 20:04:42 +0000</pubDate>
		<dc:creator>BriBriBri</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://briansabbeth.com/processing/?p=1</guid>
		<description><![CDATA[Ok, so I really love shit made in Processing.  This is going to be my honest attempt to get it down.  My mission:  An hour a day x 5 days/week dedicated to p5.  I will be using the book, Processing &#8230; <a href="http://briansabbeth.com/processing/?p=1">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Ok, so I really love shit made in Processing.  This is going to be my honest attempt to get it down.  My mission:  An hour a day x 5 days/week dedicated to p5.  I will be using the book, <a href="http://books.google.com/books?id=tqW75bfJkxIC&#038;dq=processing&#038;printsec=frontcover&#038;source=bn&#038;hl=en&#038;ei=qJBtTNWtLcjungfX4JmuCA&#038;sa=X&#038;oi=book_result&#038;ct=result&#038;resnum=5&#038;ved=0CEgQ6AEwBA#v=onepage&#038;q&#038;f=false">Processing</a><br />
I will also be doing tutorials from <a href="http://processing.org">www.processing.org</a>.</p>
<p>I&#8217;m starting at the very beginning, whether I think its redundant or not. I&#8217;m sure that this will improve my general programming skills.  I want to be a digital artist.  I want to be good.  But mostly, I want to know what I am doing backwards and forwards.  I should let anyone that reads this know, I do know a fair amount of AS3 as well as HTML and CSS.   </p>
<p>In the immortal words of Al Bundy&#8230;&#8221;Let&#8217;s rock!&#8221;<a href="http://briansabbeth.com/processing/wp-content/uploads/2010/08/Al_Bundy.jpg"><img src="http://briansabbeth.com/processing/wp-content/uploads/2010/08/Al_Bundy-243x300.jpg" alt="" title="Al_Bundy" width="243" height="300" class="alignright size-medium wp-image-73" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://briansabbeth.com/processing/?feed=rss2&amp;p=1</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

