0.3.4 ā€¢ Published 2 years ago

illustrator.js v0.3.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Installation

# install with npm
$ npm install illustrator.js
# install with yarn
$ yarn add illustrator.js

šŸŽ‰ No build tools required!

Features

  • Illustrator is fast, powered by @napi-rs/canvas šŸš€
  • Illustrator provides beginner friendly API šŸ¤“
  • TypeScript supported šŸ’Ŗ
  • Layers API šŸŽšļø
  • Color utilities API šŸŽØ
  • Filters šŸ“ø
  • Tools such as eraser, shapes, text, etc. āš’ļø
  • Image manipulation (crop, brightness, blur, sharpness, format conversion, compression and much more..)
  • Animation API (GIF) šŸ˜Ž

and more...

Documentation

https://illustrator.js.org

npm

https://www.npmjs.com/package/illustrator.js

Quick Example

Creating GIF

// import
import { Illustrator } from "illustrator.js";
import fs from "fs";

// create illustrator instance
const illustrator = new Illustrator(512, 512);

// colors array
const colors = ["#FFFFFF", "#FF0000", "#FFFF00", "#FF00FF", "#00FF00", "#0000FF"];

// for a color in colors array, create new layer and fill the layer with that color
for (const color of colors) {
    // create new layer
    const layer = illustrator.layers.createLayer({
        name: color
    });
    // create background color tool
    const bgTool = layer.tools.get("BackgroundColorTool");
    // set fill color
    bgTool.setFillColor(color);
    // fill background
    bgTool.fill(0, 0, illustrator.width, illustrator.height);
    // render this tool to the layer
    bgTool.render();
}

// get animation api
const animation = illustrator.animation;
// get all layers and transform to animation frame
const layers = illustrator.layers.getAllLayers().map(m => ({
    duration: 500,
    frame: m.layer
}));
// animation config, set repeat to infinite (or 0) and add our layers to frames
animation.setRepeat(0).addFrames(layers);

// render the frames
const output = await animation.createAnimation();
// write the output file
output.pipe(fs.createWriteStream("./animation.gif"));

Output Preview

Other Examples

Check out ~/examples for more.

Canvacord

It may be hard to get simple things done via this library. Check out Canvacord for beginner-friendly utility APIs, built with Illustrator.js.

Special thanks to šŸ’–

Brooooooklyn and the people behind napi-rs. Illustrator.js is here only because of their hard work behind the projects under napi-rs.

Discord

Join our official Discord support server: Join Now

Help us keep this project alive

ko-fi

0.3.4

2 years ago

0.3.3

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago

0.1.0-dev.6

2 years ago

0.1.0-dev.5

2 years ago

0.1.0-dev.4

2 years ago

0.1.0-dev.3

2 years ago

0.1.0-dev.2

2 years ago

0.1.0-dev.1

2 years ago

0.1.0-dev

2 years ago