topical media & game development

talk show tell print

#javascript-processing-example-basic-color-creating.htm / htm



  <!DOCTYPE html>
  <html><head>
  <script src="javascript-processing-example-processing.js"></script>
  <script src="javascript-processing-example-init.js"></script>
  <link rel="stylesheet" href="javascript-processing-example-style.css">
  </head><body><h1><a href="http://ejohn.org/blog/processingjs/">Processing.js</a></h1>
  <h2>Creating</h2>
  
  <p>Creating variables for colors that may be referred to 
  in the program by their name, rather than a number.</p>
  
  <p><a href="http://processing.org/learning/basics/creating.html"><b>Original Processing.org Example:</b> Creating</a><br>
  <script type="application/processing">
  size(200, 200);
  noStroke();
  
  color inside = color(204, 102, 0);
  color middle = color(204, 153, 0);
  color outside = color(153, 51, 0);
  
  // These statements are equivalent to the statements above.
  // Programmers may use the format they prefer.
  //color inside = #CC6600;
  //color middle = #CC9900;
  //color outside = #993300;
  
  fill(outside);
  rect(0, 0, 200, 200);
  fill(middle);
  rect(40, 60, 120, 120);
  fill(inside);
  rect(60, 90, 80, 80);
  </script><canvas width="200" height="200"></canvas></p>
  <div style="overflow: hidden; height: 0px; width: 0px;"></div>
  
  <pre><b>// All Examples Written by <a href="http://reas.com/">Casey Reas</a> and <a href="http://benfry.com/">Ben Fry</a>
  // unless otherwise stated.</b>
  size(200, 200);
  noStroke();
  
  color inside = color(204, 102, 0);
  color middle = color(204, 153, 0);
  color outside = color(153, 51, 0);
  
  // These statements are equivalent to the statements above.
  // Programmers may use the format they prefer.
  //color inside = #CC6600;
  //color middle = #CC9900;
  //color outside = #993300;
  
  fill(outside);
  rect(0, 0, 200, 200);
  fill(middle);
  rect(40, 60, 120, 120);
  fill(inside);
  rect(60, 90, 80, 80);</pre>
  </body></html>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.