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.

            
              <p>Grab the points & drag</p>
<svg width="450" height="450" viewBox="0 0 450 450">
<defs>
<path id="path" d="M70,180Q100,330 195,225Q290,120 380,250"  fill="transparent" stroke-width="1"></path>
</defs>
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#path"></use>

   <text stroke="#000000" font-size="20">
      <textPath xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#path" startOffset="7%">
            just some words I wrote
      </textPath>
    </text>
  
<circle cx ="70"  cy ="180" r ="6" class="M" /> 
<circle cx ="100" cy ="330" r ="6" class="Q" />
<circle cx ="195" cy ="225" r ="6" class=" "/>  
<circle cx ="290" cy ="120" r ="6" class="Q" />
<circle cx ="380" cy ="250" r ="6" class=" "/>  
<line x1="100" y1="330" x2="290" y2="120" /> 
</svg>
            
          
!
            
              body{
  background: black;
  font-family: Verdana, Geneva, sans-serif;
}

p {
  text-align: center;
  color: #777
}

svg {
  border: 1px solid #333;
  display: block;
  margin: 0 auto;
}

path,
line {
  stroke: dodgerblue;
  stroke-width: 2;
}

circle {
  fill: dodgerblue;
  cursor:move;
}

svg text {
  font-size: 30px;
  fill: dodgerblue;
  stroke:black;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}
            
          
!
            
              var svg = document.querySelector("svg");
var path = document.querySelector("#path");
var line = document.querySelector("line");
var circles = document.querySelectorAll("circle");
var cry = [];
for (var i = 0; i < circles.length; i++) {
  var o = {}
  o.x = Number(circles[i].getAttribute('cx'));
  o.y = Number(circles[i].getAttribute('cy'));
  o.class = circles[i].getAttribute('class');
  o.history = {
    x: o.x,
    y: o.y
  };
  cry.push(o);
}
var dragging = false;
var index;
var m = {
  x: 0,
  y: 0
}
svg.addEventListener("mousedown", function(evt) {
  if (evt.target.tagName == "circle") {
    dragging = evt.target;
  }
}, false);

svg.addEventListener("mouseleave", function(evt) {
    dragging = false;
}, false);

svg.addEventListener("mousemove", function(evt) {
  if (dragging) {

    m = oMousePos(svg, evt);
    dragging.setAttributeNS(null, 'cx', m.x);
    dragging.setAttributeNS(null, 'cy', m.y);
    var dPath = '';

    for (var i = 0; i < circles.length; i++) {
      cry[i].history.x = cry[i].x;
      cry[i].history.y = cry[i].y;
      cry[i].x = Number(circles[i].getAttribute('cx'));
      cry[i].y = Number(circles[i].getAttribute('cy'));
      if (circles[i] == dragging) {
        index = i;
      }
    }

    if (index == 1) {// first control point
      var dx1 = cry[1].x - cry[2].x;
      var dy1 = cry[1].y - cry[2].y;
      cry[3].x = cry[2].x - dx1;
      cry[3].y = cry[2].y - dy1;

    } else if (index == 2) {// middle point
      var dx2 = m.x - cry[2].history.x;
      console.log(dx2)
      var dy2 = m.y - cry[2].history.y;
      cry[1].x = cry[1].x + dx2;
      cry[1].y = cry[1].y + dy2;
      cry[3].x = cry[3].x + dx2;
      cry[3].y = cry[3].y + dy2;
      
    } else if (index == 3) {// second control point
      var dx3 = cry[3].x - cry[2].x;
      var dy3 = cry[3].y - cry[2].y;
      cry[1].x = cry[2].x - dx3;
      cry[1].y = cry[2].y - dy3;
    }

    for (var i = 0; i < circles.length; i++) {
      dPath += cry[i].class + cry[i].x + ',' + cry[i].y;
      circles[i].setAttributeNS(null, 'cx', cry[i].x);
      circles[i].setAttributeNS(null, 'cy', cry[i].y);
    }
    
    path.setAttributeNS(null, 'd', dPath);
    line.setAttributeNS(null, 'x1', cry[1].x);
    line.setAttributeNS(null, 'y1', cry[1].y);
    line.setAttributeNS(null, 'x2', cry[3].x);
    line.setAttributeNS(null, 'y2', cry[3].y);
  }
}, false);

svg.addEventListener("mouseup", function(evt) {
  dragging = false;
}, false);

function oMousePos(elmt, evt) {
  var ClientRect = elmt.getBoundingClientRect();
  return { //objeto
    x: Math.round(evt.clientX - ClientRect.left),
    y: Math.round(evt.clientY - ClientRect.top)
  }
}
            
          
!
999px
Loading ..................

Console