Change starting coordinate for svg line drawing? -


http://codepen.io/stevendavisphoto/pen/dovolo

<svg xmlns="http://www.w3.org/2000/svg" height="223.5px" width="432.7px" viewbox="-1 -1 433.7 225.5">     <path d="m341.6,95.3c3.4-62.2-66.9-96.3-112.5-62.7c173.7-34.9,70.7,10.7,79.5,94.4c17.8,93.4-26.4,166,18,223.5     l396.4,0c461.3,162.7,410.9,85.8,341.6,95.3"     stroke="#fff"     stroke-width="2"     fill="none"     stroke-dasharray=""     stroke-dashoffset="0.00"></path> </svg> 

the direction of drawing fine, i'd start lower left point, not random point in right middle. can show me how fix it?

the path starts definition says - whatever point artist started from.

the general solution load image vector editor , rearrange path components - or redraw path - starts want.

if path simple enough, , familiar how svg path definitions work, can hand. have done below. otherwise need use vector editor.

var $p = document.queryselector('svg path'),      plength = $p.gettotallength();  // clear previous transition  $p.style.transition = $p.style.webkittransition =    'none';  // set starting positions  $p.style.strokedasharray = plength + ' ' + plength;  $p.style.strokedashoffset = -plength;  // trigger layout styles calculated & browser  // picks starting position before animating  $p.getboundingclientrect();  // define our transition  $p.style.transition = $p.style.webkittransition =    'stroke-dashoffset 2s ease-in-out';  // go!  $('#draw').on('click', function(){    $p.style.strokedashoffset = '0';    settimeout(function(){      $p.style.strokedashoffset = -(plength);    }, 3000);  });
body {background:black;}  svg {    position:absolute;    top:50%;    left:50%;    transform:translate(-50%,-50%);  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <svg xmlns="http://www.w3.org/2000/svg" height="223.5px" width="432.7px" viewbox="-1 -1 433.7 225.5">    <path d="m 18, 223.5             l 396.4,0             c 461.3,162.7,410.9,85.8,341.6,95.3             c 3.4 -62.2 -66.9 -96.3 -112.5 -62.7             c 173.7 -34.9, 70.7, 10.7, 79.5, 94.4             c 17.8, 93.4 -26.4, 166, 18, 223.5" stroke="#fff" stroke-width="2" fill="none" stroke-dasharray="" stroke-dashoffset="0.00"></path>  </svg>    <button id="draw">draw!</button>


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -