var gB, fullRes, windowRes;
var requiredFrames = 360;
var xPos, yPos, numberOfPoints;
windowRes = min(windowWidth, windowHeight);
createCanvas(windowRes, windowRes);
gB = createGraphics(fullRes = 32, fullRes);
numberOfPoints = 1 + floor(random(32));
var startHue = 360 * random();
for (var i = 0; i < numberOfPoints; i += 1) {
xPos: random(fullRes * -0.5, fullRes * 0.5),
yPos: random(fullRes * -0.5, fullRes * 0.5),
xSpeed: 0.5 * random(-1, 1),
ySpeed: 0.5 * random(-1, 1),
hue: (startHue + 60 * random() * random()) % 360
function randPow(multiplier, min, max, power) {
for (var i = 0; i < power; i += 1) {
multiplier *= random(min, max);
gB.translate(fullRes * 0.5, fullRes * 0.5);
for (var i = 0; i < numberOfPoints; i += 1) {
var thisPoint = points[i];
gB.stroke(thisPoint.hue, 230, 360);
gB.point(thisPoint.xPos, thisPoint.yPos);
gB.point(thisPoint.xPos, -thisPoint.yPos);
gB.point(-thisPoint.xPos, thisPoint.yPos);
gB.point(-thisPoint.xPos, -thisPoint.yPos);
if (thisPoint.xPos > fullRes * 0.5 || thisPoint.xPos < fullRes * -0.5) {
thisPoint.xSpeed = -thisPoint.xSpeed;
if (thisPoint.yPos > fullRes * 0.5 || thisPoint.yPos < fullRes * -0.5) {
thisPoint.ySpeed = -thisPoint.ySpeed;
thisPoint.xPos += thisPoint.xSpeed;
thisPoint.yPos += thisPoint.ySpeed;
thisPoint.ySpeed += -0.05;
function mouseClicked() {
saveGif('export', requiredFrames, {
function displayBuffer(buffer) {
image(buffer, windowRes / 2, windowRes / 2, windowRes, windowRes);
function windowResized() {
windowRes = min(windowWidth, windowHeight);
resizeCanvas(windowRes, windowRes);