# Finding pixels inside a shape

**URL:** https://discourse.processing.org/t/finding-pixels-inside-a-shape/1829
**Category:** Coding Questions
**Created:** [July 16, 2018, 8:15pm UTC](https://discourse.processing.org/t/finding-pixels-inside-a-shape/1829 "2018-07-16T20:15:53Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![talisman](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/talisman/32/479_2.png) [@talisman](https://discourse.processing.org/u/talisman)
#### Post date: [July 16, 2018, 8:15pm UTC](https://discourse.processing.org/t/finding-pixels-inside-a-shape/1829/1 "2018-07-16T20:15:53Z")

</div>

Hi all ,  
I have a ‘bouncing ball’ , of sorts . If you have followed Dan Shiffmans’ tutorials you must have encountered one. I want to show the underlying captured video only within the bouncing ball, like a spotlight.  
I am attaching a pic showing the video and the circle .  
 ![Capture](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/1X/f8883dc5c0814f67aadf0e45c69d489f42d1f4cf.PNG)  
Any hints into which direction to explore would be great.  
Thanks Jonathan

---

<div class="post-metadata">

### Author: ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)
#### Post date: [July 16, 2018, 8:19pm UTC](https://discourse.processing.org/t/finding-pixels-inside-a-shape/1829/2 "2018-07-16T20:19:15Z")

</div>

Have you tried the mask() function ?  
[https://processing.org/reference/PImage\_mask\_.html](https://processing.org/reference/PImage_mask_.html)

---

<div class="post-metadata">

### Author: ![talisman](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/talisman/32/479_2.png) [@talisman](https://discourse.processing.org/u/talisman)
#### Post date: [July 16, 2018, 8:26pm UTC](https://discourse.processing.org/t/finding-pixels-inside-a-shape/1829/3 "2018-07-16T20:26:39Z")

</div>

Thanks jb4X -  
I am using p5.js - does not seem to have a mask .  
If it did (or does and I missed it) : how would you go about it ? I think I need an image with the circle white and the rest black (masking part - right ?) and then move the image rather than the circle? Am I in the right direction?  
Thanks again , Jonathan.

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [July 16, 2018, 8:28pm UTC](https://discourse.processing.org/t/finding-pixels-inside-a-shape/1829/4 "2018-07-16T20:28:00Z")

</div>

[https://p5js.org/reference/#/p5.Image/mask](https://p5js.org/reference/#/p5.Image/mask)

[https://ThimbleProjects.org/gotoloop/97931/](https://ThimbleProjects.org/gotoloop/97931/)

[https://ThimbleProjects.org/gotoloop/97931/sketch.js](https://ThimbleProjects.org/gotoloop/97931/sketch.js)

---

<div class="post-metadata">

### Author: ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)
#### Post date: [July 16, 2018, 8:30pm UTC](https://discourse.processing.org/t/finding-pixels-inside-a-shape/1829/5 "2018-07-16T20:30:53Z")

</div>

Ho sorry,

I didn’t see that you posted in the P5.js section.  
I’m working with processing and assume that everyone is 😕

Anyway, the link that GoToLoop posted is the equivalent in P5.

For the rest you are on the right track I think 🙂
