我想让整个屏幕被不同颜色的方块填满。我已经成功生成了整个屏幕的方块,但是我无法让它们随机着色。以下是我的代码:
import java.util.Random;
public class RGBRandom
{
public static void main(String[] args)
{
StdDraw.setScale(0, 100);
for (int x = 0; x <= 100; x++)
{
for (int y = 0; y <= 100; y++)
{
int r = (int)Math.random()*256;
int g = (int)Math.random()*256;
int b = (int)Math.random()*256;
StdDraw.setPenColor(r, g, b);
StdDraw.filledSquare(x, y, 0.5);
}
}
}
}