All Projects → danmarshall → svg-path-outline

danmarshall / svg-path-outline

Licence: Apache-2.0 License
Create an outline surrounding an SVG path

Programming Languages

HTML
75241 projects
javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to svg-path-outline

durdraw
Animated Unicode, ANSI and ASCII Art Editor for Linux/Unix/macOS
Stars: ✭ 55 (-1.79%)
Mutual labels:  drawing
Elementa
A simple, declarative GUI library for Minecraft
Stars: ✭ 160 (+185.71%)
Mutual labels:  drawing
gossip
An online user interface to efficiently author and delivery awesome and informative presentation. 🚀
Stars: ✭ 378 (+575%)
Mutual labels:  outline
pixelino
Pixel-drawing app for iOS ✍️
Stars: ✭ 45 (-19.64%)
Mutual labels:  drawing
HoroscopeDrawer
JavaScript-Library to draw celestial charts in SVG-Format.
Stars: ✭ 51 (-8.93%)
Mutual labels:  drawing
mvt
Draw Mapbox Vector Tiles (MVT) in Go
Stars: ✭ 46 (-17.86%)
Mutual labels:  drawing
sdfx
C# bindings for https://github.com/andlabs/libui targeting .NET Standard.
Stars: ✭ 31 (-44.64%)
Mutual labels:  drawing
drawsvg-editor
Full SVG Editor to be installed as desktop app
Stars: ✭ 19 (-66.07%)
Mutual labels:  drawing
Dynamic-Draw
This is a plugin for Paint.NET that extends it with dynamic brush capabilities. Images can be used as brushes to draw with options to adjust and jitter the brush in different ways.
Stars: ✭ 15 (-73.21%)
Mutual labels:  drawing
MagPiDownloader
Downloads all the Mag Pi (Raspberry Pi Magazine) on your Windows, Mac OS or Linux or with Docker
Stars: ✭ 70 (+25%)
Mutual labels:  maker
convertPath
A node lib to convert svg shape elements into path svg elements.
Stars: ✭ 94 (+67.86%)
Mutual labels:  svg-path
ocaml-cairo
Binding to Cairo, a 2D Vector Graphics Library.
Stars: ✭ 39 (-30.36%)
Mutual labels:  drawing
Anondraw
Source code of anondraw.com. An artistic collaboration tool with an infinite canvas.
Stars: ✭ 43 (-23.21%)
Mutual labels:  drawing
SwiftUI-Shapes
Commonly Used Shapes and Utilities In SwiftUI
Stars: ✭ 52 (-7.14%)
Mutual labels:  drawing
custom-hotword-for-aiy-voicekit
Snowboy API for AIY Voice Kit
Stars: ✭ 26 (-53.57%)
Mutual labels:  maker
themes
Need to find a new theme for your DBM Client? Check here!
Stars: ✭ 16 (-71.43%)
Mutual labels:  maker
at-the-wall
A Game of Thrones scene coded in pure SCSS and HTML
Stars: ✭ 12 (-78.57%)
Mutual labels:  drawing
vue-draw
Drawing Component for VueJS
Stars: ✭ 26 (-53.57%)
Mutual labels:  drawing
isometric
A lightweight JavaScript library, written in TypeScript to create isometric projections using SVGs
Stars: ✭ 53 (-5.36%)
Mutual labels:  drawing
MROGeometry
♊️ Mirror of http://purl.mro.name/ios/MROGeometry | √ C and Objective C math and geometry helpers
Stars: ✭ 58 (+3.57%)
Mutual labels:  svg-path

svg-path-outline

Create an outline surrounding an SVG path

Image of example outlines

A stroke is typically used to outline an SVG element. Use this package if you need an actual SVG path instead. When corners are outlined, you have the option of specifying the style of joint: round, square, or beveled.

Live demo: https://danmarshall.github.io/svg-path-outline/browser

Installation

Node

npm install svg-path-outline --save

Browser

<script src="https://pomax.github.io/bezierjs/bezier.js" type="text/javascript"></script>
<script src="https://microsoft.github.io/maker.js/target/js/browser.maker.js" type="text/javascript"></script>
<script src="https://danmarshall.github.io/svg-path-outline/browser/index.js" type="text/javascript"></script>

Usage

var spo = require('svg-path-outline');

var outline = spo(svgData, distance, options);

Parameters

svgData

Input is a string of either SVG path data, or point coordinates from SVG polyline or polygon.

distance

Numeric distance to offset the outline.

options

Object with these optional properties:

option type default description
joints number 0 0 - round joints
1 - miter
2 - bevel
bezierAccuracy number 0.5 Distance of accuracy for Bezier curves. A lower number is more accurate but requires more computation. Using zero is not recommended as it may never finish computing. This number is relative to the unit system of your SVG; so if you are rendering pixels, then 0.5 is accurate to half a pixel.
inside boolean false Add offset lines on the inside of the shape
outside boolean true Add offset lines on the outside of the shape
tagName string 'path' SVG tag name of the type of data:
'path' - SVG path language
'polygon' - point coordinates, closed shape
'polyline' - point coordinates, open shape

return value

Output is a string of SVG path data.

Examples

Simple example in JavaScript:

var spo = require('svg-path-outline');
var svgData = "M 95 35 L 59 35 L 48 0 L 36 35 L 0 35 L 29 56 L 18 90 L 48 69 L 77 90 L 66 56 Z";
var outline = spo(svgData, 10);

Example in HTML:

<svg id="star" fill="none" stroke="black">
 <path d="M 95 35 L 59 35 L 48 0 L 36 35 L 0 35 L 29 56 L 18 90 L 48 69 L 77 90 L 66 56 Z" />
</svg>

<script type="text/javascript">
 var spo = require('svg-path-outline');
 var starPath = document.querySelector('#star path');
 var d = starPath.getAttribute('d');
 var outline = spo(d, 10);
 starPath.setAttribute('d', d + outline);
</script>

License

Apache 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].