rec4 - CS 177 Week 4 Recitation Slides for Loop if...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CS 177 Week 4 Recitation Slides for Loop if statement and range
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Announcements EXAM 1 Wednesday 09/29 6:30p - 7:30p EE 129
Background image of page 2
3 ANY QUESTIONS?
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Let’s remember for Loop def decreaseRed(picture): for p in getPixels(picture) : value = getRed( p ) setRed( p ,value*0.5)
Background image of page 4
5 What is wrong here? def decreaseRed(picture): for p in getPixels(picture) : value = getRed( p ) setRed( p ,value*0.5) Indentation is wrong! This statement is not inside the for loop. Only the last pixel is changed.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Clearing Blue def clearBlue(picture): for p in getPixels(picture): setBlue(p,0) Again, this will work for any picture. 6
Background image of page 6
Lightening and darkening an image def darken(picture): for px in getPixels(picture): color = getColor(px) color = makeDarker(color) setColor(px ,color) 7 def lighten(picture): for px in getPixels(picture): color = getColor(px) color = makeLighter(color) setColor(px ,color)
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Let’s think it through R,G,B go from 0 to 255 Let’s say Red is 10. That’s very light red. What’s the opposite? LOTS of Red! The negative of that would be 255 – 10 = 245 So, for each pixel, if we negate each color component in creating a new color, we negate the whole picture. 8
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 22

rec4 - CS 177 Week 4 Recitation Slides for Loop if...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online