#javascript-processing-example-basic-image-alphamask.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>Alphamask</h2> <p>Loads a "mask" for an image to specify the transparency in different parts of the image. The two images are blended together using the mask() method of PImage. Created 29 April 2003.</p> <p><a href="http://processing.org/learning/basics/alphamask.html"><b>Original Processing.org Example:</b> Alphamask</a><br> <script type="application/processing"> PImage img; PImage maskImg; void setup() { size(200,200); img = loadImage("test.jpg"); maskImg = loadImage("mask.jpg"); img.mask(maskImg); } void draw() { background((mouseX+mouseY)/1.5); image(img, 50, 50); image(img, mouseX-50, mouseY-50); } </script><canvas width="200" height="200"></canvas></p> <div style="overflow: hidden; height: 0px; width: 0px;"><img src="javascript-processing-example-mask.jpg" id="mask.jpg"><img src="javascript-processing-example-test.jpg" id="test.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 img; PImage maskImg; void setup() { size(200,200); img = loadImage("test.jpg"); maskImg = loadImage("mask.jpg"); img.mask(maskImg); } void draw() { background((mouseX+mouseY)/1.5); image(img, 50, 50); image(img, mouseX-50, mouseY-50); }</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.