cssAudio - ActiveCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

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"/>
      <g>
        <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>
      </g>
      <g>
        <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>
      </g>
      <g>
        <circle cx="109" cy="108" r="4" fill="#000"/>
        <text x="109" y="108" font-size="6" stroke-width="1" text-anchor="middle" dy="2em">P</text>
      </g>
    </svg>
  </div>
</div>

<div class="controller">
  <div class="controller__inner">
    <form action="">
      <input class="blend-ipt" type="text" value=".5"/>
      <button class="blend-btn" type="submit">Blending</button>
    </form>
  </div>
</div>

            
          
!
            
              html,
body {
  padding: 0;
  margin: 0;
}

input,
button {
  margin: 0;
}

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

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

.controller {
  margin-left: 5px;
  margin-top: 5px;
  font-size: 0;
  
  &__inner {
    position: relative;
  }
  
  button {
    margin-left: 3px;
  }
}
            
          
!
            
              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 blendIpt = document.getElementsByClassName('blend-ipt')[0];
const form = document.getElementsByTagName('form')[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)
}

const blendX = blender.bind(null, Ax, Bx);
const blendY = blender.bind(null, Ay, By);

form.addEventListener('submit', function(event) {
  event.preventDefault();
  
  const t = parseFloat(blendIpt.value);
  const nx = blendX(t);
  const ny = blendY(t);
  
  if (t > 1 || t < 0) {
    alert('0 이상 1 이하의 값을 입력하세요.');
  }
  
  midpoint.setAttribute('cx', nx);
  midpoint.setAttribute('cy', ny);
  midpointText.setAttribute('x', nx);
  midpointText.setAttribute('y', ny);
});

            
          
!
999px
Close

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.

Go PRO

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

Console