我用codepen写了我的代码,然后我把它处理了,现在有很多错误。在 codepen 中没问题,但在处理过程中发生了一些事情。这是我第一次使用处理,所以语言参考有点不同。有人可以让我朝着正确的方向前进吗?
void draw() {
// Call the variableEllipse() method and send it the
// parameters for the current mouse position
// and the previous mouse position
ellipse(mouseX, mouseY, pmouseX, pmouseY);
}
// The simple method variableEllipse() was created specifically
// for this program. It calculates the speed of the mouse
// and draws a small ellipse if the mouse is moving slowly
// and draws a large ellipse if the mouse is moving quickly
void ellipse(x, y, px, py) {
let speed = abs(x - px) + abs(y - py);
stroke(speed);
ellipse(x, y, speed, speed);
}
//https://p5js.org/examples/drawing-patterns.html
void setup() {
size(500, 500);
background(50);
let num = 20;
let spanx = width / num;
let spany = height / num;
for (let i = 1; i < num; i++) {
for (let j = 1; j < num; j++) {
stroke(255, 255, 255);
if (random(1) < 0.8) {
line(width / 2, height/2, i * spanx, j * spany);
frameRate(35);
}
stroke(255, 0, 0);
if (random(1) < 0.3) {
line(width / 1, height, i * spanx, j * spany);
}
//red line
stroke(0, 0, 255);
if (random(1) < 0.5) {
line(6, height, i * spanx, j * spany);
//line(1, height / 2, i * spanx, j * spany);
}
stroke(0, 128, 0);
strokeWeight(1);
if (random(1) < 0.5) {
line(7, 3, i * spanx, j * spany);
}
stroke(255, 255, 0);
if (random(1) < 0.9) {
line(width, 9, i * spanx, i * spany);
//line(width / 2, height, i * spanx, i * spany);
//line(width, height / 2, i * spanx, i * spany);
//line(width / 2, 1, i * spanx, i * spany);
}
}
}
}