Saturday, 2 July 2016

The function swapRedGreen has one parameter, a pixel. This function swaps the red and green values and returns the resulting red, green and blue values somehow. Which one of the following is the correct code for this function?

// write your code here
function swapRedGreen(pixel) {
     var newGreen = pixel.getRed();
     var newRed = pixel.getGreen();
     return pixel;
var image = new SimpleImage ("eastereggs.jpg");
print (image);
for ( var pixel of image.values()){
    if (swapRedGreen(pixel) ){
print (image);

1 comment:

  1. What is the different??
    var img3 = new SimpleImage ("eastereggs.jpg");

    for (var pixel of img3.values()){
    if (pixel.getX() <= img3.getWidth()){

    print (img3);