Bruno Croys Felthes
Bruno Croys Felthes

Reputation: 1203

Can i know if an image is transparent at a specific position?

I'm making a game in javascript (for IE 10) that has a colision system. I want to colide the objects only when 2 visible parts colide, i want to ignore the transparent parts of the images.

Has any way to know if a position from an < img > is transparent or not?

Upvotes: 6

Views: 835

Answers (2)

hyankov
hyankov

Reputation: 4130

'Burn' the image into an HTML5 canvas, then get the specific pixel from the canvas and check its Alpha (http://falcon80.com/HTMLCanvas/PixelManipulation/getImageData.html).

I think it would be easier if you only worked with HTML5 canvas instead of moving around DOM segments.

Upvotes: 4

Anass
Anass

Reputation: 974

Check the following post :

You can use an image with the old-fashioned < map > and < area > tags.

Hover only on non-transparent part of image

Upvotes: 0

Related Questions