前提・実現したいこと
processingで水面のアニメーションを作っています。
発生している問題・エラーメッセージ
エラーメッセージ
該当のソースコード
final int W = 500;
final int H = 500;
final int Speed = 40;
final float A = 32;
float stepNum = 70;
float stepSize = 45;
float noiseScale = 0.005;
float timeScale = 0.1111;
float[][][] u = new float[W][H][3];
void setup(){
size(500, 500, P3D);
//frameRate(1);
for(int i=0; i<W; i++){
for(int j=0; j<H; j++){
for(int k=0; k<3; k++){
//u[i][j][k] = 100*sin(i/float(W)*PI)*sin(j/float(H)*PI);
//u[i][j][k] = (i==W/2 && j==H/2 && k==2)? 255 : 0; u[i][j][k] = 0; } }
}
}
void draw(){
background(225);
noStroke();
fill(25,233,250,100);
rect(0, 0, width, height);
noFill();
stroke(198,198,198,90);
strokeWeight(1);
for(int x = 1; x < stepNum; x++){
float w = x * stepSize;
beginShape();
curveVertex(w, 0);
curveVertex(w, 0);
for(int y = 1; y < stepNum; y++){
float h = y * stepSize;
float nw = map(noise(w * noiseScale, h * noiseScale, frameCount * timeScale), 0, 5, -stepSize, stepSize);
float nh = map(noise(w * noiseScale, h * noiseScale, frameCount * timeScale),0, 5, -stepSize, stepSize);
curveVertex(w + nw, h + nh);
}
curveVertex(w, stepNum * stepSize);
curveVertex(w, stepNum * stepSize);
endShape();
}
for(int y = 1; y < stepNum; y++){
float h = y * stepSize;
beginShape();
curveVertex(0, h);
curveVertex(0, h);
for(int x = 1; x < stepNum; x++){
float w = x * stepSize;
float nw = map(noise(w * noiseScale, h * noiseScale, frameCount * timeScale), 0, 1, -stepSize, stepSize);
float nh = map(noise(w * noiseScale, h * noiseScale, frameCount * timeScale), 0, 1, -stepSize, stepSize);
curveVertex(w + nw, h + nh);
}
curveVertex(stepNum * stepSize, h);
curveVertex(stepNum * stepSize, h);
endShape();
}
for(int i=0; i<W; i++){
for(int j=0; j<H; j++){
stroke(#34E9FF,map(u[i][j][0],-255,255,-55,200) + 55);
point(i,j);
}
}
for(int i=0; i<W; i++){
for(int j=0; j<H; j++){
stroke(#0E76E3,map(u[i][j][0],-255,255,-55,200) + 55);
point(i,j);
}
}
for(int i=0; i<Speed; i++){
calc();
}
}
void calc(){
float B = 1/A;
for(int i=0; i<W; i++){
for(int j=0; j<H; j++){
if(i==W-1 || j==H-1){
u[i][j][0] = 0;
}else if(i==0 || j==0){
u[i][j][0] = 0;
}else{
u[i][j][0] = B * ( -Au[i][j][2] + 2(A-2)*u[i][j][1] + u[i-1][j][1] + u[i+1][j][1] + u[i][j-1][1] + u[i][j+1][1]) * 0.99;
}
}
}
for(int i=0; i<W; i++){
for(int j=0; j<H; j++){
u[i][j][2] = u[i][j][1];
u[i][j][1] = u[i][j][0];
}
}
}
void mousePressed(){
u[constrain(mouseX,0,W-1)][constrain(mouseY,0,H-1)][2] = 255;
}
void mouseDragged(){
u[constrain(mouseX,0,W-1)][constrain(mouseY,0,H-1)][2] = 100;
}
試したこと
色々試しましたがあまり変わりません。わかる方がいらっしゃったらご教授願います。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
あなたの回答
tips
プレビュー