# In Pygame, how can I check if an object is touching a color?

Is there a way to tell if a sprite is touching a specific color on the screen, maybe given as a hex code. I know you can do pygame.sprite.collide for sprites, but how can you do this for a specific color on the whole screen?

• Can you explain this a little bit more please? I dont understand why one would need this, since colliding is colliding, whether green, blue or red. – tkausl Nov 7 '14 at 2:51
• @tkausl Like not colliding with another sprite, but with any color on the screen. Like if the background has a black line, how could i tell if the main sprite is touching that color. – pepper5319 Nov 7 '14 at 2:52
• I'm still not sure what you are trying to do but maybe pygame.org/docs/ref/mask.html will help (with a collisionmap or something). – tkausl Nov 7 '14 at 2:54
• @tkausl Like if the background has a black line, how could i tell if the main sprite is touching that color. – pepper5319 Nov 7 '14 at 2:56
• Oh now i get it. Check groups.google.com/forum/#!topic/pygame-mirror-on-google-groups/… the first answer. I dont know pygame but this seems a good approach (unfortunately, googeling "pygame collision with background" gives really bad results) – tkausl Nov 7 '14 at 3:02