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
	h1 rows_of_them

              
            
!

CSS

              
                body
	background: #000

h1
	bottom: -1.5em
	color: #333
	margin: 0
	position: absolute
	right: 0
	font: 400 24px monospace

.container
	border: 2px solid #fff
	border-radius: 8px
	left: 50%
	max-height: calc(90vh - 120px)
	max-width: calc(90vh - 120px)
	padding: 24px
	position: absolute
	top: 50%
	transform: translate(-50%, -50%)

canvas
	width: 100%
	height: 100%
              
            
!

JS

              
                // Play with these!
const SIZE = 660;
const DEPTH = 6;
const SPARSITY = 4;
const SPEED = 1 / 40;

const container = document.querySelector('.container');
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');

// First, generate some patterns to fill our lines with.
canvas.width = DEPTH;
const patterns = Array.from({length: DEPTH}, (_, layer) => {
	const size = canvas.height = canvas.width = (layer + 2) * 2;
	ctx.fillStyle = '#000';
	ctx.fillRect(0, 0, size, size);
	ctx.fillStyle = '#fff';
	ctx.arc(1, 1, 2, 0, Math.PI);
	ctx.fill();
	
	return ctx.createPattern(canvas, 'repeat');
});

function step(t) {
	ctx.clearRect(0, 0, SIZE, SIZE);
	
	for (let layer = DEPTH - 1; layer >= 0; layer--) {
		let width = SIZE / 14 * (1 - layer / DEPTH);
		let numLines = Math.ceil(SIZE / width / SPARSITY) + 1;
		let loopWidth = numLines * SPARSITY * width;
		let lightness = Math.floor(255 * (1 - layer / (DEPTH + 1)));
		ctx.fillStyle = patterns[layer];
		
		for (let col = 0; col < numLines; col++) {
			let x = mod(col * SPARSITY * width - t * (layer + 1) * SPEED, loopWidth);
			ctx.fillStyle = patterns[layer];
			ctx.fillRect(x - width, 0, width, SIZE - 3);

			// Make sure the last row is always filled so that the 
			// colums appear full-height.
			ctx.save();
			ctx.translate(0, SIZE - 3);
			ctx.fillRect(x - width, 0, width, 3);
			ctx.restore();
		}
	}
	
	requestAnimationFrame(step);
}

// Append our canvas to the DOM.
document.body.style.margin = 0;
canvas.height = canvas.width = SIZE;
container.style.height = container.style.width = `${SIZE / 2}px`;
container.appendChild(canvas);

step(0);

// Proper modulo :-)
function mod(a, b) {
    return ((a % b) + b) % b;
}

              
            
!
999px

Console