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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import or require. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div class="canvas-wrapper">
  <canvas id="canvas" width="500" height="300"></canvas>
</div>
<main id="main">
  <h1>Pretty Delaunay Triangles</h1>

  <form id="form">
    <h2 class="headline-toggle">Configuration</h2>
    <input type="checkbox" class="headline-toggle check-toggle" id="hide-config" checked/><label for="hide-config"></label>

    <fieldset id="generate-buttons">
      <legend><h3>Generate</h3></legend>
      <div class="form-row">
        <button id="generate" data-generate-colors data-generate-gradients data-generate-triangles>Redo all</button>
      </div>
      <div class="form-row">
        <button id="generate-colors" data-generate-colors>Redo Colors</button>
        <button id="generate-gradients" data-generate-gradients>Redo Gradients</button>
        <button id="generate-triangles" data-generate-triangles>Redo Triangles</button>
      </div>
    </fieldset>

    <fieldset id="render-options">
      <legend><h3>Render options</h3></legend>

      <div class="form-row">
        <input type="checkbox" name="show-animation" id="show-animation" /><label for="show-animation">Animation</label>
        <input type="checkbox" name="show-hover" id="show-hover" checked /><label for="show-hover">Hover Effect</label>
      </div>

      <div class="form-row">
        <input type="checkbox" name="show-triangles" id="show-triangles" checked /><label for="show-triangles">Triangles</label>
        <input type="checkbox" name="show-edges" id="show-edges" checked /><label for="show-edges">Edges</label>
        <input type="checkbox" name="show-points" id="show-points" /><label for="show-points">Points</label>
        <input type="checkbox" name="show-centroids" id="show-centroids" /><label for="show-centroids">Centroids</label>
      </div>

      <div class="form-row">
        <input type="checkbox" name="show-circles" id="show-circles" /><label for="show-circles">Gradient circles</label>
      </div>
    </fieldset>

    <fieldset id="point-options">
      <legend><h3>Point density options</h3></legend>

      <div>
        <input type="radio" name="point-gen" value="multiplier" id="point-gen-option-multiplier" checked />
        <label for="point-gen-option-multiplier" id="point-gen-multiplier-label">Multiplier (based on size of canvas)</label>
      </div>
      <div class="form-row">
        <input type="range" id="points-multiplier" value="0.5" min="0.01" max="1" step="0.01" aria-labelledby="point-gen-multiplier-label" aria-describedby="points-min points-max">
        <label for="points-multiplier">0.1</label>
        <label for="points-multiplier">1.0</label>
      </div>

      <div>
        <input type="radio" name="point-gen" value="exactly" id="point-gen-option-exact" />
        <label for="point-gen-option-exact">Exact range:</label>

        <fieldset>
          <legend><h4>Point density ranges</h4></legend>
          <div class="form-row">
            <label for="min-points">Points</label>
            <input id="min-points" type="number" min="1" max="10000" value=""/>
            <label for="max-points">to</label>
            <input id="max-points" type="number" min="1" max="10000" value=""/>
          </div>

          <div class="form-row">
            <label for="min-edge-points">Edge Points</label>
            <input id="min-edge-points" type="number" min="1" max="10000" value=""/>
            <label for="max-edge-points">to</label>
            <input id="max-edge-points" type="number" min="1" max="10000" value=""/>
          </div>
        </fieldset>
      </div>
    </fieldset>

    <fieldset id="background-options">
      <legend><h3>Background options</h3></legend>

      <div class="form-row">
        <label for="min-gradients">Gradients</label>
        <input id="min-gradients" type="number" min="1" max="100" value="1"/>
        <label for="max-gradients">to</label>
        <input id="max-gradients" type="number" min="1" max="100" value="10"/>
      </div>

      <div class="form-row">
        <input type="radio" name="background" value="random" id="color-random-option" checked />
        <label for="color-random-option">Random colors</label>
        <input type="radio" name="background" id="color-choose-option" />
        <label for="color-choose-option">Choose colors:</label>
      </div>
      <fieldset id="color-inputs">
        <legend>Custom colors:</legend>
        <div class="form-row">
          <label for="color-1">Inner color:</label>
          <input type="color" id="color-1" data-color-sync="color-1-hex" value="#FFFFFF">
          <input type="text" id="color-1-hex" data-color-sync="color-1" value="#FFFFFF">
        </div>

        <div class="form-row">
          <label for="color-2">Middle color:</label>
          <input type="color" id="color-2" data-color-sync="color-2-hex" value="#888888">
          <input type="text" id="color-2-hex" data-color-sync="color-2" value="#888888">
        </div>

        <div class="form-row">
          <label for="color-3">Outer color:</label>
          <input type="color" id="color-3" data-color-sync="color-3-hex" value="#000000">
          <input type="text" id="color-3-hex" data-color-sync="color-3" value="#000000">
        </div>
      </fieldset>
      <div>
        <input type="radio" name="background" id="color-image-option" />
        <label for="color-image-option">Image</label>
        <fieldset>
          <div class="form-row">
            <input type="radio" name="image-background" id="image-background-upload-option" checked />
            <label for="image-background-upload-option">Upload:</label>
            <input type="file" id="image-background-upload" accept="image/*">
          </div>
          <div class="form-row">
            <input type="radio" name="image-background" id="image-background-url-option" />
            <label for="image-background-url-option" id="image-background-url-label">URL:</label>
            <input type="url" id="image-background-url" aria-labelledby="image-background-url-label" value="">
          </div>
        </fieldset>
      </div>
    </fieldset>
  </form>
