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 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.

Quick-add: + add another resource

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.

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="109" x2="198" y2="109" stroke="#9E9E9E"/>
      <g>
        <circle cx="20" cy="109" r="10" fill="#8A81AE"/>
        <text x="20" y="109" font-size="8" stroke-width="1" text-anchor="middle" dy="2.5em">A</text>
      </g>
      <g>
        <circle cx="198" cy="109" r="10" fill="#8A81AE"/>
        <text x="198" y="109" font-size="8" stroke-width="1" text-anchor="middle" dy="2.5em">B</text>
      </g>
      <g>
        <circle cx="109" cy="109" r="4" fill="#000"/>
        <text x="109" y="109" 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 blendBtn = document.getElementsByClassName('blend-btn')[0];
const A = parseInt(controlPointA.getAttribute('cx'), 10);
const B = parseInt(controlPointB.getAttribute('cx'), 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 blend = blender.bind(null, A, B);

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

            
          
!
999px
Loading ..................

Console