0.1.0 • Published 5 years ago

dumas v0.1.0

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

dumas

build status coverage status greenkeeper

render watercolor images

Renders images that resemble watercolor paint splotches and outputs them as svg. Based on this post by Tyler Hobbs.

Installation

$ npm install dumas

Example

So for example:

const fs = require('fs');
const dumas = require('dumas');

const shape = [
  [593, 215, 1.1],
  [407, 215, 1.5],
  [257, 324, 0.9],
  [200, 500, 0.5],
  [257, 676, 0.7],
  [407, 785, 0.9],
  [593, 785, 0.2],
  [743, 676, 1.1],
  [800, 500, 1.9],
  [743, 324, 0.3]
];

const svg = dumas(shape, {
  fill: 'rgb(245, 10, 10)',
  opacity: 0.02,
  baseSigmas: [50, 30, 20, 20, 10, 10],
  layerSigmas: [20, 10, 5, 5],
  amountOfLayers: 150,
  mutationFactor: 0.75,
  mutationSigma: 0.1
});

fs.writeFileSync('output.svg', svg);

API

dumas(shape, options) ⇒ string

Render watercolor images

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

ParamTypeDefaultDescription
shapeArrayThe base shape to start with, array of arrays
optionsObject{}Global configuration options
options.fillstring"rgb(0, 0, 0)"Css color string, color to fill the shapes with
options.opacitynumber0.02Opacity of the generated shapes, between 0 and 1
options.baseSigmasArray50, 30, 20, 20, 10, 10Array of sigmas for to use for deforming the base shape
options.layerSigmasArray20, 10, 5, 5Array of sigmas for to use for deforming the layer shapes
options.amountOfLayersnumber150Amount of layers to generate
options.mutationFactornumber0.75Factor to reduce sigma by after every deformation round
options.mutationSigmanumber0.1Sigma used for introducing some randomness in the mutationFactor

License

MIT

0.1.0

5 years ago