// write your code here
function swapRedGreen(pixel) {
var newGreen = pixel.getRed();
var newRed = pixel.getGreen();
pixel.setGreen(newGreen);
pixel.setRed(newRed);
return pixel;
}
var image = new SimpleImage ("eastereggs.jpg");
print (image);
for ( var pixel of image.values()){
if (swapRedGreen(pixel) ){
}
}
print (image);
function swapRedGreen(pixel) {
var newGreen = pixel.getRed();
var newRed = pixel.getGreen();
pixel.setGreen(newGreen);
pixel.setRed(newRed);
return pixel;
}
var image = new SimpleImage ("eastereggs.jpg");
print (image);
for ( var pixel of image.values()){
if (swapRedGreen(pixel) ){
}
}
print (image);
What is the different??
ReplyDeletevar img3 = new SimpleImage ("eastereggs.jpg");
for (var pixel of img3.values()){
if (pixel.getX() <= img3.getWidth()){
pixel.setRed(pixel.getGreen());
pixel.setGreen(pixel.getRed());
}
}
print (img3);