// write your code here
function setBlack(pixel){
pixel.setBlue(0);
pixel.setGreen(0);
pixel.setRed(0);
return pixel;
}
function pixelOnEdgeDifferentThicknesses(pixel, image, borderWidth){
var x = pixel.getX();
var y = pixel.getY();
if (x < borderWidth) return true;
if (y < (borderWidth+40)) return true;
if (x >= image.getWidth() - borderWidth) return true;
if (y >= image.getHeight() - (borderWidth+40)) return true;
return false;
}
var image = new SimpleImage ("lion.jpg");
print (image);
for ( var pixel of image.values()){
if (pixelOnEdgeDifferentThicknesses(pixel, image, 25) ){
pixel = setBlack(pixel);
}
}
print (image);
Here is a picture of the island with different thicknesses for the vertical versus horizontal borders:
function setBlack(pixel){
pixel.setBlue(0);
pixel.setGreen(0);
pixel.setRed(0);
return pixel;
}
function pixelOnEdgeDifferentThicknesses(pixel, image, borderWidth){
var x = pixel.getX();
var y = pixel.getY();
if (x < borderWidth) return true;
if (y < (borderWidth+40)) return true;
if (x >= image.getWidth() - borderWidth) return true;
if (y >= image.getHeight() - (borderWidth+40)) return true;
return false;
}
var image = new SimpleImage ("lion.jpg");
print (image);
for ( var pixel of image.values()){
if (pixelOnEdgeDifferentThicknesses(pixel, image, 25) ){
pixel = setBlack(pixel);
}
}
print (image);
Here is a picture of the island with different thicknesses for the vertical versus horizontal borders:
No comments:
Post a Comment