<?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: Exercise 5-6: Fading Squares</title>
	<atom:link href="http://www.learningprocessing.com/exercises/chapter-5/exercise-5-6/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>Fri, 10 Feb 2012 19:58:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Leo T Nozawa</title>
		<link>http://www.learningprocessing.com/exercises/chapter-5/exercise-5-6/comment-page-1/#comment-20572</link>
		<dc:creator>Leo T Nozawa</dc:creator>
		<pubDate>Fri, 12 Aug 2011 02:05:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=776#comment-20572</guid>
		<description>Kit, if u&#039;re using ints try using this:

  if(rec == 0) rec = 1;
  if(rec1 == 0) rec1 = 1;
  if(rec2 == 0) rec2 = 1;
  if(rec3 == 0) rec3 = 1;

Can&#039;t make work with constrain using int too...</description>
		<content:encoded><![CDATA[<p>Kit, if u&#8217;re using ints try using this:</p>
<p>  if(rec == 0) rec = 1;<br />
  if(rec1 == 0) rec1 = 1;<br />
  if(rec2 == 0) rec2 = 1;<br />
  if(rec3 == 0) rec3 = 1;</p>
<p>Can&#8217;t make work with constrain using int too&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: riko</title>
		<link>http://www.learningprocessing.com/exercises/chapter-5/exercise-5-6/comment-page-1/#comment-9434</link>
		<dc:creator>riko</dc:creator>
		<pubDate>Thu, 18 Feb 2010 23:06:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=776#comment-9434</guid>
		<description>Hi!

A differente solution, but I don&#039;t know if it&#039;s better or not to do this.

float brightA = 0;
float brightB = 0;
float brightC = 0;
float brightD = 0;

void setup () {
  size(200,200);
}
void draw(){
  background(0);
  stroke(255);
  line(0,100,200,100);
  line(100,0,100,200);
  if(mouseX &gt;100 &amp;&amp; mouseY &gt;100) {
    brightA = 255;
  }else{
    brightA = brightA - 1;
  }
  if(mouseX &gt; 100 &amp;&amp; mouseY &lt;100){
    brightB = 255;
  }else{
    brightB = brightB - 1;
  }
  if(mouseX &lt;100 &amp;&amp; mouseY &lt;100) {
    brightC = 255;
  }else{
    brightC = brightC - 1;
  }
  if(mouseX 100){
    brightD = 255;
  }else{
    brightD = brightD - 1;
  }

  fill(brightA);
  rect(100,100,100,100);
  fill(brightB);
  rect(100,0,100,100);
  fill(brightC);
  rect(0,0,100,100);
  fill(brightD);
  rect(0,100,100,100);

  brightA = constrain (brightA,0,255);
  brightB = constrain (brightB,0,255);
  brightC = constrain (brightC,0,255);
  brightD = constrain (brightD,0,255);


}</description>
		<content:encoded><![CDATA[<p>Hi!</p>
<p>A differente solution, but I don&#8217;t know if it&#8217;s better or not to do this.</p>
<p>float brightA = 0;<br />
float brightB = 0;<br />
float brightC = 0;<br />
float brightD = 0;</p>
<p>void setup () {<br />
  size(200,200);<br />
}<br />
void draw(){<br />
  background(0);<br />
  stroke(255);<br />
  line(0,100,200,100);<br />
  line(100,0,100,200);<br />
  if(mouseX &gt;100 &amp;&amp; mouseY &gt;100) {<br />
    brightA = 255;<br />
  }else{<br />
    brightA = brightA &#8211; 1;<br />
  }<br />
  if(mouseX &gt; 100 &amp;&amp; mouseY &lt;100){<br />
    brightB = 255;<br />
  }else{<br />
    brightB = brightB &#8211; 1;<br />
  }<br />
  if(mouseX &lt;100 &amp;&amp; mouseY &lt;100) {<br />
    brightC = 255;<br />
  }else{<br />
    brightC = brightC &#8211; 1;<br />
  }<br />
  if(mouseX 100){<br />
    brightD = 255;<br />
  }else{<br />
    brightD = brightD &#8211; 1;<br />
  }</p>
<p>  fill(brightA);<br />
  rect(100,100,100,100);<br />
  fill(brightB);<br />
  rect(100,0,100,100);<br />
  fill(brightC);<br />
  rect(0,0,100,100);<br />
  fill(brightD);<br />
  rect(0,100,100,100);</p>
<p>  brightA = constrain (brightA,0,255);<br />
  brightB = constrain (brightB,0,255);<br />
  brightC = constrain (brightC,0,255);<br />
  brightD = constrain (brightD,0,255);</p>
<p>}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Shiffman</title>
		<link>http://www.learningprocessing.com/exercises/chapter-5/exercise-5-6/comment-page-1/#comment-8690</link>
		<dc:creator>Daniel Shiffman</dc:creator>
		<pubDate>Sun, 31 Jan 2010 01:47:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=776#comment-8690</guid>
		<description>No, floats can absolutely be negative.  Processing just constrains the values for you when you pass in a float for brightness into the fill() function and this doesn&#039;t happen with an int.

It&#039;s probably best to use constrain() in all cases just to be safe.</description>
		<content:encoded><![CDATA[<p>No, floats can absolutely be negative.  Processing just constrains the values for you when you pass in a float for brightness into the fill() function and this doesn&#8217;t happen with an int.</p>
<p>It&#8217;s probably best to use constrain() in all cases just to be safe.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://www.learningprocessing.com/exercises/chapter-5/exercise-5-6/comment-page-1/#comment-8682</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Sat, 30 Jan 2010 17:18:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=776#comment-8682</guid>
		<description>Does that mean float values can&#039;t go into negatives? (that would explain why there is no constrain code in the answer?)</description>
		<content:encoded><![CDATA[<p>Does that mean float values can&#8217;t go into negatives? (that would explain why there is no constrain code in the answer?)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://www.learningprocessing.com/exercises/chapter-5/exercise-5-6/comment-page-1/#comment-3638</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Mon, 27 Jul 2009 15:35:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=776#comment-3638</guid>
		<description>When you use integers, Processing will read negative numbers as strange colors.  So you must make sure you constrain the values to between 0 and 255.

&lt;pre&gt;
  // All rectangles always fade
  bright0 = constrain(bright0 - 1,0,255);
  bright1 = constrain(bright1 - 1,0,255);
  bright2 = constrain(bright2 - 1,0,255);
  bright3 = constrain(bright3 - 1,0,255);
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>When you use integers, Processing will read negative numbers as strange colors.  So you must make sure you constrain the values to between 0 and 255.</p>
<pre>
  // All rectangles always fade
  bright0 = constrain(bright0 - 1,0,255);
  bright1 = constrain(bright1 - 1,0,255);
  bright2 = constrain(bright2 - 1,0,255);
  bright3 = constrain(bright3 - 1,0,255);
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kit</title>
		<link>http://www.learningprocessing.com/exercises/chapter-5/exercise-5-6/comment-page-1/#comment-3634</link>
		<dc:creator>Kit</dc:creator>
		<pubDate>Mon, 27 Jul 2009 13:32:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=776#comment-3634</guid>
		<description>I can&#039;t work out exactly why this won&#039;t work if the brightness variables are int rather than float.</description>
		<content:encoded><![CDATA[<p>I can&#8217;t work out exactly why this won&#8217;t work if the brightness variables are int rather than float.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

