Blue Devil on Green Background

Solve It

In this example we want to change only the background of the Duke logo. We will turn the background green and leave the rest of the logo unchanged. Since only the background pixels have a blue value of 255, we can use this condition in an if statement to identify the pixels that should change to green.

Code It

// blue devil on a green background var image = new SimpleImage("duke_blue_devil.png"); for (var pixel of image.values()) { if (pixel.getBlue() == 255) { pixel.setRed(0); pixel.setGreen(255); pixel.setBlue(100); } } print(image);

See It

 
 

Available Images


duke_blue_devil.png
[397x337]

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.