Image-7 Exercises

< CS101

For these problems, you may use literal numbers in your x,y tests, like (x < 250), or you may use expressions like (x < image.getWidth() / 2).


Write code to set a vertical stripe 100 pixels wide at the right edge of the flowers image to dark gray (red green blue all set to 100). The flowers image is 457 pixels wide.




Write code to set a horizontal stripe 20 pixels high along the bottom of the flowers image to light gray (200 200 200). The flowers image is 360 pixels high.




Flip of problem (2). Set to gray all of the pixels except the bottom horizontal stripe.




Write code to set the left half of the flowers image to be grayscale. (See the image-6 section for the definition of grayscale).



Each click of a Run button saves that code on the computer running the browser. The button below retrieves the all code exercises listed to the right of the button.

count 4 : image-7-ex1 image-7-ex2 image-7-ex3 image-7-ex4

(code appears here)