</main>
            
          
!
            
              $row-vertical-spacing: 0.75rem;
$label-horizontal-spacing: 0.5rem;

html {
  height: 100%;
  font-size: 16px;
}

body {
  margin: 0;
  padding: 0;
  position: relative;
  min-height: 100%;

  font-family: sans-serif;
}

main {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  overflow-x: hidden;
  overflow-y: auto;

  margin: 0;
  padding: 1rem;
  text-align: center;

  & > * {
    z-index: 1;
    position: relative;
  }
}

* {
  box-sizing: border-box;

  & + * {
    margin-top: $row-vertical-spacing;
  }
}

hr {
  margin: 1rem 0;
  -webkit-margin-collapse: separate;
}

h1, h2, h3, h4, h5 {
  margin-top: 0;
  margin-bottom: 0.5em;
}
form {
  display: inline-block;
  text-align: left;
}

.canvas-wrapper {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  overflow: hidden;
}

canvas, canvas + canvas {
  margin: 0;
}

.form-row {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;

  > * {
    flex-grow: 1;
    flex-basis: 0;

    margin-top: 0;
    margin-left: $label-horizontal-spacing;

    &:first-child {
      margin-left: 0;
    }
  }

  > input {
    &[type=radio],
    &[type=checkbox] {
      flex-grow: 0;
      flex-basis: auto;
      margin-left: 0;

      ~ input {
        margin-left: 1rem;
      }
    }

    &[type=range] {
      flex-grow: 100;

      ~ label {
        margin-left: $label-horizontal-spacing;
        flex-grow: 1;
        flex-basis: auto;
      }

      + label {
        order: -1;
        margin-left: 0;
        margin-right: $label-horizontal-spacing;
      }
    }

    &[type=number] + label {
      flex-grow: 0;
    }

    &[type=url] {
      flex-grow: 10;
    }

    &[type=color] {
      flex-grow: 1.5;

      + input {
        width: 5em;
        flex-grow: 0;
      }
    }

  }

  legend + & {
    margin-top: 0.5rem;
  }
}

fieldset {
  > *:first-child {
    margin-top: $row-vertical-spacing;
  }
}

input {
  & ~ fieldset {
    opacity: 0.3;
    pointer-events: none;
    margin: 0.5rem 0 1rem;

    .form-row & {
      margin: 0.5rem 0 1rem;
      pointer-events: all;
    }

    *:last-child > &:last-child {
      margin-bottom: 0;
    }
  }

  &:checked ~ fieldset {
    opacity: 1;
    pointer-events: all;
  }

  &[type=radio],
  &[type=checkbox] {
    margin: 0;

    label + & {
      margin-left: 1em;
    }
  }

  &[type=color] {
    height: 2rem;
    padding: 2px;
    border-width: 1px;
  }

  + label {
    margin-left: $label-horizontal-spacing;
  }
}

button {
  padding: 4px 2px 5px 2px;
  font-size: 0.75rem;
}

.a11y {
  position: absolute;
	clip: rect(1px 1px 1px 1px);
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(0px 0px 99.9% 99.9%);
	overflow: hidden;
	height: 1px;
	width: 1px;
	padding: 0;
	border: 0;
}

.theme-light {
  color: white;
}

.theme-dark {
  color: black;
}

.theme-light,
.theme-dark {
  input, button {
    color: black;
  }
}

.check-toggle {
  -webkit-appearance: none;
  height: 0;
  width: 0;
  visibility: hidden;
  overflow: hidden;

  + label:after {
    content: 'Show';
  }

  ~ fieldset {
    visibility: hidden;
    height: 1px;
  }

  &:checked {
    + label:after {
      content: 'Hide';
    }

    ~ fieldset {
      visibility: visible;
      height: auto;
    }
  }
}

.headline-toggle {
  display: inline-block;
}

            
          
!
            
              // see https://github.com/cshaver/pretty-delaunay/blob/master/src/demo.js
            
          
!
999px

Console