Snippets

Elvis Morales Apply more Red color to an image with JavaScript

Created by Elvis Morales last modified
function moreRed(pixel, amount) {	
     var r = pixel.getRed() + amount;	
     if (r > 255)  r = 255;	
     pixel.setRed(r);	
     return pixel;
}

var image = new SimpleImage("island.png");

print( image );

for ( var pixel of image.values() ) {
    
    pixel = moreRed( pixel, 100 );
    
}

print( image );

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.