0.1.1 • Published 5 years ago

recolor-img v0.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

recolor-img

Recolor an image (SVG and PNG), useful for recoloring toolbar icons.

Installation

yarn add recolor-img

Usage

Node.js

import { recolorSVGString, recolorPNGImage } from 'recolor-img';

Browser

<script src="./node_modules/recolor-img/dist/main.js"></script>
<script>
  const { recolorPNGImage, recolorSVGString } = window.recolorImg;
</script>

Example

<script>
  const { recolorPNGImage, recolorSVGString } = window.recolorImg;
  // recolorPNGImage recolors image of the given <img> element with the specified color.
  recolorPNGImage(document.getElementById('png'), '#83c400');

  // recolorSVGString recolors the given SVG string with the specified color.
  const svg1 = `<svg>...</svg>`;
  document
    .getElementById('svg1')
    .setAttribute('src', recolorSVGString(svg1, '#83c400', true));
</script>