我试图像这张图片一样在Java中绘制矩形:
我像在数学时一样可视化坐标,但我想出了颠倒的矩形,就像这样:
我知道我只缺少一些东西。我该怎么办? (颜色将被编辑)
public class BlockTower
{
public static void main(String[] args)
{
Rectangle rect1 = new Rectangle(20, 70, 40, 30);
rect1.draw();
rect1.setColor(Color.BLUE);
rect1.fill();
Rectangle rect2 = new Rectangle(60, 70, 40, 30);
rect2.draw();
rect2.setColor(Color.MAGENTA);
rect2.fill();
Rectangle rect3 = new Rectangle(100, 70, 40, 30);
rect3.draw();
rect3.setColor(Color.CYAN);
rect3.fill();
Rectangle rect4 = new Rectangle(40, 100, 40, 30);
rect4.draw();
rect4.setColor(Color.RED);
rect4.fill();
Rectangle rect5 = new Rectangle(80, 100, 40, 30);
rect5.draw();
rect5.setColor(Color.PINK);
rect5.fill();
Rectangle rect6 = new Rectangle(60, 130, 40, 30);
rect6.draw();
rect6.setColor(Color.BLUE);
rect6.fill();
//TODO finish the draft to display the six blocks
}
}