User Tools

Site Tools


programming_fundamentals_with_processing:ch03-places-to-put-things

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
programming_fundamentals_with_processing:ch03-places-to-put-things [2017/07/26 17:53] – [Math versus programming] mithatprogramming_fundamentals_with_processing:ch03-places-to-put-things [2017/07/26 17:57] – [Outputting variables] mithat
Line 36: Line 36:
 int b; int b;
 </code> </code>
-do exactly that--they are **variable declarations**. They tell the Processing compiler that you plan to use two variables, one named ''%%a%%'' and the other named ''%%b%%''.((Some programming languages automatically create new variables for you as soon as you use them. Processing isn't one of those.+do exactly that---they are **variable declarations**. They tell the Processing compiler that you plan to use two variables, one named ''%%a%%'' and the other named ''%%b%%''.((Some programming languages automatically create new variables for you as soon as you use them. Processing isn't one of those.
 )) ))
  
Line 72: Line 72:
 One way we can learn the value of a variable is to output it to the console as in the code below: One way we can learn the value of a variable is to output it to the console as in the code below:
  
-**program ''%%variables2.pde%%'':** +<file java variables2.pde>
- +
-<code java>+
 void setup () { void setup () {
   int a;   int a;
Line 85: Line 83:
   println(a);   println(a);
 } }
-</code>+</file>
 or, if you like, or, if you like,
  
-**program ''%%variables2a.pde%%'':** +<file java variables2a.pde>
- +
-<code java>+
 void setup () { void setup () {
   int a;   int a;
Line 103: Line 99:
   println(a);   println(a);
 } }
-</code>+</file>
 You can also use variables in places where Processing expects literal constants. Here's an example: You can also use variables in places where Processing expects literal constants. Here's an example:
  
-**program ''%%variables3.pde%%'':** +<file java variables3.pde>
- +
-<code java>+
 void setup () { void setup () {
   int a;   int a;
Line 118: Line 112:
   rect(0, 0, a, b);   rect(0, 0, a, b);
 } }
-</code>+</file>
 This will draw a rectangle whose upper left corner is at the origin of the canvas, whose width is the value of ''%%a%%'' (53 pixels) and whose height is the value of ''%%b%%'' (33 pixels). This example shows that we can use variables whose values might be the result of calculations based on other stuff to control how things are drawn. That should seem at least a little bit interesting. This will draw a rectangle whose upper left corner is at the origin of the canvas, whose width is the value of ''%%a%%'' (53 pixels) and whose height is the value of ''%%b%%'' (33 pixels). This example shows that we can use variables whose values might be the result of calculations based on other stuff to control how things are drawn. That should seem at least a little bit interesting.
  
programming_fundamentals_with_processing/ch03-places-to-put-things.txt · Last modified: 2017/07/26 18:06 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki