float num; void setup(){ size(640,640); noFill(); stroke(255); } void draw(){ fill(0,30); rect(-1,-1,width+1,height+1); translate(width/2,height/2); rotate(radians(num)); for(int i = 0;i<360;i+12) floatx =sin(radians(i+num))*mouseX; floaty =tan(radians(i+num))*mouseY; noFill(); bezier(0,0,0,0,x+y,y+x,x,y); bezier(0,0,0,0,-x+y,-y+x,-x,-y); } num +=0.5; } 哪里出错了
时间: 2023-11-18 17:03:35 浏览: 34
这段代码中有几个问题:
1. 在for循环中,应该将i的步长设为12,而不是i+12。
2. 在for循环中,缺少一对花括号来包含bezier函数的调用。
3. 在bezier函数的调用中,x和y没有被定义,应该将floatx和floaty赋值给它们。
4. 在代码的最后,应该将rotate和translate的状态重置。
以下是修改后的代码:
```
float num;
void setup() {
size(640, 640);
noFill();
stroke(255);
}
void draw() {
fill(0, 30);
rect(-1, -1, width + 1, height + 1);
translate(width / 2, height / 2);
rotate(radians(num));
for (int i = 0; i < 360; i += 12) {
float x = sin(radians(i + num)) * mouseX;
float y = tan(radians(i + num)) * mouseY;
noFill();
bezier(0, 0, 0, 0, x + y, y + x, x, y);
bezier(0, 0, 0, 0, -x + y, -y + x, -x, -y);
}
num += 0.5;
rotate(-radians(num));
translate(-width / 2, -height / 2);
}
```