GithubHelp home page GithubHelp logo

vectorizer's Introduction

Vectorizer

Raster to Vector image converter written in JS

Usage

Include Script

<script src='app.js'></script>

Initialize an object and call makeVector

var obj = new Vectorizer();
obj.makeVector(url, obj.SVGToContainer);

Appends the vectorized image to the root container (you can specify container to append to).

Note: The image URL must be in the same domain as the script. This is an SVG requirement in order to not to taint the canvas with foreign data.

Options

Set colorquantcycles = 1 for deterministic output. Any value > 1 produces non-deterministic output. Default used is 3

The numberofcolors option specifies palette color count. Cubic numbers ( 2^x) are suggested for deterministic palettes. Or, you can use a custom palette altogether

It is highly recommend against altering lower linear threshold and quadratic spline values. They seem to be at an empirically OK place as they are. Change them if you want to experiment. Do not set their value > 2; inaccuracies are observed

The mincolorratio option is a threshold below which anomaly and outlier pixel colors are randomized to a palette color. For an image of size 20 x 20 , a 0.01 threshold randomizes any color whose count is less than 20 x 20 x 0.01 = 4 pixels

More Usage Options

var obj = new Vectorizer();

Alert the SVG string

obj.makeVector(url,alert)

Append to a custom container

obj.makeVector(url, function(str){
   obj.SVGToContainer(str, 'Container-id-here');
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.