Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


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


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.


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.


		p loading...
		h1 ASCII animator

			| Type something here:&nbsp;
			input[type="text" value="  .oO0Oo."]


			| Speed:&nbsp;
			input[type="range" min="4" max="120" value="20"]



                html, body
	height: 100%

	display: flex
	align-items: center
	justify-content: center
	margin: 0
	font-family: monospace

	display: inline-block
	margin-bottom: 40px
	text-align: center

	display: none

		display: none

		display: block

	display: block
	margin-bottom: 40px

	margin-top: 40px

	position: relative
	display: block
	width: 11em
	height: 11em
	margin: auto
	border: 1em solid white
	font-family: VT323, monospace
	text-align: left
	overflow: hidden
	box-shadow: 0 0 0 1px black

		position: absolute
		left: 0
		bottom: -1em
		visibility: hidden
		width: 100%
		line-height: 1
		margin: 0
		word-wrap: break-word
		white-space: pre-wrap



                const main = () => {
  // Adds ZERO-WIDTH-SPACEs between the characters of a word for nicer wrapping,
  // and replaces spaces with non-breaking ones.
  const spaceify =
    word => ['', ...word.replace(/ /g, '\u00A0').split(''), ''].join('\u200B');

  // DOM.
  const ascii = document.querySelector('.ascii input');
  const p = document.querySelector('.output p');
  const speed = document.querySelector('.speed input');

  // Derive the number of characters that fit on a single line.
  const charsPerLine = (() => {
    const prevHTML = p.innerHTML;
    p.textContent = '.';
    const lineHeight = p.offsetHeight;
    let charsPerLine = 0;
    for (; p.offsetHeight === lineHeight; ++charsPerLine) p.textContent += '.';
    p.innerHTML = prevHTML;
    return charsPerLine;
  })(); = 'calc(100% + 1em)'; = 'visible';

  // State.
  let word = spaceify(ascii.value);
  let period = 40; // ~24fps.
  let timeout = period;
  let tPrev = 0;
  let i = 0;
  // Main animation loop.
  (function print (t = {
    const gap = tPrev && t - tPrev - timeout;

    // Clear some of the old characters if we fall well below `period`.
    if (gap > period / 2) {
      const unspaced = p.textContent.replace(/\u200B/g, '');
      const charsToKeep = 11 * charsPerLine + unspaced.length % charsPerLine;
      p.textContent = spaceify(unspaced.slice(-charsToKeep));
    p.textContent += word;

    // Update state.
    tPrev = t;
    timeout = Math.max(period - gap, 0);
    setTimeout(print, timeout);

  ascii.addEventListener('keyup', e => {
    word = spaceify(ascii.value), p.textContent = '';
  speed.addEventListener('input', e => {
    period = 1000 / speed.value, tPrev = 0;

  google: {families: ['VT323']},
  active: main,