给我一个Java的爱心代码,要求是动画类型炫酷的
时间: 2023-03-12 19:19:53 浏览: 104
public class LoveCode {
public static void main(String[] args) {
// 创建一个宽150,高50的画布
StdDraw.setCanvasSize(150, 50);
// 设定画布背景色
StdDraw.setPenColor(StdDraw.BLACK);
StdDraw.filledSquare(75, 25, 75);
// 绘制爱心
StdDraw.setPenColor(StdDraw.PINK);
double[] x = {36, 40, 44, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 44, 40, 36};
double[] y = {40, 30, 20, 10, 5, 10, 20, 30, 40, 30, 20, 10, 5, 10, 20, 30, 40, 30, 20, 10, 5, 10, 20, 30, 40, 30, 20};
StdDraw.filledPolygon(x, y);
}
}
阅读全文