Pen Settings

HTML

CSS

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.

+ add another resource

JavaScript

Babel includes JSX processing.

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.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                .container

              
            
!

CSS

              
                body
	margin: 0
	background: #000

.container
	font-size: 0
	left: 50%
	position: absolute
	top: 50%
	transform: translate(-50%, -50%)

canvas
	animation: spin 100s linear infinite
	border-radius: 50%
	height: 0
	opacity: 0
	transition: height 0.2s, margin 0.2s, opacity 0.2s, width 0.2s
	width: 0

@keyframes spin
	from
		transform: rotate(0)

	to
		transform: rotate(360deg)

              
            
!

JS

              
                // Probably don't edit these:
const {cos, sin, random, PI} = Math;
const PI2 = PI * 2;
const container = document.querySelector('.container');

// Totally edit these!
const R = 40;
const NUM_LINES = 3000;
const NUM_VARIATIONS = 15;
const OFFSET_INC = 1 / 25;
const BREAK_AFTER = 3;

// Just here to ensure your browser doesn't freeze :)
const CHUNK_SIZE = 600;

let variationsDrawn = 0;
(function draw (offset) {
	const canvas = document.createElement('canvas');
	canvas.width = canvas.height = R * 2;
	container.appendChild(canvas);

	const ctx = canvas.getContext('2d');
	ctx.fillStyle = '#fff';
	ctx.arc(R, R, R, 0, PI2);
	ctx.stroke();
	ctx.fill();

	ctx.strokeStyle = 'rgba(0, 0, 0, 0.1)';
	let linesDrawn = 0;
	(function step () {
		const STEP_SIZE = Math.min(CHUNK_SIZE, NUM_LINES - linesDrawn);
		ctx.beginPath();
		for (let i = 0; i < STEP_SIZE; i++) {
			const A = random() * PI2;
			const B = A + (gRand(6) - 0.5) * PI2 + offset * PI;
			ctx.moveTo((1 + cos(A)) * R, (1 + sin(A)) * R);
			ctx.lineTo((1 + cos(B)) * R, (1 + sin(B)) * R);
		}
		ctx.stroke();

		linesDrawn += STEP_SIZE;
		if (linesDrawn < NUM_LINES) return requestAnimationFrame(step);
		
		++variationsDrawn;
		canvas.style.height = canvas.style.width = `${R * 2}px`;
		canvas.style.margin = '10px';
		canvas.style.opacity = 1;
		if (variationsDrawn === NUM_VARIATIONS) return;
		
		if (!(variationsDrawn % BREAK_AFTER)) {
			container.appendChild(document.createElement('br'));
		}
		draw(offset + OFFSET_INC);
	})();
})(0);

// Naive Gaussian random between [0, 1). Could improve on this.
function gRand(iterations) {
	let total = 0;
	for (let i = 0; i < iterations; i++) {
		total += random();
	}
	return total / iterations;
}

              
            
!
999px

Console