Thinking Critically about Your Program

    Write a program to draw a red square that is 200 pixels by 200 pixels with this black edge that is 20 pixels wide in the middle and has two diagonal corners (imagine that if the diagonal lines kept going, they would meet in the center of the diagram).

Code It

// create a black square var image = new SimpleImage(200,200); for (var pixel of image.values()) { var x = pixel.getX(); var y = pixel.getY(); if (x>y) pixel.setRed(255); else if (x+y > 200) pixel.setRed(255); else if (x>20) pixel.setRed(255); } print(image);

See It

 
 

Available Images


chapel.png
[231x308]

dinos.png
[1920x1080]

drewRobert.png
[1920x1080]

drewRobertDinos.png
[1922x1090]

drewRobertOrig.png
[1928x1090]

drewgreen.png
[510x1006]

duke_blue_devil.png
[397x337]

palm-and-beach.png
[960x640]

rodger.png
[315x424]

smallhands.png
[320x226]

smallpanda.png
[270x201]

astrachan.jpg
[240x360]

duvall.jpg
[200x300]

eastereggs.jpg
[615x410]

hilton.jpg
[140x210]

hippieflower.jpg
[5616x3744]

lion.jpg
[1280x960]

nyc-skyline.jpg
[1280x853]

pixabayhands.jpg
[1280x905]

skyline.jpg
[300x300]

smalllion.jpg
[250x188]

smalluniverse.jpg
[256x200]

universe.jpg
[1280x1000]

usain.jpg
[300x300]

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.