All Projects → Ashung → Svg2vectordrawable

Ashung / Svg2vectordrawable

Licence: mit
Node.js module and command-line tools for convert SVG to Android vector drawable.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Svg2vectordrawable

Webfonts Loader
Make an icon font from SVGs!
Stars: ✭ 153 (-10.53%)
Mutual labels:  svg
Animatedsvgview
Animated SVG Drawing for Android
Stars: ✭ 1,927 (+1026.9%)
Mutual labels:  svg
React Native Svg Icon
A simple, but flexible SVG icon component for React Native
Stars: ✭ 164 (-4.09%)
Mutual labels:  svg
Svgdom
Straightforward DOM implementation to make SVG.js run headless on Node.js
Stars: ✭ 154 (-9.94%)
Mutual labels:  svg
Mini Svg Data Uri
Small, efficient encoding of SVG data URIs for CSS, HTML, etc.
Stars: ✭ 158 (-7.6%)
Mutual labels:  svg
React Native Svg Charts
📈 One library to rule all charts for React Native 📊
Stars: ✭ 2,056 (+1102.34%)
Mutual labels:  svg
Terminal In React
👨‍💻 A component that renders a terminal
Stars: ✭ 1,939 (+1033.92%)
Mutual labels:  svg
Svg utils
Python tools to create and manipulate SVG files
Stars: ✭ 169 (-1.17%)
Mutual labels:  svg
Svg Optimiser
A python module to clear up SVG files, especially those created in Inkscape
Stars: ✭ 158 (-7.6%)
Mutual labels:  svg
D3tutorial
📊📈 A D3 v6 tutorial - interactive bar chart and multiple coordinated views (MCV)
Stars: ✭ 163 (-4.68%)
Mutual labels:  svg
Aegis Icons
Unofficial 2FA entry icons for open source Android authenticator Aegis
Stars: ✭ 153 (-10.53%)
Mutual labels:  svg
Lazy Line Painter
Lazy Line Painter - A Modern JS library for SVG path animation
Stars: ✭ 1,918 (+1021.64%)
Mutual labels:  svg
Svgsort
svg path sorter for more efficient (pen)plotting.
Stars: ✭ 162 (-5.26%)
Mutual labels:  svg
Ui Snippets Menu Animations
Four different menu animations for menu button toggle between hamburger, cross and back icon.
Stars: ✭ 153 (-10.53%)
Mutual labels:  svg
Materialdesign Svg
@mdi/svg Dist for Material Design Icons.
Stars: ✭ 166 (-2.92%)
Mutual labels:  svg
Vue Topo
😳 vue + svg 拓扑编辑与展示
Stars: ✭ 153 (-10.53%)
Mutual labels:  svg
Svg Spritemap Webpack Plugin
SVG spritemap plugin for webpack
Stars: ✭ 160 (-6.43%)
Mutual labels:  svg
File Icon Vectors
A collection of file type icons in SVG format
Stars: ✭ 171 (+0%)
Mutual labels:  svg
Gerbolyze
Render high-resolution bitmap images to PCB gerber files
Stars: ✭ 169 (-1.17%)
Mutual labels:  svg
React Rough
🐇 React Components for Rough.js
Stars: ✭ 164 (-4.09%)
Mutual labels:  svg

SVG2VectorDrawable

中文说明

Node.js module and command-line tools for convert SVG to Android vector drawable. Support vector drawable with gradient and clip mask.

Use in command-line

Install.

npm install svg2vectordrawable -g
# Show help.
s2v -h

Convert a SVG to vector drawable file.

s2v -i input.svg -o output.xml
s2v -i input.svg -o res/drawable/output.xml
s2v -p 3 -i input.svg -o res/drawable/output.xml

Convert all SVG file in a folder to vector drawable file.

s2v -f input_folder -o output_folder

Show vector drawable code from SVG code, or convert it to XML file.

s2v -s '<rect x="2" y="2" width="20" height="20"/>'
s2v -s '<Paste from Sketch SVG code>' -o output.xml

Use in node.js

Install.

npm install svg2vectordrawable -s

Example 1, convert SVG code to Android Vector Drawable code, and write to a file.

const svg2vectordrawable = require('svg2vectordrawable');
const writeFile = require('svg2vectordrawable/lib/write-content-to-file');
let svgCode = '<svg viewBox="0 0 24 24"><rect x="2" y="2" width="20" height="20"/></svg>';
let floatPrecision = 3; // If undefined, the default precision is 2.
svg2vectordrawable(svgCode, floatPrecision).then(xmlCode => {
    console.log(xmlCode);
    writeFile(xmlCode, './dir/output.xml');
});

Example 2, convert SVG file to Android Vector Drawable file.

const svg2vectordrawable = require('svg2vectordrawable/lib/svg-file-to-vectordrawable-file');
let floatPrecision = 3; // If undefined, the default precision is 2.
svg2vectordrawable('./dir/input.svg', './dir/output.xml', floatPrecision);

Example 3,use svg2vectordrawable with gulp.

const path = require('path');
const vinylPaths = require('vinyl-paths');
const svg2vectordrawable = require('svg2vectordrawable/lib/svg-file-to-vectordrawable-file');

let floatPrecision = 3; // If undefined, the default precision is 2.

gulp.task('vectorDrawable', () => {
    let dest = './dest/vector-drawable';
    return gulp.src('./dest/svg/*.svg')
        .pipe(vinylPaths(function (file) {
            let outputPath = path.join(dest, 'ic_' + path.basename(file).replace(/\.svg$/, '.xml'));
            return svg2vectordrawable(file, outputPath, floatPrecision);
        }));
});

License

MIT

Donate

Buy me a coffee or donate $5.00 $10.00 via PayPal.

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].