cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              body {padding: 0; margin: 0;}
canvas {vertical-align: top;cursor: none;}
            
          
!
            
              // Daniel Shiffman
// Code for: https://youtu.be/XATr_jdh-44

var circles = [];
var circleColor = "#0058ff";

function Circle() {
	this.x = random(width);
	this.y = random(height);
	this.r = random(width/20, height/40);
	this.color = {
		// r: random(0, 255),
		h: 250,
		// g: random(0, 255),
		s: random(70, 100),
		// b: random(0, 255),
		l: random(10, 60),
		a: 1
	};
	this.delay = Math.round(this.r * 1/50);
	this.update = function() {
		if (!this.delay) {
			var deslocX = width/2 - this.x;
			// deslocX > 0 ? 
				// this.x += Math.pow(this.x, 1/deslocX/100) :
				this.x += deslocX/25;
			var deslocY = height/2 - this.y;
			// deslocY > 0 ? 
				// this.y += deslocY/100 :
				this.y += deslocY/25;
			// this.x > width/2 ? this.x -= Math.pow(this.x, 0.1) : this.x += Math.pow(this.x, 0.1);
			// this.y > height/2 ? this.y -= Math.pow(this.y, 0.1) : this.y += Math.pow(this.y, 0.1);
			this.r -= Math.pow(this.r, 0.1);
		} else
			this.delay--;
	};
}

function setup() {
	createCanvas(window.innerWidth, window.innerHeight);
}

function draw() {
	fill(2, 0, 31, 100);
	rect(0, 0, width, height);

	// Pick a random circle
	var circle = new Circle();

	// Does it overlap any previous circles?
	var overlapping = false;
	for (var j = 0; j < circles.length; j++) {
		var other = circles[j];
		var dC = dist(circle.x, circle.y, other.x, other.y);
		if (dC < circle.r + other.r + 5) {
			overlapping = true;
			break;
		}
	}

	// If not keep it!
	if (!overlapping)
		circles.push(circle);

	// Draw all the circles
	for (var i = 0; i < circles.length; i++) {
		circles[i].update();
		if (Math.round(circles[i].r) <= 0)
			circles.splice(i, 1);
		'hsla(160, 100%, 50%, 0.5)'
		fill("hsla("+circles[i].color.h+", "+circles[i].color.s+"%, "+circles[i].color.l+"%, "+circles[i].color.a+")");
		noStroke();
		ellipse(circles[i].x, circles[i].y, circles[i].r * 2, circles[i].r * 2);
	}
}

window.addEventListener("resize", setup);
            
          
!
999px
Loading ..................

Console