Basic SVG Path Manipulation Library – SVGRoad

Category: Javascript | October 31, 2018
Author: zFunx
Views Total: 463
Official Page: Go to website
Last Update: October 31, 2018
License: MIT

Preview:

Basic SVG Path Manipulation Library – SVGRoad

Description:

SVGRoad is a really small SVG manipulation library which enables you to easily and quickly set the stroke-dasharray and stroke-dashoffset attributes in percentage.

How to use it:

Download and import the SVGRoad library into the document.

<script src="SVGRoad.js"></script>

Initialize the SVGRoad and specify the SVG path element.

var el = document.getElementById("path");
var Instance = new SVGRoad(el);

Set the stroke-dasharray.

Instance.setStrokeDasharrayInPercent(50); 
Instance.setStrokeDasharrayInPercent(50, 10);
Instance.setStrokeDasharrayInPercent(20, 5, 10, 5);
...

Set/get the stroke-dashoffset.

Instance.getStrokeDashoffsetInPercent();
Instance.setStrokeDashoffsetInPercent(50);

Get the SVG length.

Instance.getPathLength();

You Might Be Interested In:


Leave a Reply