Drawing a red square

Report a typo

Write a function that returns a buffered image of size 500x500. The image should have TYPE_INT_RGB color components, and it should contain a red square starting at position (100, 100), with the side length of 300.

Hint: A square is a rectangle with equal sides.

The return value of the function should be a BufferedImage with the following contents:

Outline of red square on black background

Write a program in Kotlin
import java.awt.Color
import java.awt.image.BufferedImage

fun drawSquare(): BufferedImage {
// Add your code here
}
___

Create a free account to access the full topic