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

              
                script.
	window.canvasOptions = {
		autoClear: true,
		autoCompensate: false,
		autoPushPop: true,
		canvas: true,
		//- centered: true,
		desynchronized: false,
		width: null,
		height: null
	};
	/* requestAnimationFrame */

script.
	const pathData_num2 = 'M52.100,27.591 L52.100,51.190 C52.100,52.390 51.700,53.190 50.300,53.790 C48.500,54.590 32.700,61.190 17.301,67.790 C7.101,72.190 0.701,75.190 0.701,86.590 L0.701,133.589 L80.300,133.589 L80.300,108.390 L28.300,108.390 L28.300,93.190 C28.300,91.990 29.100,91.190 29.900,90.790 C32.300,89.590 46.500,83.390 67.900,73.590 C75.900,69.990 79.700,65.390 79.700,56.990 L79.700,21.191 C79.700,9.791 70.300,0.391 58.900,0.391 L21.501,0.391 C10.101,0.391 0.701,9.791 0.701,21.191 L0.701,36.191 L28.101,41.191 L28.101,27.591 C28.101,26.391 28.900,25.591 30.100,25.591 L50.100,25.591 C51.300,25.591 52.100,26.391 52.100,27.591 Z';
	const pathData_num0 = 'M83.100,21.191 C83.100,9.791 73.700,0.391 62.300,0.391 L21.701,0.391 C10.301,0.391 0.901,9.791 0.901,21.191 L0.901,112.789 C0.901,124.189 10.301,133.589 21.701,133.589 L62.300,133.589 C73.700,133.589 83.100,124.189 83.100,112.789 L83.100,21.191 ZM55.500,27.591 L55.500,106.390 C55.500,107.590 54.700,108.390 53.500,108.390 L30.500,108.390 C29.300,108.390 28.500,107.590 28.500,106.390 L28.500,27.591 C28.500,26.391 29.300,25.591 30.500,25.591 L53.500,25.591 C54.700,25.591 55.500,26.391 55.500,27.591 Z';
              
            
!

CSS

              
                body {
	background-color: hsl(0, 0%, 2%);
	cursor: pointer;
}
              
            
!

JS

              
                const gravity = new Vector(0, 0.03);
const particles = [];

const path_num2 = new Path2D(pathData_num2);
const path_num0 = new Path2D(pathData_num0);

function setup() {
	for(let i = 0; i < 25; i++) {
		setTimeout(() => {
			const f = new Firework();
			particles.push(f);
		}, i * 25);
	}
}

function draw(e) {
	// background(hsl(0, 0, 8, 0.2));
	if(particles.length < 25) {
		const f = new Firework();
		particles.push(f);
	}
	ctx.shadowOffsetX = 0;
	ctx.shadowOffsetY = 0;
	lineCap('round');
	push();
	// const time = e * 0.001;
	for(let i = particles.length - 1; i >= 0; i--) {
		const p = particles[i];
		if(p instanceof Particle) {
			if(e > p.created + p.life) {
				particles.splice(i, 1);
				continue;
			}
			p.posPrev.set(p.pos);
			p.pos.add(p.vel.add(gravity).mult(0.999));
			if(mouseDown) {
				p.vel.add(mousePos._.sub(p.pos).limit(1));
			}
			const _r = ease.expo.out(map(e, p.created, p.created + p.life, 1, 0));
			const r = p.r * _r;
			const color = hsl(p.color, 90, 55);
			ctx.shadowBlur = 15 * _r;
			ctx.shadowColor = color;
			beginPath();
			line(p.posPrev._.sub(p.pos).mult(5 * _r).add(p.pos), p.pos);
			stroke(color, r * 2);
		}
		else if(p instanceof Firework) {
			if(e > p.created + p.life) {
				particles.splice(i, 1);
				for(let i = 0; i < p.particleCount; i++) {
					const t = i / p.particleCount;
					const p2 = new Particle();
					p2.color = p.color + random(-20, 20);
					p2.pos.set(p.pos);
					const mag = p2.vel.mag();
					p2.vel.set(Vector.fa(t * TAU, mag));
					particles.push(p2);
				}
				continue;
			}
			p.pos.add(p.vel.add(gravity).mult(0.999));
			const r = 4 * map(e, p.created, p.created + p.life, 1, 0);
			ctx.shadowBlur = 0;
			beginPath();
			circle(p.pos, r);
			fill(hsl(p.color, 80, 40));
		}
	}
	pop();
	
	translate(width_half - 175, height_half - 72);
	
	compositeOperation(compOper.xor);
	
	lineWidth(8);
	ctx.shadowBlur = 0;
	ctx.shadowOffsetX = 2;
	ctx.shadowOffsetY = 5;
	ctx.shadowColor = hsl(e * 0.15, 80, 60);
	// filter('blur(4px)');
	strokeStyle(hsl(0, 0, 100));
	stroke(path_num2);
	translate(89, 0);
	stroke(path_num0);
	translate(92, 0);
	stroke(path_num2);
	translate(89, 0);
	stroke(path_num2);
}

class Particle {
	pos = new Vector();
	posPrev = new Vector();
	vel = Vector.fa(random(TAU), random(0.5, 3));
	r = random(1, 7);
	color = random(360);
	created = performance.now();
	life = random(1, 3) * 1000;
}

class Firework {
	pos = new Vector(random(width), height);
	vel = Vector.fa(random(-1, 1) * EIGHTH_PI + PI * 1.5, random(4, 9));
	color = random(360);
	created = performance.now();
	life = random(0.5, 2.25) * 1000;
	particleCount = random(7, 12);
}
              
            
!
999px

Console