# Picking library failing on many spheres

**URL:** <https://discourse.processing.org/t/picking-library-failing-on-many-spheres/45202>\
**Category:** Libraries\
**Created:** [October 19, 2024, 8:50am UTC](https://discourse.processing.org/t/picking-library-failing-on-many-spheres/45202 "2024-10-19T08:50:47Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [November 12, 2024, 5:47pm UTC](https://discourse.processing.org/t/picking-library-failing-on-many-spheres/45202/13 "2024-11-12T17:47:39Z")

</div>

another picking:

Everything we draw on screen we also draw on a PGraphics that we don’t display. We use PGraphics only to check it against the mouse. The items / boxes we draw on the PGraphics we draw with an unique color.  
Then we can use `pg.get(mouseX,mouseY)` to check against the pixel.  
We need some kind of list to know which item / box has thi color we found under the mouse.

It is a picking mechanism: The color underneath the mouse is checked against a unique color that every box has. This unique color is invisible on a PGraphics that gets not displayed. In this PGraphics the check of the mouse is performed.

This is useful because we don’t have to do any calculations with mouse position and box position but can just use the colors. We have to use the PGraphics because in the visible graphic, the colors are distorted because we use lights(). The PGraphics has the same size as the visible window and also uses the same camera data of course. But `noLights()` command

see [Looking for more resources about ArrayLists - #45 by Chrisir](https://discourse.processing.org/t/looking-for-more-resources-about-arraylists/21025/45)

---

_[View the full topic](https://discourse.processing.org/t/picking-library-failing-on-many-spheres/45202)._
