Text Wave

FEATURED

In this example below you will see how to do a Text Wave with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by Jacob Foster, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright Jacob Foster ©
  • HTML
  • CSS
  • JavaScript
    script.
	window.canvasOptions = {
		autoClear: true,
		autoCompensate: false,
		autoPushPop: true,
		canvas: true,
		centered: true,
		width: null,
		height: null
	};

/*Downloaded from https://www.codeseek.co/Alca/text-wave-Papoxx */
    


/*Downloaded from https://www.codeseek.co/Alca/text-wave-Papoxx */
    function draw(e) {
	textAlign('center');
	textBaseline('middle');
	let time = e * 0.001;
	let count = 30;
	let msg = 'CODEPEN!  ';
	for(let y = 0; y < count * 0.5; y++) {
		for(let x = 0; x < count; x++) {
			let t = x / count * TAU;
			let ty = y / count * TAU;
			let char = msg[floor(time * 16 + x + y) % msg.length];
			let str = ' '.repeat(x) + char + ' '.repeat(count - x - 1);
			let n1 = sin(TAU * cos(t + ty + time));
			let n2 = cos(TAU * sin(t * 0.5 + ty * 0.5 + time * 2));
			let n = ease.quint.in(sin(ty + time) + 1, 0, 1, 2);
			let size = map(lerp(n1, n2, n), -1, 1, 24, 36);
			font(`${size}px monospace`);
			fillStyle(hsl(x * y, 100, 50, map(n, -1, 1, 0.5, 1)));
			fillText(str, 0, y * size - count * 0.25 * size);
		}
	}
}

Comments