cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

              <div class="coordinate-pane">
  <div class="coordinate-pane__inner">
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 218 218">
      <line x1="20" y1="144" x2="198" y2="72" stroke="#9E9E9E"/>
        <circle cx="20" cy="144" r="10" fill="#8A81AE"/>
        <text x="20" y="144" font-size="8" stroke-width="1" text-anchor="middle" dy="2.5em">A</text>
        <circle cx="198" cy="72" r="10" fill="#8A81AE"/>
        <text x="198" y="72" font-size="8" stroke-width="1" text-anchor="middle" dy="2.5em">B</text>
        <circle cx="20" cy="144" r="4" fill="#000"/>
        <text x="20" y="144" font-size="6" stroke-width="1" text-anchor="middle" dy="2em">P</text>

<button class="interpolate-btn">Interpolating</button>
body {
  padding: 0;
  margin: 0;

.coordinate-pane {
  width: 218px;
  height: 218px;
  margin-top: 10px;
  margin-left: 10px;
  border: 1px solid #ebebeb;

  &__inner {
    position: relative;
    width: 100%;
    height: 100%;

button {
  margin-left: 10px;

              const controlPointA = document.getElementsByTagName('circle')[0];
const controlPointB = document.getElementsByTagName('circle')[1];
const midpoint = document.getElementsByTagName('circle')[2];
const midpointText = document.getElementsByTagName('text')[2];
const interpolateBtn = document.getElementsByClassName('interpolate-btn')[0];
const Ax = parseInt(controlPointA.getAttribute('cx'), 10);
const Ay = parseInt(controlPointA.getAttribute('cy'), 10);
const Bx = parseInt(controlPointB.getAttribute('cx'), 10);
const By = parseInt(controlPointB.getAttribute('cy'), 10);

function blender(A, B, t) {
    if (t === 0) {
        return A;

    if (t === 1) {
        return B;

    return ((1 - t) * A) + (t * B); // or A + t * (B - A)

function interpolator(Ax, Bx, Ay, By, duration) {
  return function(update) {
    const blendX = blender.bind(null, Ax, Bx);
    const blendY = blender.bind(null, Ay, By);
    let startTime = 0;
    function step(timestamp) {
      if (!startTime) {
        startTime = timestamp;

      const pastTime = timestamp - startTime;
      let progress = pastTime / duration;
      if (progress > 1) {
        update(blendX(1), blendY(1));

      update(blendX(progress), blendY(progress));


const interpolate = interpolator(Ax, Bx, Ay, By, 1000);

interpolateBtn.addEventListener('click', function() {
  interpolate(function(x, y) {
    // do interpolating.
    midpoint.setAttribute('cx', x);
    midpoint.setAttribute('cy', y);
    midpointText.setAttribute('x', x);
    midpointText.setAttribute('y', y);


Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.


Loading ..................