In this lab you will become more familiar with using Python for loops
to manipulate colors in a picture.
increaseRed and decreaseRedincreaseRed and decreaseRed functions are
so similar, that we might ask why there are two different functions at all. Create
a new function (for example, by copying and pasting either one of them) that
takes an additional parameter representing the multiplier to use when modifying
the
amount of
red in a
picture.
Design Questions: What would be a clear, meaningful name for your new function? What would be a clear, meaningful name for the new parameter?Use the parameter rather than a constant multiplier value in the body of the function.
increaseRed and decreaseRed functions.
makeSunset function from the previous
mini-lab to
be similar to that in
Recipe 12 (p. 63), but using your new, generalized
functions rather than the reduceBlue and reduceGreen
functions. Test your modified function by loading and running it.
makeSunset function with a number of
different pictures. Choose one that you particularly like and save it
using the JES writePictureTo function at the bottom of p. 49.
For example, suppose my picture was captured in the variable
myPict. To save this picture as a JPEG image, I would type
writePictureTo(myPict,
pickAFile())
When the file selector window opens, I would navigate to the folder
where I want to save the image. I would then type in a name for the
image, such as sunsetPic.jpg. Be sure to include the
.jpg file extension so that it gets saved as an image file.
(The writePictureTo function is described in the section of
Chapter 3 that we have skipped, but you
don't need to read anything else in the section to understand how the
writePictureTo function works.)
Design Questions:Load and run your new function. Did you get the effect you were striving for? If not, experiment with your function, making small changes, loading your function, and running it. When you have the effect you want, create a picture to save.
- How do you think you might achieve a full moon effect? Jot down some notes to yourself of what you plan to try, before you try to fully implement it in Python.
- What would be a clear, meaningful name for your new function?
kzoo.edu. (You may want to review
the instructions in Lab 1 if you've forgotten how
to do this.)