Skip to content

Commit

Permalink
Move example API usage to README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
progers committed Nov 10, 2015
1 parent 2e904ac commit 692d50e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,17 @@ Just add pathseg.js to your server and drop this in your html or svg files:
```
<script src="pathseg.js"></script>
```

## Example API usage
```
var path = document.createElementNS("http://www.w3.org/2000/svg", "path");
var moveToSeg = path.createSVGPathSegMovetoRel(10, 10);
var lineToSeg = path.createSVGPathSegLinetoRel(100, 100);
path.pathSegList.appendItem(moveToSeg);
path.pathSegList.appendItem(lineToSeg);
console.log(path.getAttribute('d')); // m 10 10 l 100 100
moveToSeg.x += 200;
moveToSeg.y += 200;
console.log(path.getAttribute('d')); // m 210 210 l 100 100
```

11 changes: 0 additions & 11 deletions pathseg.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@
// This is a drop-in replacement for the SVGPathSeg and SVGPathSegList APIs that were removed from
// SVG2 (https://lists.w3.org/Archives/Public/www-svg/2015Jun/0044.html), including the latest spec
// changes which were implemented in Firefox 43 and Chrome 46.
//
// Example API usage:
// var path = document.createElementNS("http://www.w3.org/2000/svg", "path");
// var moveToSeg = path.createSVGPathSegMovetoRel(10, 10);
// var lineToSeg = path.createSVGPathSegLinetoRel(100, 100);
// path.pathSegList.appendItem(moveToSeg);
// path.pathSegList.appendItem(lineToSeg);
// console.log(path.getAttribute('d')); // m 10 10 l 100 100
// moveToSeg.x += 200;
// moveToSeg.y += 200;
// console.log(path.getAttribute('d')); // m 210 210 l 100 100

(function() { "use strict";
if (!window.SVGPathSeg) {
Expand Down

0 comments on commit 692d50e

Please sign in to comment.