diagonal with half the pixels red.

var image = new SimpleImage(200,200);
w = image.getWidth();
for (var p of image.values()){
    p.setRed(255);
    p.setBlue(0);
    p.setGreen(0);
    if (p.getX()+p.getY() < w ){
        p.setRed(0);
        p.setBlue(0);
        p.setGreen(0);
    }
}
print (image);




var image = new SimpleImage(200,200);
w = image.getWidth();
for (var p of image.values()){
    var x = p.getX();
    var y = p.getY();
    if ( x > 200-y){
        p.setRed(255);
    }
    if ( x > y){
        p.setRed(255);
    }
    if ( x > 20){
        p.setRed(255);
    }
    
}
print (image);

Comments

Popular posts from this blog

The function swapRedGreen has one parameter, a pixel. This function swaps the red and green values and returns the resulting red, green and blue values somehow. Which one of the following is the correct code for this function?