xxxxxxxxxx
72
let waveBalls = [];
var thisWaveBall;
function setup() {
createCanvas(800, 600);
thisWaveBall = new waveballs();
waveBalls.push(thisWaveBall);
}
function draw() {
background(255);
thisWaveBall.setWave();
thisWaveBall.calWave(0.0);
thisWaveBall.renderWave(222, 244, 95, 95, 400);
// class(waveBalls.setWave);
// class(waveBalls.calWave(0.0));
// class(waveBalls.randerWave(222,244,95,95,400));
}
class waveballs {
constructor(wofwave, theta, hofwave, period, dx, yvalues, c1, c2, positionY, rx, ry) {
this.spacingx = 20;
this.wofwave = wofwave;
this.theta = theta;
this.hofwave = 40.0;
this.period = 800.0;
this.dx = dx;
this.yvalues = yvalues;
this.c1 = c1;
this.c2 = c2;
this.positionY = positionY;
this.rx = rx;
this.ry = ry;
}
setWave() {
this.wofwave = width + 20;
this.dx = (TWO_PI / this.period) * this.xspacing;
this.yvalues = new Array(floor(this.wofwave / this.spacingx));
}
calWave(theta) {
// this.theta += 0.02;
// var x = this.theta;
// for (var i = 0; i < yvalues.length; i++) {
// yvalues[i] = sin(x)*hofwave;
//x+=dx; }
}
renderWave(c1, c2, positionY, rx, ry) {
this.theta += 0.02;
//var x = this.theta;
for (var i = 0; i < this.yvalues.length; i++) {
this.yvalues[i] = sin(x) * this.hofwave;
x += this.dx;
noStroke();
print(this.yvalues);
fill(222, 232, 244);
for (var x = this.theta; x < this.yvalues.length; x++) {
ellipse(x * this.xspacing, height / 2 + this.yvalues[x] + this.positionY, this.rx, this.ry);
}
}
}
drawWave() {
calcWave();
renderWave();
}
}