Ashung / Svg2vectordrawable
Licence: mit
Node.js module and command-line tools for convert SVG to Android vector drawable.
Stars: ✭ 171
Programming Languages
javascript
184084 projects - #8 most used programming language
Labels
Projects that are alternatives of or similar to Svg2vectordrawable
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 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
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
Svg Spritemap Webpack Plugin
SVG spritemap plugin for webpack
Stars: ✭ 160 (-6.43%)
Mutual labels: svg
Gerbolyze
Render high-resolution bitmap images to PCB gerber files
Stars: ✭ 169 (-1.17%)
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].