<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Example 5-3: Rollovers</title>
	<atom:link href="http://www.learningprocessing.com/examples/chapter-5/example-5-3/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learningprocessing.com</link>
	<description>A Beginner's Guide to Programming Images, Animation, and Interaction by Daniel Shiffman</description>
	<lastBuildDate>Thu, 09 Feb 2012 16:27:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Daniel Shiffman</title>
		<link>http://www.learningprocessing.com/examples/chapter-5/example-5-3/comment-page-1/#comment-9976</link>
		<dc:creator>Daniel Shiffman</dc:creator>
		<pubDate>Mon, 15 Mar 2010 17:05:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/wp/?page_id=344#comment-9976</guid>
		<description>In this case, it doesn&#039;t really matter, but an if/else structure will only allow the first instance of true to be executed whereas multiple if statements are treated separately.   The following illustrates the point more effectively:

&lt;pre&gt;


int x = 50;

if (x &gt; 30) {
  println(&quot;A&quot;);
} else if (x &gt; 20) {
  println(&quot;B&quot;);
}

if (x &gt; 30) {
  println(&quot;C&quot;);
}

if (x &gt; 20) {
  println(&quot;D&quot;); 
}&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>In this case, it doesn&#8217;t really matter, but an if/else structure will only allow the first instance of true to be executed whereas multiple if statements are treated separately.   The following illustrates the point more effectively:</p>
<pre>

int x = 50;

if (x > 30) {
  println("A");
} else if (x > 20) {
  println("B");
}

if (x > 30) {
  println("C");
}

if (x > 20) {
  println("D");
}</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick Mimran</title>
		<link>http://www.learningprocessing.com/examples/chapter-5/example-5-3/comment-page-1/#comment-9937</link>
		<dc:creator>Patrick Mimran</dc:creator>
		<pubDate>Sun, 14 Mar 2010 17:16:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/wp/?page_id=344#comment-9937</guid>
		<description>I did this exercise only with ifs first i thought i made a mistake but it worked as well i am wondering what is the plus to use if else ?

Thanks

PM

void setup() {
  size(200,200);
}

void draw() {
  background(255);
  stroke(0);
  line(100,0,100,200);
  line(0,100,200,100);
  
  // Fill a black color
  noStroke();
  fill(0);

  // Depending on the mouse location, a different rectangle is displayed.    
  if (mouseX &lt; 100 &amp;&amp; mouseY  100 &amp;&amp; mouseY &lt; 100) {
    rect(100,0,100,100); }
  if (mouseX  100) {
    rect(0,100,100,100);}
 if (mouseX &gt; 100 &amp;&amp; mouseY &gt; 100) {
    rect(100,100,100,100);
  }
}</description>
		<content:encoded><![CDATA[<p>I did this exercise only with ifs first i thought i made a mistake but it worked as well i am wondering what is the plus to use if else ?</p>
<p>Thanks</p>
<p>PM</p>
<p>void setup() {<br />
  size(200,200);<br />
}</p>
<p>void draw() {<br />
  background(255);<br />
  stroke(0);<br />
  line(100,0,100,200);<br />
  line(0,100,200,100);</p>
<p>  // Fill a black color<br />
  noStroke();<br />
  fill(0);</p>
<p>  // Depending on the mouse location, a different rectangle is displayed.<br />
  if (mouseX &lt; 100 &amp;&amp; mouseY  100 &amp;&amp; mouseY &lt; 100) {<br />
    rect(100,0,100,100); }<br />
  if (mouseX  100) {<br />
    rect(0,100,100,100);}<br />
 if (mouseX &gt; 100 &amp;&amp; mouseY &gt; 100) {<br />
    rect(100,100,100,100);<br />
  }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kit</title>
		<link>http://www.learningprocessing.com/examples/chapter-5/example-5-3/comment-page-1/#comment-3633</link>
		<dc:creator>Kit</dc:creator>
		<pubDate>Mon, 27 Jul 2009 13:07:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/wp/?page_id=344#comment-3633</guid>
		<description>After a 20 year break from programming this excercise really grabbed my interest. After doing it as above I tried nested if statements (If mouse on left side of screen then if mouse at top of screen etc.) This didn&#039;t make it any prettier.

Then I remembered you could do this

x=(width/2)*int(mouseX&gt;width/2);
y=(height/2)*int(mouseY &gt; height/2);
rect(x,y,width/2,height/2);

What fun!</description>
		<content:encoded><![CDATA[<p>After a 20 year break from programming this excercise really grabbed my interest. After doing it as above I tried nested if statements (If mouse on left side of screen then if mouse at top of screen etc.) This didn&#8217;t make it any prettier.</p>
<p>Then I remembered you could do this</p>
<p>x=(width/2)*int(mouseX&gt;width/2);<br />
y=(height/2)*int(mouseY &gt; height/2);<br />
rect(x,y,width/2,height/2);</p>
<p>What fun!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

