Press escape to exit fullscreen

{{sketch.instructions}}

CC {{sketch.licenseObject.short}}

Archived Sketch

This sketch is created with an older version of Processing,
and doesn't work on browsers anymore.

View Source Code

Capture Screenshot

Colour based retrieval of objects from an ArrayList

{{$t('general.by')}}
An example of using the colour of pixels in a buffer image to retrieve an object from an ArrayList. The principle is simple enough: when objects are created and added to the ArrayList you draw a 'hit-area' to a buffer image using a fill colour that 'matches' the index of the object in the ArrayList. This means that rather than doing hit-detection on all your objects each frame you can simply use the colour in the buffer corresponding to the mouse position to directly retrieve the object from the ArrayList and, for example, call a method on that object.
We recovered an unsaved version of this sketch. Please review your changes below.

As a Plus+ Member feature, this source code is hidden by the owner.

  • {{co.title}}
    {{$t('sketch.mode-pjs')}} {{$t('general.learnMore')}}
    Select mode or a template
    {{liveCodeLink}}
    • {{l.url.substr(l.url.lastIndexOf('/') + 1)}}
    {{$t('sketch.layoutDescription')}}

    {{k.category}}
    {{k.label}}
    {{k.description}}

    {{$t('sketch.seeMoreShortcuts')}}

    Versions are only kept for 7 days.
    Join Plus+ to keep versions indefinitely!

    {{$t('general.joinPlus')}}


    {{$t('sketch.versionsSummarized')}}