Solve It
Again we are coloring the 10 pixels along each edge of an image blue to make a frame around the image. This time we can use both a function and the logic operator "or" to solve the problem.
Code It
// blue border frame using a function
function setBorderColor(pixel){
pixel.setRed(0);
pixel.setGreen(0);
pixel.setBlue(255);
return pixel;
}
var image = new SimpleImage("lion.jpg");
for (var pixel of image.values()) {
var x = pixel.getX();
var y = pixel.getY();
if (x < 10 || y < 10 ||
x >= image.getWidth()-10 ||
y >= image.getHeight()-10){
pixel = setBorderColor(pixel);
}
}
print(image);
See It
Available Images

lion.jpg
[250x188]
Drop your images onto the area above to make it available within your code editor on this page. Note: your images will not be uploaded anywhere, they will stay on your computer.
