Difference between revisions of "CSC111 Lab 7 Solutions 2014"
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
--[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 17:40, 10 March 2014 (EDT) | --[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 17:40, 10 March 2014 (EDT) | ||
---- | ---- | ||
+ | <onlydft> | ||
+ | |||
=Solution Programs/Functions= | =Solution Programs/Functions= | ||
Line 17: | Line 19: | ||
green = getGreen(pixel) | green = getGreen(pixel) | ||
blue = getBlue(pixel) | blue = getBlue(pixel) | ||
− | + | ||
− | red = red + int( (255-red) * | + | fogFactor = 1.0 * y / getHeight( image ) |
− | green = green + int( (255-green) * | + | red = red + int( (255-red) * fogFactor ) |
− | blue = blue + int( (255-blue) * | + | green = green + int( (255-green) * fogFactor ) |
+ | blue = blue + int( (255-blue) * fogFactor ) | ||
newColor = makeColor( red, green, blue ) | newColor = makeColor( red, green, blue ) | ||
Line 74: | Line 77: | ||
setColor( pixel, newColor ) | setColor( pixel, newColor ) | ||
return image | return image | ||
+ | |||
+ | # saturate(): transforms component into min or max value | ||
+ | # depending on its intensity. | ||
+ | def saturate( component ): | ||
+ | if component < 125: | ||
+ | component = 0 | ||
+ | else: | ||
+ | component = 255 | ||
+ | return component | ||
+ | |||
# AndyWarhol( image ): saturates the image by saturating the | # AndyWarhol( image ): saturates the image by saturating the | ||
Line 89: | Line 102: | ||
# the line below replaces the pixel with its original color. Change | # the line below replaces the pixel with its original color. Change | ||
# the amount of red, green and blue to see some change in the colors | # the amount of red, green and blue to see some change in the colors | ||
− | + | ||
− | + | newColor = makeColor( saturate(red), saturate(green), saturate(blue) ) | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | newColor = makeColor( red, green, blue ) | ||
setColor( pixel, newColor ) | setColor( pixel, newColor ) | ||
return image | return image | ||
Line 184: | Line 186: | ||
+ | </onlydft> | ||
<br /> | <br /> |