Closed soundreactor closed 8 years ago
i edited the masking example http://p5js.org/examples/examples/Image_Alpha_Mask.php
using a graphic as mask does not work like expected why so? and is there a fix for that?
var img; var imgMask; var pg;
function preload() { img = loadImage("assets/moonwalk.jpg"); imgMask = loadImage("assets/mask.png"); } function setup() { createCanvas(720, 400); pg = createGraphics(720, 400); pg.background(0); pg.noStroke(); pg.fill(255); pg.ellipse(300, 200, 50, 50); img.mask(pg); } function draw(){ background(0, 102, 153); //this should work but does not image(img, 0,0); }
mask() only works with an image file, not with graphics. From the reference: "Masks part of an image from displaying by loading another image and using it's alpha channel as an alpha channel for this image."
mask()
i edited the masking example http://p5js.org/examples/examples/Image_Alpha_Mask.php
using a graphic as mask does not work like expected why so? and is there a fix for that?
var img; var imgMask; var pg;
function preload() { img = loadImage("assets/moonwalk.jpg"); imgMask = loadImage("assets/mask.png"); } function setup() { createCanvas(720, 400); pg = createGraphics(720, 400); pg.background(0); pg.noStroke(); pg.fill(255); pg.ellipse(300, 200, 50, 50); img.mask(pg); } function draw(){ background(0, 102, 153); //this should work but does not image(img, 0,0); }