topical media & game development

talk show tell print

#javascript-processing-example-basic-form-pointslines.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>PointsLines</h2>
  
  <p>Constructing a simple dimensional form with lines and rectangles.
  Changing the value of the variable 'd' scales the image.
  The four variables set the positions based on the value of 'd'.</p>
  
  <p><a href="http://processing.org/learning/basics/pointslines.html"><b>Original Processing.org Example:</b> PointsLines</a><br>
  <script type="application/processing">
  int d = 40;
  int p1 = d;
  int p2 = p1+d;
  int p3 = p2+d;
  int p4 = p3+d;
  
  size(200, 200);
  background(0);
  
  // Draw gray box
  stroke(153);
  line(p3, p3, p2, p3);
  line(p2, p3, p2, p2);
  line(p2, p2, p3, p2);
  line(p3, p2, p3, p3);
  
  // Draw white points
  stroke(255);
  point(p1, p1);
  point(p1, p3); 
  point(p2, p4);
  point(p3, p1); 
  point(p4, p2);
  point(p4, p4);
  </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>
  int d = 40;
  int p1 = d;
  int p2 = p1+d;
  int p3 = p2+d;
  int p4 = p3+d;
  
  size(200, 200);
  background(0);
  
  // Draw gray box
  stroke(153);
  line(p3, p3, p2, p3);
  line(p2, p3, p2, p2);
  line(p2, p2, p3, p2);
  line(p3, p2, p3, p3);
  
  // Draw white points
  stroke(255);
  point(p1, p1);
  point(p1, p3); 
  point(p2, p4);
  point(p3, p1); 
  point(p4, p2);
  point(p4, p4);</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.