Im trying to make a perfect pixel collision in a game and im gonna use a
collision mask to do this, the physics its with chipmunk and i need a
polygon to do it, my idea is, read the image pixel per pixel and store
in a matrix the x and y of the black pixels, later with this matrix i
can create a poligon just geting the first and last element from the
column in each line of the matrix.
The problem is the RMagick, i know how to read the image pixel per pixel
but dont know how to compare the color to get only the black pixels
Im trying to make a perfect pixel collision in a game and im gonna use a
collision mask to do this, the physics its with chipmunk and i need a
polygon to do it, my idea is, read the image pixel per pixel and store
in a matrix the x and y of the black pixels, later with this matrix i
can create a poligon just geting the first and last element from the
column in each line of the matrix.
The problem is the RMagick, i know how to read the image pixel per pixel
but dont know how to compare the color to get only the black pixels
Someone can help me?
thx
black = Magick::Pixel.from_color(“black”)
p == black # true if the pixel p is black.