# someImage.mask (someMaskImage), not working (the mask is a createGraphic)

**URL:** <https://discourse.processing.org/t/someimage-mask-somemaskimage-not-working-the-mask-is-a-creategraphic/44395>\
**Category:** Coding Questions\
**Created:** [May 7, 2024, 4:39am UTC](https://discourse.processing.org/t/someimage-mask-somemaskimage-not-working-the-mask-is-a-creategraphic/44395 "2024-05-07T04:39:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vkbr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/vkbr/32/16844_2.png) [@vkbr](https://discourse.processing.org/u/vkbr)\
**Post date:** [May 7, 2024, 4:39am UTC](https://discourse.processing.org/t/someimage-mask-somemaskimage-not-working-the-mask-is-a-creategraphic/44395/1 "2024-05-07T04:39:19Z")

</div>

Hey folks,  
Can you please have a look in this sketch at

> **[p5.js Web Editor](https://editor.p5js.org/v-k-/sketches/UyIrR-M4o)**
>
> A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.

I can’t grasp why masking is not working.

It simple, here is the code. (you can run it in the above link, image included)

```auto
let face; // Variable to store the face image
let matte; // Variable to store the matte image

function preload() {
  // Load the face image
  face = loadImage("153423.jpg");
}

function setup() {
  createCanvas(windowWidth, windowHeight);
  background(0, 0, 70); // Set background color

  // Create a graphics object for the matte
  matte = createGraphics(face.width, face.height);
  matte.background(0); // Background color for the matte
  matte.fill(255); // Fill color for the matte
  matte.noStroke();
  matte.ellipse(matte.width / 2, matte.height / 2, matte.width); // Draw an ellipse as the matte
}

function draw() {
  background(0, 0, 70); // Set background color
  // Draw the face image
  face.mask(matte);
  image(face, 100, 100);

  // Draw the matte image uncomment to see
  // image(matte, 100, 100);
}

```

---

<div class="post-metadata">

**Author:** ![alptugan](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/alptugan/32/19406_2.png) [@alptugan](https://discourse.processing.org/u/alptugan)\
**Post date:** [May 7, 2024, 6:08am UTC](https://discourse.processing.org/t/someimage-mask-somemaskimage-not-working-the-mask-is-a-creategraphic/44395/2 "2024-05-07T06:08:02Z")

</div>

You can remove the following line;

> [@vkbr](#):
>
> ```auto
> matte.background(0); // Background color for the matte
> 
> ```

---

<div class="post-metadata">

**Author:** ![vkbr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/vkbr/32/16844_2.png) [@vkbr](https://discourse.processing.org/u/vkbr)\
**Post date:** [May 7, 2024, 11:16am UTC](https://discourse.processing.org/t/someimage-mask-somemaskimage-not-working-the-mask-is-a-creategraphic/44395/3 "2024-05-07T11:16:08Z")

</div>

Thanks!!! Im used to b&w masks from video fx world, missed that p5 uses the alpha channel already.  
You saved my day, well night… whatever : )

thanks.
