xxxxxxxxxx
42
class RandomLine {
constructor (){
this.xPos = 0;
this.yPos = random(0,600);
this.xSpeed = 1;
this.ySpeed = random(0, 1);
}
pointdraw (strokeWeightnumber) {
for(let i = 0; i < 10; i++) {
strokeWeight(strokeWeightnumber);
this.yPos += this.ySpeed;
this.xPos += this.xSpeed;
if (this.xPos > width - strokeWeightnumber / 2 || this.xPos < 0) {
this.xSpeed = - this.xSpeed;
}
else if (this.yPos > height - strokeWeightnumber / 2|| this.yPos < strokeWeightnumber / 2) {
this.ySpeed = - this.ySpeed;
}
stroke(random(0,255), random(0,255), random(0,255),);
point(this.xPos, this.yPos);
}
}
}
let myLine;
function setup() {
createCanvas(600, 600);
frameRate(1);
myLine = new RandomLine();
}
function draw() {
background(220);
myLine.pointdraw(25);
}