<?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-7: &#8220;Bouncing&#8221; Color</title>
	<atom:link href="http://www.learningprocessing.com/examples/chapter-5/example-5-7/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-7/comment-page-1/#comment-16723</link>
		<dc:creator>Daniel Shiffman</dc:creator>
		<pubDate>Mon, 20 Dec 2010 22:43:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/wp/?page_id=352#comment-16723</guid>
		<description>The color is never (0,0,0).  As the R value (&#039;c1&#039;) counts down, the B value (&#039;c2&#039;) counts up.  So they cross at ~127 (127,0,127), which is purple.</description>
		<content:encoded><![CDATA[<p>The color is never (0,0,0).  As the R value (&#8216;c1&#8242;) counts down, the B value (&#8216;c2&#8242;) counts up.  So they cross at ~127 (127,0,127), which is purple.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dhruv</title>
		<link>http://www.learningprocessing.com/examples/chapter-5/example-5-7/comment-page-1/#comment-16352</link>
		<dc:creator>Dhruv</dc:creator>
		<pubDate>Tue, 14 Dec 2010 11:25:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/wp/?page_id=352#comment-16352</guid>
		<description>why dont the colors become black and white at the extreme instead remain separate and become purple ? (0,0,0) would be black wouldn&#039;t it ?</description>
		<content:encoded><![CDATA[<p>why dont the colors become black and white at the extreme instead remain separate and become purple ? (0,0,0) would be black wouldn&#8217;t it ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: subpixel</title>
		<link>http://www.learningprocessing.com/examples/chapter-5/example-5-7/comment-page-1/#comment-620</link>
		<dc:creator>subpixel</dc:creator>
		<pubDate>Thu, 22 Jan 2009 07:42:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/wp/?page_id=352#comment-620</guid>
		<description>This code does not correct for stepping over the boundaries.

When the code reaches the first boundary (c1 == 255.1, c2 == -0.1), both c1dir and c2dir are negated, but c1 and c2 retain the values 255.1 and -0.1 which will be passed to fill() on the next call to draw(). Similarly for each colour variable heading in the other direction.

Including &quot;c1 = c1 + c1dir;&quot; in the first conditional will repeat the boundary value, so a nice crisp bounce is produced with &quot;c1 = c1 + 2 * c1dir;&quot; or equivalent code.

I might also suggest using variable names other than c1dir and c2dir since they are rates of change, not merely (or perhaps not even) &quot;directions&quot;.

A similar problem exists in the &quot;bouncing ball&quot; (Example 5-6) code, but is arguably less &quot;critical&quot; (the ball doesn&#039;t &quot;bounce&quot; until the centre passes the edge anyway). The bouncing ball problem is one that I still find tricky - for example, a bouncing ball under &quot;gravity&quot; that eventually comes to rest, and that looks good, is not so easy!</description>
		<content:encoded><![CDATA[<p>This code does not correct for stepping over the boundaries.</p>
<p>When the code reaches the first boundary (c1 == 255.1, c2 == -0.1), both c1dir and c2dir are negated, but c1 and c2 retain the values 255.1 and -0.1 which will be passed to fill() on the next call to draw(). Similarly for each colour variable heading in the other direction.</p>
<p>Including &#8220;c1 = c1 + c1dir;&#8221; in the first conditional will repeat the boundary value, so a nice crisp bounce is produced with &#8220;c1 = c1 + 2 * c1dir;&#8221; or equivalent code.</p>
<p>I might also suggest using variable names other than c1dir and c2dir since they are rates of change, not merely (or perhaps not even) &#8220;directions&#8221;.</p>
<p>A similar problem exists in the &#8220;bouncing ball&#8221; (Example 5-6) code, but is arguably less &#8220;critical&#8221; (the ball doesn&#8217;t &#8220;bounce&#8221; until the centre passes the edge anyway). The bouncing ball problem is one that I still find tricky &#8211; for example, a bouncing ball under &#8220;gravity&#8221; that eventually comes to rest, and that looks good, is not so easy!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rosie Wood</title>
		<link>http://www.learningprocessing.com/examples/chapter-5/example-5-7/comment-page-1/#comment-361</link>
		<dc:creator>Rosie Wood</dc:creator>
		<pubDate>Fri, 12 Dec 2008 00:45:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/wp/?page_id=352#comment-361</guid>
		<description>really interesting, I never thought of doing that...</description>
		<content:encoded><![CDATA[<p>really interesting, I never thought of doing that&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

