Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 309
Bruno Croys Felthes Avatar asked Dec 12 '12 10:12

Bruno Croys Felthes


People also ask

How do you know if an image is Rgba?

getcolors() ). If the image is in RGBA mode, then presumably it has transparency in it, but it double-checks by getting the minimum and maximum values of every color channel ( img. getextrema() ), and checks if the alpha channel's smallest value falls below 255.

How to make the image background transparent CSS?

There is no background-opacity property in CSS, but you can fake it by inserting a pseudo element with regular opacity the exact size of the element behind it.

How do you know if an image is transparent?

Images that have transparency often illustrate it by using a gray and white checkered pattern. The idea is that you can see which parts of the image will be transparent before you save it. The checkered pattern is the background. There's no transparency.


1 Answers

'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.

like image 57
hyankov Avatar answered Oct 04 '22 18:10

hyankov