0.2.0 • Published 7 years ago

svg-reader v0.2.0

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

svg-reader

Build Status

sync read svg icons and parse to icons object

get

npm install svg-reader

use

const read = require('svg-reader')
var icons = read(__dirname + '/icons.svg')

/*
icons = 
{ home: 
   { name: 'home',
     width: 928,
     height: 1000,
     path: 'M786 ... 12t-4-13z',
     ascent: 850,
     svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 928 1000"><g transform="scale(1,-1) translate(0 -850)"><path d="M78 ... 4-13z"/></g></svg>' },
  link: 
   { name: 'link',
     width: 928,
     height: 1000,
     path: 'M81 ... 14z',
     ascent: 850,
     svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 928 1000"><g transform="scale(1,-1) translate(0 -850)"><path d="M81 ... 114z"/></g></svg>' },
  unlink: 
   { name: 'unlink',
     width: 928,
     height: 1000,
     path: 'M24 ... 13z',
     ascent: 850,
     svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 928 1000"><g transform="scale(1,-1) translate(0 -850)"><path d="M24 ... 5-13z"/></g></svg>' }
}

*/

//if do not need svg,  pass a option { nosvg: true } 
var icons = read(__dirname + '/icons.svg', { nosvg: true })
/*
icons = 
{ home: 
   { name: 'home',
     width: 928,
     height: 1000,
     path: 'M786 ... 12t-4-13z',
     ascent: 850},
  link: 
   { name: 'link',
     width: 928,
     height: 1000,
     path: 'M81 ... 14z',
     ascent: 850},
  unlink: 
   { name: 'unlink',
     width: 928,
     height: 1000,
     path: 'M24 ... 13z',
     ascent: 850}
}

*/

test

git clone git@github.com:zxdong262/svg-reader.git
cd svg-reader
npm i
npm run test

License

MIT

0.2.0

7 years ago

0.1.0

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago