#javascript-processing-example-basic-image-backgroundimage.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>BackgroundImage</h2> <p>This example presents the fastest way to load a background image into Processing. To load an image as the background, it must be the same width and height as the program.</p> <p><a href="http://processing.org/learning/basics/backgroundimage.html"><b>Original Processing.org Example:</b> BackgroundImage</a><br> <script type="application/processing"> PImage bg; int a; void setup() { size(200,200); frameRate(30); // The background image must be the same size as the parameters // into the size() method. In this program, the size of "milan_rubbish.jpg" // is 200 x 200 pixels. bg = loadImage("milan_rubbish.jpg"); } void draw() { background(bg); a = (a + 1)%(width+32); stroke(226, 204, 0); line(0, a, width, a-26); line(0, a-6, width, a-32); } </script><canvas width="200" height="200"></canvas></p> <div style="overflow: hidden; height: 0px; width: 0px;"><img src="javascript-processing-example-milan_rubbish.jpg" id="milan_rubbish.jpg"></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> PImage bg; int a; void setup() { size(200,200); frameRate(30); // The background image must be the same size as the parameters // into the size() method. In this program, the size of "milan_rubbish.jpg" // is 200 x 200 pixels. bg = loadImage("milan_rubbish.jpg"); } void draw() { background(bg); a = (a + 1)%(width+32); stroke(226, 204, 0); line(0, a, width, a-26); line(0, a-6, width, a-32); }</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.