我的代码在处理中有问题



我用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);
}
}
}
}

在CodePen上,您将使用JavaScript风格的处理(可能是p5.js)。桌面编辑器默认为Java。

你的代码看起来像是两者的混合。

如果你想继续使用JavaScript,你可以在桌面编辑器中添加p5.js模式。否则,您将需要完成将语法的其余部分转换为Java。

最新更新