Computer Science, asked by lakshmit2344, 9 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

Answers

Answered by mgaurav651
2

Answer:

// Correct Answer is

var img = new SimpleImage(500,500);

img.setSize(200,200);

print(img);

for (var pixel of img.values())

{

   var x= pixel.getX();

   var y= pixel.getY();

   if ( x< img.getWidth()/2)

   {

       pixel.setRed(255);

   }

   else

   {

       pixel.setGreen(255);

   }

   if (y>img.getHeight()/2)

   {

       pixel.setBlue(255);

   }

    if (y>img.getHeight()/2)

   {

       pixel.setGreen(0);

   }

   

}

print(img);

Explanation:

here you have to look for Value of RGB.

Similar questions