![]() ![]() |
| |||||||||
| Hotspots: Slides and Code TA Corner Comments? Announcements FAQ Static Webspace | ||||||||||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |

Kyle DuPont
| Okay, I give, Adam – how did you do transparency in Jython?!? Mark Guzdial |
| Why, magic of course! Seriously, All I did was examine the colors of both the target and the source pixels when deciding what the new target pixel color should be. You can weight the colors in certain ways. For the middle picture I gave the source pixel a weight of 0.8, and the target pixel a weight of (1.0 - 0.8). For the corner ones, I gave the source a 0.5 weight. It's easy and fun! Adam Wilson |
#This is the function I used to do the transparency above
#Merge takes in 2 pixels and a weight and makes a combination of them
#@return: the resultant color
def merge(pix1, pix2, weight)
if weight > 1.0:
return getColor(pix1)
if weight < 0.0:
return getColor(pix2)
else:
r = (getRed(pix1) * weight) + (getRed(pix2) * (1 - weight))
g = (getGreen(pix1) * weight) + (getGreen(pix2) * (1 - weight))
b = (getBlue(pix1) * weight) + (getBlue(pix2) * (1 - weight))
return makeColor(r, g, b)




