All Projects → pencil-js → Pencil.js

pencil-js / Pencil.js

Licence: mit
✏️ Nice modular interactive 2D drawing library

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Pencil.js

isometric
A lightweight JavaScript library, written in TypeScript to create isometric projections using SVGs
Stars: ✭ 53 (-74.02%)
Mutual labels:  drawing, draw, 2d
Mopaint
🎨💪 Modern, modular paint and more! (pre-alpha, not much done yet)
Stars: ✭ 50 (-75.49%)
Mutual labels:  drawing, draw, canvas
Sketchpad
Sketchpad is fully customisable collaborative whiteboard plugin written in pure JavaScript.
Stars: ✭ 85 (-58.33%)
Mutual labels:  drawing, draw, canvas
awesome-canvas
Canvas资源库大全中文版。An awesome Canvas packages and resources.
Stars: ✭ 288 (+41.18%)
Mutual labels:  canvas, draw, 2d
D2dlib
A .NET library for hardware-accelerated, high performance, immediate mode rendering via Direct2D.
Stars: ✭ 84 (-58.82%)
Mutual labels:  drawing, draw
Touchable
Flutter library to add gestures and animations to each Shape you draw on your canvas in your CustomPainter
Stars: ✭ 82 (-59.8%)
Mutual labels:  draw, canvas
Pretty Painter
Graphics editor for Android.
Stars: ✭ 105 (-48.53%)
Mutual labels:  drawing, canvas
Libmodule
C simple and elegant implementation of an actor library
Stars: ✭ 118 (-42.16%)
Mutual labels:  modular, oop
Literallycanvas
A canvas in your browser. Literally.
Stars: ✭ 1,043 (+411.27%)
Mutual labels:  drawing, canvas
Omg
🎨 一个让你跳过canvas,直接绘图的 2d 绘图库,上手简单,接口简洁,功能丰富.
Stars: ✭ 107 (-47.55%)
Mutual labels:  drawing, canvas
Pixelfarm
From Vectors to (sub) Pixels, C# 2D Rendering Library
Stars: ✭ 120 (-41.18%)
Mutual labels:  drawing, canvas
Maker.js
📐⚙ 2D vector line drawing and shape modeling for CNC and laser cutters.
Stars: ✭ 1,185 (+480.88%)
Mutual labels:  drawing, draw
Notation
✏️ A simple web app to make drawings that are easy to embed, particularly for Notion.so.
Stars: ✭ 63 (-69.12%)
Mutual labels:  drawing, canvas
Plutovg
Tiny 2D vector graphics library in C
Stars: ✭ 141 (-30.88%)
Mutual labels:  2d, canvas
Sprite Wxapp
spritejs 小程序版
Stars: ✭ 138 (-32.35%)
Mutual labels:  oop, canvas
Cax
HTML5 Canvas 2D Rendering Engine - 小程序、小游戏以及 Web 通用 Canvas 渲染引擎
Stars: ✭ 1,864 (+813.73%)
Mutual labels:  2d, canvas
Clumsy
A library written on node.js for creating math figures on HTMLCanvas in XKCD style.
Stars: ✭ 107 (-47.55%)
Mutual labels:  drawing, canvas
Drawingboard.js
A canvas based drawing app that you can integrate easily on your website.
Stars: ✭ 2,072 (+915.69%)
Mutual labels:  drawing, canvas
Sharpmath
A small .NET math library.
Stars: ✭ 36 (-82.35%)
Mutual labels:  draw, canvas
Minipaint
online image editor
Stars: ✭ 1,014 (+397.06%)
Mutual labels:  drawing, canvas

Pencil.js logo

✏️ Pencil.js

NPM Version Dependencies update Maintainability Test Coverage

Nice modular interactive 2D drawing library.

Installation

You can install Pencil.js with the following command :

npm install pencil.js

CDN

On capable browsers, the easiest way is to import the ESM package.

<script type="module">
    import { Scene } from "https://unpkg.com/pencil.js/dist/pencil.esm.js";
    
    const scene = new Scene();
</script>

If you want to go old-school, you can fetch the script with unpkg or jsdelivr.

<script src="https://unpkg.com/pencil.js"></script>
<!-- or -->
<script src="https://cdn.jsdelivr.net/npm/pencil.js"></script>

<script>
    const scene = new Pencil.Scene();
</script>

Usage

Once you have installed the library using NPM, you can start to import it.

You can either import everything under a namespace or only the package you're going to use. Pick the way that fit your style.

// The whole package under a namespace
import Pencil from "pencil.js";

const scene = new Pencil.scene();

/***/

// Just the part you need (recommended)
import { Scene } from "pencil.js";

const scene = new Scene();

In that case, you will need to use a bundler like webpack or browserify.

Documentation

The official documentation Vercel logo.

What Pencil.js do best

Abstraction

Drawing in a canvas is not trivial. First of all, the goal is to ease the use of canvas in a browser; allowing anyone to use it with its comprehensible syntax and extensible options.

OOP

OOP is great, OOP is almighty, OOP saves lives ! Others library exists, but none with a beautiful OOP syntax. It makes code look natural.

Modularity

Splitting the whole code into modules make everything cleaner. It also allows you to grab only what you need or replace what you don't like.

Documentation

A complete documentation goes a long way to help developers. All functions are assured to have a description and typed arguments and returns.

Performance

Pencil.js is able to draw thousands of shapes pretty smoothly without tanking your memory. Even more if you use the Particles generator.

Size

With Minified and gzip size, Pencil.js is fairly lightweight. Furthermore, with no side effect, it's fully tree-shakable. So, any decent bundler can further reduce its footprint.

Examples

import { Scene, Rectangle } from "pencil.js";

const scene = new Scene(); // create a new scene

const position = [100, 200];
const width = 80;
const height = 50;
const options = {
    fill: "red",
};
const rectangle = new Rectangle(position, width, height, options); // Create a new red rectangle
scene.add(rectangle); // Add the rectangle to the scene

scene.render(); // Render the scene once

Take a look at more advanced examples.

Modules

Core modules

Core modules refer to all classes and methods you'll get within Pencil.js library.

Non-core modules

Non-core modules refer to packages made by us and not part of Pencil.js library. We find them useful so maybe you will too...

  • spritesheet (CLI)
    Pack a set of images into a single spritesheet along its json description file.
  • vue-pencil.js
    Build reactive 2D graphics scene in your Vue project.
  • gif
    Turn any Pencil.js scene into an animated GIF.
  • text-direction
    Gives the rendering text direction (left to right or right to left) of a node.
  • test-environment
    Set a Node.js environment suitable for testing Pencil.js and Pencil.js applications.
  • canvas-gif-encoder
    Create a GIF stream frame by frame from a canvas rendering context.

Who is using Pencil.js ?

Take a tour of all the awesome project using Pencil.js.

Sponsors

JetBrains logo

Enterprises

We are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

Contributions

You want to help us improve ? Please read the contributing manual.

Contributors

Guillaume Martigny avatar
Guillaume Martigny
Heraclite avatar
Heraclite
Zachary Nguyen avatar
Zachary Nguyen
Christian Paul avatar
Christian Paul
Rémi Marche avatar
Rémi Marche

All contributions are valued, you can add yourself to this list (or request to be) whatever your contribution is.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].