<?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 4-5: Width and Height System Variables</title>
	<atom:link href="http://www.learningprocessing.com/exercises/chapter-4/exercise-4-5/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/exercises/chapter-4/exercise-4-5/comment-page-1/#comment-9609</link>
		<dc:creator>Daniel Shiffman</dc:creator>
		<pubDate>Sat, 27 Feb 2010 02:56:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=895#comment-9609</guid>
		<description>When you give something a negative dimension (width or height) in Processing, this is not the same as a zero width or height.  With a rectangle, it will draw it to the left or up (rather than to the right or down).  With a centered ellipse, it is just the equivalent as a positive width or height.

You&#039;ll want to constrain the values so that ellx or elly stays at zero, i.e.:

&lt;pre&gt;
ellx = constrain(ellx-0.2,0,200);
elly = constrain(elly-0.2,0,200);
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>When you give something a negative dimension (width or height) in Processing, this is not the same as a zero width or height.  With a rectangle, it will draw it to the left or up (rather than to the right or down).  With a centered ellipse, it is just the equivalent as a positive width or height.</p>
<p>You&#8217;ll want to constrain the values so that ellx or elly stays at zero, i.e.:</p>
<pre>
ellx = constrain(ellx-0.2,0,200);
elly = constrain(elly-0.2,0,200);
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick Mimran</title>
		<link>http://www.learningprocessing.com/exercises/chapter-4/exercise-4-5/comment-page-1/#comment-9595</link>
		<dc:creator>Patrick Mimran</dc:creator>
		<pubDate>Fri, 26 Feb 2010 15:13:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=895#comment-9595</guid>
		<description>I made this little code 

to combine an automatic decrease in size with a mouse rectangle size \streching \
it works as i wanted , but when the ellipse arrive to the minimum size , from there it grows again ,
it is something i do not understand . Thanks  Patrick 

int trectx = 50;
int trecty = 50 ;

int trectmx = 50;
int trectmY = 50;

float ellx = 200;
float elly = 200;


void setup () {
  
  size (400, 400 ) ;
  
}

