Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm 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. We'll also process your JavaScript with Babel.

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

Code Indentation


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.

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.

              <p><em><a href="">Original demo</a> and basically all JS by <a href="">Tab Atkins</a></em></p>

<code>linear-gradient(90deg, blue, 66.6%, white)</code> vs. simulated <code>linear-gradient(90deg, blue, ease-in, white)</code>
<div id="d01"></div>
<canvas id="c01" width=200 height=200></canvas>

<code>linear-gradient(90deg, blue, 23%, #AFAFFF 50%, 68%, white 93%)</code> vs. simulated <code>linear-gradient(90deg, blue, ease-out, white)</code>
<div id="d02"></div>
<canvas id="c02" width=200 height=200></canvas>

<code>linear-gradient(90deg, blue, 5.5%, #AFAFFF 22%, #E4E4FF 48%, 66%, white 88%)</code> vs. simulated <code>linear-gradient(90deg, blue, ease, white)</code> 
<div id="d03"></div>
<canvas id="c03" width=200 height=200></canvas>


<code>linear-gradient(90deg, blue, 33.3%, white)</code> vs. <code>linear-gradient(90deg, blue, ease-out, white)</code>
<div id="d04"></div>
<canvas id="c04" width=200 height=200></canvas>

              article, div, canvas {
  display: block;
  width: 1000px;
  height: 50px;
  margin: 0;
article {
  height: auto;
  padding: 10px 1px 1px;
  margin-bottom: 1em;
    linear-gradient(90deg, #0008 1px, 1px, transparent) top left / 10% 100% repeat-x,
    linear-gradient(90deg, #0003 1px, 1px, transparent) top left / 1% 100% repeat-x,
p {
  margin-bottom: 0.25em;
code {
  color: maroon;
  background: #FED;

/* ------------------------------ 
  easing comparisons start here
------------------------------ */

#d01 {
  background: linear-gradient(90deg, blue, 66.6%, white);

#d02 {
  background: linear-gradient(90deg, blue, 23%, #AFAFFF 50%, 68%, white 93%);

#d03 {
  background: linear-gradient(90deg, blue, 5.5%, #AFAFFF 22%, #E4E4FF 48%, 66%, white 88%);

#d04 {
  background: linear-gradient(90deg, blue, 33.3%, white);

              const ease_in = [[.42, 0], [1, 1]]; // ease-in
const ease_out = [[0, 0], [.58, 1]]; // ease-out
const ease = [[0, .25], [.1, 1]]; // ease

class BezierMap {
  constructor(p1, p2) {
    this.points = [];
    for(var i = 0; i <= 1000; i++ ) {
      this.points.push(bezierPoint(i/1000, p1, p2));
  get(x) {
    if(x < 0 || x > 1) throw "In .get(x), x must be in [0,1]";
    let prevPoint = null;
    let nextPoint = this.points[0];
    for(const p of this.points.slice(1)) {
      [prevPoint, nextPoint] = [nextPoint, p];
      if(p[0] > x) break;
    const prog = (x-prevPoint[0]) / (nextPoint[0]/prevPoint[0]);
    return linearNumber(prog, prevPoint[1], nextPoint[1]);
function bezierPoint(prog, p1, p2) {
  const m1 = linearArray(prog, [0,0], p1);
  const m2 = linearArray(prog, p1, p2);
  const m3 = linearArray(prog, p2, [1,1]);
  const n1 = linearArray(prog, m1, m2);
  const n2 = linearArray(prog, m2, m3);
  return linearArray(prog, n1, n2);
function linearArray(p, a1, a2) {
  if(a1.length != a2.length) throw "In linearArray(x,y), x and y must be same length.";
  return,i)=>linearNumber(p, e, a2[i]));
function linearNumber(p, a, b) {
  const p_ = 1-p;
  return p_*a + p*b;

function drawEasing(canvas, easing) {
  const ctx = canvas.getContext("2d");
  for(var i = 0; i < 200; i++) {
      var prog = i/200;
      var map = new BezierMap(...easing);
      var start = [0, 0, 1];
      var end = [1, 1, 1];
    var colorProg = map.get(prog);
    const color = linearArray(colorProg, start, end);
    ctx.fillStyle = `rgb(${>x*100+"%").join(",")})`;
    ctx.fillRect(i, 0, 1, 200);

drawEasing(document.querySelector("#c01"), ease_in);
drawEasing(document.querySelector("#c02"), ease_out);
drawEasing(document.querySelector("#c03"), ease);
// --
drawEasing(document.querySelector("#c04"), ease_out);
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.