void setup() {
size(600, 600);
colorMode(RGB, 255);
strokeWeight(15);
}
float speed = 0.03;// 运动速度
float bgColor = 200;//背景颜色
float lineU = 150; // x方向幅度
float lineV = 50; // y方向幅度
float lineHead = 0, lineLength = 0;
float pointColor, x, y;
void draw() {
background(bgColor);
pointColor = bgColor;
lineHead = lineHead + speed;
lineLength = lineHead;
while (pointColor >= 0) {
lineLength += 0.03; // 控制线长度
pointColor -= 1;
stroke(pointColor);
x = lineU * sin(lineLength) + width / 2;
y = lineV * sin(2 * lineLength) + height / 2;
point(x, y);
}
}