This site requires JavaScript, please enable it in your browser!
Greenfoot back
blangley83
blangley83 wrote ...

2014/7/14

How do i figure out what pixels are with color/alpha values?

blangley83 blangley83

2014/7/14

#
The alpha value is what is throwing me off; i need to know what pixels look like w/ color alpha value of (255, 0, 0, 255) (0, 0, 255, 128) and lastly- (255, 0, 255, 230) i know the first 3 numbers and how to use them to figure the color our, its the forth number that is throwing me off,. how do i determine what the pixel would look like with the above info ?
danpost danpost

2014/7/14

#
The fourth number is called the 'alpha' value. It is the value that is changed when you use 'setTransparency' on an image. The value you give in the 'setTransparency' call is what the alpha value is set to. Unfortunately, the name of the method is sort of the opposite of what it does (it should probably be called 'setOpaqueness'). That is, the lower the value given, the higher the actual transparency. At the high limit of the value, 255, the color (or image) is completely opaque (totally non-transparent). The lower the value set on the color, the fainter and less apparent the color becomes. So, basically, it does not actually change the color itself; just how much of it is apparent. You could think of it as coats of paint -- it takes 255 coats of paint to make the color totally opaque. You could actually test this by drawing an image whose transparency is set to one repeatedly at the same place in the background of the world. You will see the image slowing fade in view.
You need to login to post a reply.