0.7.0 • Published 6 years ago

@ismay/silkscreen v0.7.0

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

silkscreen

build status coverage status greenkeeper

pointillize a raster image to svg

Silkscreen allows you to render a raster image to svg. It does so by converting the pixels to svg shapes, with a configurable size. This gives the result a pointillized, or silkscreened appearance.

Installation

$ npm install @ismay/silkscreen

Example

So to silkscreen an image to dots of 25 by 25 pixels, with a 1 pixel gap:

const lena = require('lena');
const silkscreen = require('@ismay/silkscreen');

const svg = silkscreen(lena, {
  sample: [25, 25],
  padding: [1, 1]
});

fs.writeFileSync('./lena.svg', svg);

Which would yield this result:

example

API

silkscreen(image, options) ⇒ string

Converts an ndarray of an image to an svg

Kind: global function Returns: string - The svg as a string

ParamTypeDefaultDescription
imagendarrayNdarray of the image to convert to an svg. Use get-pixels to convert an image to an ndarray.
optionsObject{}Configuration options
options.sampleArray5,5The width and height in pixels per sample, must be positive
options.paddingArray0,0Padding applied to each shape in px
options.shapestring"ellipse"The svg shape to generate, either rect or ellipse
options.patternstringA predefined shape sizing pattern, either linear, diagonal, radial or alpha
options.attributesObject{}An object with attributes to add to each shape

License

MIT

0.7.0

6 years ago

0.6.0

6 years ago

0.5.0

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago