Computer Science, asked by abratmughal8641, 10 months ago

Your friend is trying to write a program that draws a square 200 pixels by 200 pixels and that looks like this square with colors red (red value 255), green (green value 255), blue (blue value 255) and magenta (red value 255 and blue value 255). All other RGB values are set to 0. by javascript

Answers

Answered by jefferson7
0

Your friend is trying to write a program that draws a square 200 pixels by 200 pixels and that looks like this square with colors red (red value 255), green (green value 255), blue (blue value 255) and magenta (red value 255 and blue value 255). All other RGB values are set to 0. by javascript

Explanation:

var img = new SampleImage(200,200);

for (var px of img.values()){

var a = px.getA();

var b = px.getB();

if (a < img.getWidth()/2){

   px.setRed(255);

}

 if (b>img.getHeight()/2){

   px.setBlue(255);

}

elseif {

   px.setGreen(255);

}

}

print (img);

Similar questions