Superfast 2D object picking
in
Share your Work
•
2 years ago
or "Accessing an object from an ArrayList based on the colour of a pixel in a buffer image...",
or "How I Learned to Stop Worrying and Love the tobacco smoke enema"
[edit - thanks Kevin for the suggested, succinct title.
As for the tobacco smoke enema, it puts a whole new spin on the idea of a blow-back
]
Sorry for the unwieldy, solely descriptive title...
I've seen a couple of queries lately about creating mouseOver behaviour on static displays of data and this struck me as a neat approach (though I'm sure plenty of people have thought of this before):
http://www.openprocessing.org/visuals/?visualID=15910
Rather than doing standard distance-based hit-detection it uses a buffer image and colour-based hit-detection. It's likely to be far more efficient to perform one get() operation per frame instead of distance-based tests for each and every object displayed. Obviously, nothing new there... but by setting the colour of the hit-area in the buffer image using a value that can easily be converted to the index of the corresponding object stored in an ArrayList it's then possible to call methods directly on that object. There's probably nothing new about that either, but it's not something I've seen done before and given the questions that have been cropping up I figured I might as well put a demo together :)
or "How I Learned to Stop Worrying and Love the tobacco smoke enema"
[edit - thanks Kevin for the suggested, succinct title.
As for the tobacco smoke enema, it puts a whole new spin on the idea of a blow-back
![](zoho-static/ze/images/yell.gif)
Sorry for the unwieldy, solely descriptive title...
I've seen a couple of queries lately about creating mouseOver behaviour on static displays of data and this struck me as a neat approach (though I'm sure plenty of people have thought of this before):
http://www.openprocessing.org/visuals/?visualID=15910
Rather than doing standard distance-based hit-detection it uses a buffer image and colour-based hit-detection. It's likely to be far more efficient to perform one get() operation per frame instead of distance-based tests for each and every object displayed. Obviously, nothing new there... but by setting the colour of the hit-area in the buffer image using a value that can easily be converted to the index of the corresponding object stored in an ArrayList it's then possible to call methods directly on that object. There's probably nothing new about that either, but it's not something I've seen done before and given the questions that have been cropping up I figured I might as well put a demo together :)