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

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

1 CS 177 Week 4 Recitation Slides for Loop if statement and range

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

View Full Document
2 Announcements EXAM 1 Wednesday 09/29 6:30p - 7:30p EE 129
3 ANY QUESTIONS?

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

View Full Document
4 Let’s remember for Loop def decreaseRed(picture): for p in getPixels(picture) : value = getRed( p ) setRed( p ,value*0.5)
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.

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

View Full Document
Clearing Blue def clearBlue(picture): for p in getPixels(picture): setBlue(p,0) Again, this will work for any picture. 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)

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

View Full Document
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
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### 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
Ask a homework question - tutors are online