svg-path-contours

WebJar for svg-path-contours

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

svg-path-contours
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

svg-path-contours
WebJar for svg-path-contours
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/mattdesl/svg-path-contours

Download svg-path-contours

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/svg-path-contours/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>svg-path-contours</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/svg-path-contours/
implementation 'org.webjars.npm:svg-path-contours:2.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/svg-path-contours/
implementation ("org.webjars.npm:svg-path-contours:2.0.0")
'org.webjars.npm:svg-path-contours:jar:2.0.0'
<dependency org="org.webjars.npm" name="svg-path-contours" rev="2.0.0">
  <artifact name="svg-path-contours" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='svg-path-contours', version='2.0.0')
)
libraryDependencies += "org.webjars.npm" % "svg-path-contours" % "2.0.0"
[org.webjars.npm/svg-path-contours "2.0.0"]

Dependencies

compile (4)

Group / Artifact Type Version
org.webjars.npm : abs-svg-path jar [0.1.1,0.2)
org.webjars.npm : adaptive-bezier-curve jar [1.0.3,2)
org.webjars.npm : normalize-svg-path jar [0.1.0,0.2)
org.webjars.npm : vec2-copy jar [1.0.0,2)

Project Modules

There are no modules declared in this project.

svg-path-contours

stable

Approximates an SVG path into a discrete list of 2D contours (polylines). This is useful for collision detection, intersection, triangulation & WebGL rendering, etc. It does not attempt to clean or optimize the discretized points.

img

Usage:

var parse = require('parse-svg-path')
var contours = require('svg-path-contours')

var path = 'm10,10C45.812,24.024,45.673,24,45.529,24H31.625
   c0.482-3.325,6.464-2.758,8.913-3.155z'

var result = contours(parse(path))

/* 
[ 
 [ [10,10], ...etc ]
 [ [x, y], ... ]
]
*/

Triangulation example:

var parse = require('parse-svg-path')
var simplify = require('simplify-path')
var contours = require('svg-path-contours')
var triangulate = require('triangulate-contours')

//get a list of polylines/contours from svg contents
var lines = contours(parse(path))

//simplify the contours before triangulation
lines = lines.map(function(path) {
    return simplify(path, threshold)
})

//turns into triangles, returns { positions, cells }
var shape = triangulate(lines)

//now draw the simplicial complex with Canvas/WebGL/etc

See demo/index.js for exmaple.

Usage

NPM

contours(svg)

Takes parsed SVG contents from parse-svg-path and produces a list of 2D polylines representing the contours of the shape.

License

MIT, see LICENSE.md for details.

Versions

Version
2.0.0