This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#26 2012-05-20 20:00:21

applejack
Scratcher
Registered: 2010-03-23
Posts: 100+

Re: If touching color algorithm

bobbybee wrote:

bump.


http://i.imgur.com/zKzps.png
http://blocks.scratchr.org/API.php?action=onlineStatus&type=square&user=applejack -I'm http://blocks.scratchr.org/API.php?action=onlineStatus&type=text&user=applejack

Offline

 

#27 2012-05-21 03:02:06

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: If touching color algorithm

The most efficient thing I can think of: Take a sample of the picture behind the sprite, only looking at pixels that are covered (beneath opaque, not transparent pixels).  Iterate through those pixels.  If you find a pixel whose color value is equal to the one you're checking for, stop searching and return true.  If you reach the end of the sample without finding a match, return false.  As long as your images aren't huge, it shouldn't eat up too much overhead.

Offline

 

Board footer