SketchBook

soyuart

//サイズ
var rad = 5;

var xpos, ypos;

//速さ
//9,6.6,
//↓の数字をいじれば模様がかわるヨ!
var xspeed = 3;
var yspeed = 2.2;

var xdirection = 1;
var ydirection = 1;

function setup() {
createCanvas(windowWidth,
windowHeight);
noStroke();
ellipseMode(RADIUS);

xpos = width / 2;
ypos = height / 2;
}

function draw() {
//background(234, 234, 234);
fill(255, 20, 150);

xpos = xpos + xspeed * xdirection;
 ypos = ypos + yspeed * ydirection;
yspeed = yspeed + random(-0.1, 0.1)
if (xpos > width - rad || xpos < rad) {
xdirection *= -1;
}

if (ypos > height - rad || ypos < rad) {
ydirection *= -1;
}

 ellipse(xpos, ypos, rad, rad, 100);
}