Image-2 Exercises

For these exercises, write code to manipulate and print the image "x.png". Some basic starter code to load and print the image is provided. Modify and add lines to the starter code as needed to solve each exercise.

1.

Write code to set the pixel at (3, 2) to green.


image-2-ex1

 

2.

Write code to set the pixel at (1, 4) to be purple.


image-2-ex2

 

3.

Write code to set the pixel at (1, 0) to be white.


image-2-ex3

 

4.

Write code to set the pixels (0, 0) and (1, 0) to be yellow.


image-2-ex4

 

5.

Horizontal Red, White, and Blue: set the origin to be red, the pixel to its right to be white, and the pixel to its right to be blue.


image-2-ex5

 

6.

Green diagonal: create a pure blue three pixel diagonal, starting with the bottom right corner and going up and to the left.


image-2-ex6

 

7.

Be creative! Change x.png however you'd like (you can create your own colors). In order to get full credit, you must change at least three different pixels and add two different colors (besides pure red, green, blue, black, or white) to the image.


image-2-ex7

 


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 7 : image-2-ex1 image-2-ex2 image-2-ex3 image-2-ex4 image-2-ex5 image-2-ex6 image-2-ex7

(code appears here)