void draw () {
  
  background (250,0,0);
  stroke (0) ;
 
  rect ( width/8 ,height/2 , mouseX , mouseY ) ;
  stroke (600,0);
  fill ( 250,0);
  rect ( width/2 ,height/2 , mouseX+200 ,mouseY+200 ) ;
  fill ( 250);
   rectMode (CENTER );
  rect ( width/8 ,height/2 , mouseX , mouseY ) ;
  rect ( 350 ,height/2 , mouseX ,mouseY ) ;
  ellipse (width/2,height/2,ellx,elly);
  stroke (200);
  line (0,0 ,400,400);
  stroke (250);
   line (400,0 ,0,400);
   
   ellx = ellx -0.2 ;
   elly = elly -0.2 ;
  
  
}</description>
		<content:encoded><![CDATA[<p>I made this little code </p>
<p>to combine an automatic decrease in size with a mouse rectangle size \streching \<br />
it works as i wanted , but when the ellipse arrive to the minimum size , from there it grows again ,<br />
it is something i do not understand . Thanks  Patrick </p>
<p>int trectx = 50;<br />
int trecty = 50 ;</p>
<p>int trectmx = 50;<br />
int trectmY = 50;</p>
<p>float ellx = 200;<br />
float elly = 200;</p>
<p>void setup () {</p>
<p>  size (400, 400 ) ;</p>
<p>}</p>
<p>void draw () {</p>
<p>  background (250,0,0);<br />
  stroke (0) ;</p>
<p>  rect ( width/8 ,height/2 , mouseX , mouseY ) ;<br />
  stroke (600,0);<br />
  fill ( 250,0);<br />
  rect ( width/2 ,height/2 , mouseX+200 ,mouseY+200 ) ;<br />
  fill ( 250);<br />
   rectMode (CENTER );<br />
  rect ( width/8 ,height/2 , mouseX , mouseY ) ;<br />
  rect ( 350 ,height/2 , mouseX ,mouseY ) ;<br />
  ellipse (width/2,height/2,ellx,elly);<br />
  stroke (200);<br />
  line (0,0 ,400,400);<br />
  stroke (250);<br />
   line (400,0 ,0,400);</p>
<p>   ellx = ellx -0.2 ;<br />
   elly = elly -0.2 ;</p>
<p>}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Shiffman</title>
		<link>http://www.learningprocessing.com/exercises/chapter-4/exercise-4-5/comment-page-1/#comment-9341</link>
		<dc:creator>Daniel Shiffman</dc:creator>
		<pubDate>Mon, 15 Feb 2010 04:31:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=895#comment-9341</guid>
		<description>The if statement needs to live somewhere in your code where it will actually be executed, i.e. setup() or draw().  Also, you are missing some semi-colons.  Try the following:

&lt;pre&gt;
int rDim=20;

void setup(){
  size (250,200);
  background(175);
  if (width &gt; height){
    rDim=height;
  }  else {
    rDim=width;
  }

}


void draw(){
  stroke(0);
  rectMode(CENTER);
  rect(125,100,rDim/2,rDim/2);
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>The if statement needs to live somewhere in your code where it will actually be executed, i.e. setup() or draw().  Also, you are missing some semi-colons.  Try the following:</p>
<pre>
int rDim=20;

void setup(){
  size (250,200);
  background(175);
  if (width > height){
    rDim=height;
  }  else {
    rDim=width;
  }

}

void draw(){
  stroke(0);
  rectMode(CENTER);
  rect(125,100,rDim/2,rDim/2);
}
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian</title>
		<link>http://www.learningprocessing.com/exercises/chapter-4/exercise-4-5/comment-page-1/#comment-9322</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Sun, 14 Feb 2010 06:32:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=895#comment-9322</guid>
		<description>Daniel,
thanks for one of the easiest to understand programming books I&#039;ve ever come across...I&#039;ve been waiting most of my life to work with sensors and microcontrollers, and now people like you are making this all accessible to people like me.

I was modifying this exercise to see if I could draw the elements with original proportions, but scaled to the window size. I thought I could evaluate the narrowest of width and height, then use that as a basis to dimension the shapes. But my &quot;if&quot; code block seems to be causing trouble (it will run if I remove it, but nothing renders (or prints) if I leave the code block in.) What do I have wrong? And since I can&#039;t seem to get the println() to work either, I can&#039;t diagnose what the program is doing...

int rDim=20;

void setup(){
  size (250,200);
  background(175);
}

  if (width=&gt;height){
  rDim=height
} else {
  rDim=width
}


void draw(){
  stroke(0);
  rectMode(CENTER);
  rect(125,100,rDim/2,rDim/2);
}


thanks!</description>
		<content:encoded><![CDATA[<p>Daniel,<br />
thanks for one of the easiest to understand programming books I&#8217;ve ever come across&#8230;I&#8217;ve been waiting most of my life to work with sensors and microcontrollers, and now people like you are making this all accessible to people like me.</p>
<p>I was modifying this exercise to see if I could draw the elements with original proportions, but scaled to the window size. I thought I could evaluate the narrowest of width and height, then use that as a basis to dimension the shapes. But my &#8220;if&#8221; code block seems to be causing trouble (it will run if I remove it, but nothing renders (or prints) if I leave the code block in.) What do I have wrong? And since I can&#8217;t seem to get the println() to work either, I can&#8217;t diagnose what the program is doing&#8230;</p>
<p>int rDim=20;</p>
<p>void setup(){<br />
  size (250,200);<br />
  background(175);<br />
}</p>
<p>  if (width=&gt;height){<br />
  rDim=height<br />
} else {<br />
  rDim=width<br />
}</p>
<p>void draw(){<br />
  stroke(0);<br />
  rectMode(CENTER);<br />
  rect(125,100,rDim/2,rDim/2);<br />
}</p>
<p>thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zimbrone</title>
		<link>http://www.learningprocessing.com/exercises/chapter-4/exercise-4-5/comment-page-1/#comment-8404</link>
		<dc:creator>zimbrone</dc:creator>
		<pubDate>Mon, 18 Jan 2010 12:00:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=895#comment-8404</guid>
		<description>I have set  the right square position on x axis with &quot;width/8*7&quot;, I think it is more or less the same...
Like splitting the width in eight parts then multiply for seven.
Thanks for your book, in years I have tried to understand something about coding with no results...
Yours is the first programming approach I can understand.
When I am sixty-four...tatatatata tatatata....
I will be sixty-four in eight years from now.
 I will be alive and writing code for fun.
Thanks for your effort.</description>
		<content:encoded><![CDATA[<p>I have set  the right square position on x axis with &#8220;width/8*7&#8243;, I think it is more or less the same&#8230;<br />
Like splitting the width in eight parts then multiply for seven.<br />
Thanks for your book, in years I have tried to understand something about coding with no results&#8230;<br />
Yours is the first programming approach I can understand.<br />
When I am sixty-four&#8230;tatatatata tatatata&#8230;.<br />
I will be sixty-four in eight years from now.<br />
 I will be alive and writing code for fun.<br />
Thanks for your effort.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Shiffman</title>
		<link>http://www.learningprocessing.com/exercises/chapter-4/exercise-4-5/comment-page-1/#comment-7376</link>
		<dc:creator>Daniel Shiffman</dc:creator>
		<pubDate>Sun, 06 Dec 2009 23:27:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=895#comment-7376</guid>
		<description>Ah, yes, good clarification.  I&#039;ll have to add the parentheses in any next rounds of corrections.</description>
		<content:encoded><![CDATA[<p>Ah, yes, good clarification.  I&#8217;ll have to add the parentheses in any next rounds of corrections.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: K</title>
		<link>http://www.learningprocessing.com/exercises/chapter-4/exercise-4-5/comment-page-1/#comment-7372</link>
		<dc:creator>K</dc:creator>
		<pubDate>Sun, 06 Dec 2009 21:23:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=895#comment-7372</guid>
		<description>The sum is actually width - (width/8). Its just not immediately obvious from the way the code presents it. I&#039;d be interested in some math books too if anyone has any recommendations.</description>
		<content:encoded><![CDATA[<p>The sum is actually width &#8211; (width/8). Its just not immediately obvious from the way the code presents it. I&#8217;d be interested in some math books too if anyone has any recommendations.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: LoPan</title>
		<link>http://www.learningprocessing.com/exercises/chapter-4/exercise-4-5/comment-page-1/#comment-5766</link>
		<dc:creator>LoPan</dc:creator>
		<pubDate>Wed, 21 Oct 2009 21:47:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=895#comment-5766</guid>
		<description>Hi, I just wanted to ask you a little bit about the math used to determine the right-hand rect&#039;s x-position. My math is pretty weak, and for some reason the width-width/8 operation messes with my head.  Is there a book you would recommend for people who want to improve their numerical skills for programming?

Thanks!
(Great book btw)</description>
		<content:encoded><![CDATA[<p>Hi, I just wanted to ask you a little bit about the math used to determine the right-hand rect&#8217;s x-position. My math is pretty weak, and for some reason the width-width/8 operation messes with my head.  Is there a book you would recommend for people who want to improve their numerical skills for programming?</p>
<p>Thanks!<br />
(Great book btw)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

