svg-color-light
v1.0.7
Published
get color change color of svg string
Downloads
2
Readme
get started
npm i svg-color-light
import { getColor, changeColor, strToDom, strToJson } from "svg-color-light"
example const
const svg = `
<style>
.a {
fill: #333333
}
.b {
fill: #222222
}
</style>
<svg height="100" width="100">
<circle cx="50" cy="50" r="40" fill="#000000" />
<circle cx="50" cy="50" r="40" fill="#000000" />
<circle cx="50" cy="50" r="40" fill="#000001" />
</svg>
`
get color from svg string
console.log(getColor(svg)) //output => [ '#333333', '#222222', '#000000', '#000001' ]
change color of svg string
const changedColor = changeColor(svg, [{from: '#333333', to: '#000'}])
console.log(changedColor) //output => new string svg
console.log(getColor(changedColor)) //output => [ '#000', '#222222', '#000000', '#000001' ]