The function moreRed should increase the color of the red value of a pixel by a specified amount so that after executing the code which calls this function (shown below) then the picture is more red by adding 100 to each pixel’s red value.



Which one of the following is the correct implementation of moreRed?


// write your code here
function moreRed(pixel, amount) {
     var r = pixel.getRed() + amount;
     if (r > 255)  r = 255;
     pixel.setRed(r);
     return pixel;
}
var image = new SimpleImage ("eastereggs.jpg");
print (image);
for ( var pixel of image.values()){
    if (moreRed(pixel, 200) ){
       
    }
   
}
print (image);

Comments

Popular posts from this blog

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?