Masking an Image


I’m just trying to create a simple graphic and then mask off part of it. This works if I replace the createdGraphic with just an image, but for some reason, when using createGraphic and then saving off an image, it will not mask at all. what am I doing wrong?

var img;
var imgClone;
var mk;

function setup() {
    createCanvas(400, 400);

    img_mask = loadImage('assets/mask.png');

    img = createGraphics(400, 400);
    img.ellipse(200, 200, 300, 300);
    imgClone = img.get();


function draw() {



Like GoToLoop pointed out you need to use the preload to read in your image mask files.

Adding this should fix it

function preload(){
	img_mask = loadImage('assets/mask.png')



That fixed it. Thanks guys.