Letters from Sanford Street # 406

So this programming issue was annoying, but I was able to figure it out. Here is the issue:



The question has you create an image, based on a previous image, which, according to the instructions has pixels with blue values of 200 and green values of 100, and then shows an image of what this should look like, I was having trouble getting the image based on the instructions,

and it's because it's a trick question, the image has blue values of 100, and green values of 200.



an image with blue values of 200 and green values of 100 would look different.


I've included my code below, it includes extra code that I was using to test the issues I was having with my initial code.


* * *


function changeRed(width, height) {
    var picture = new SimpleImage(width, height);
    var red = 0;
//    var blue = 200;
//    var green = 100;



for (var pixel of picture.values()) {
    

if ((pixel.getX()  )){
pixel.setRed(pixel.getX());

//pixel.setBlue(blue);

//pixel.setGreen(green);

pixel.setGreen(100);

pixel.setBlue(200);



}



}

    return picture;
}

var result = changeRed(256,200);
print(result);

var RedBlue = result.getPixel(3, 3)
print(RedBlue)

var RedBlue = result.getPixel(9, 9)
print(RedBlue)

var answer = new SimpleImage("RedBlueGreen.png")
print(answer)

var RedBlue = answer.getPixel(3, 3)
print(RedBlue)

var RedBlue = answer.getPixel(9, 9)
print(RedBlue)







No comments:

Post a Comment