All Projects → kyranet → canvas-constructor

kyranet / canvas-constructor

Licence: MIT License
An ES6 utility for canvas with built-in functions and chained methods.

Programming Languages

typescript
32286 projects
HTML
75241 projects

Projects that are alternatives of or similar to canvas-constructor

awesome-canvas
Canvas资源库大全中文版。An awesome Canvas packages and resources.
Stars: ✭ 288 (+200%)
Mutual labels:  canvas, draw
Makeup
让你的“女神”逆袭,代码撸彩妆(画妆)
Stars: ✭ 655 (+582.29%)
Mutual labels:  canvas, draw
Spotify-Cards-API
🚀 Unofficial Spotify PromoCards API
Stars: ✭ 13 (-86.46%)
Mutual labels:  canvas, node-canvas
Simple Draw
A canvas you can draw on with different colors.
Stars: ✭ 256 (+166.67%)
Mutual labels:  canvas, draw
Touchable
Flutter library to add gestures and animations to each Shape you draw on your canvas in your CustomPainter
Stars: ✭ 82 (-14.58%)
Mutual labels:  canvas, draw
Generating Devanagari Using Draw
PyTorch implementation of DRAW: A Recurrent Neural Network For Image Generation trained on Devanagari dataset.
Stars: ✭ 82 (-14.58%)
Mutual labels:  draw, image-generation
Flutter Canvas
About using of canvas in the flutter
Stars: ✭ 259 (+169.79%)
Mutual labels:  canvas, draw
Rnn Vae
Variational Autoencoder with Recurrent Neural Network based on Google DeepMind's "DRAW: A Recurrent Neural Network For Image Generation"
Stars: ✭ 39 (-59.37%)
Mutual labels:  draw, image-generation
Mopaint
🎨💪 Modern, modular paint and more! (pre-alpha, not much done yet)
Stars: ✭ 50 (-47.92%)
Mutual labels:  canvas, draw
Sharpmath
A small .NET math library.
Stars: ✭ 36 (-62.5%)
Mutual labels:  canvas, draw
Konva
Konva.js is an HTML5 Canvas JavaScript framework that extends the 2d context by enabling canvas interactivity for desktop and mobile applications.
Stars: ✭ 6,985 (+7176.04%)
Mutual labels:  canvas, node-canvas
Pencil.js
✏️ Nice modular interactive 2D drawing library
Stars: ✭ 204 (+112.5%)
Mutual labels:  canvas, draw
Sketchpad
Sketchpad is fully customisable collaborative whiteboard plugin written in pure JavaScript.
Stars: ✭ 85 (-11.46%)
Mutual labels:  canvas, draw
Rough
Create graphics with a hand-drawn, sketchy, appearance
Stars: ✭ 16,472 (+17058.33%)
Mutual labels:  canvas, draw
flappy-bird
🐦 A clone of a famous game, the Flappy Bird, made in Javascript and HTML Canvas API.
Stars: ✭ 37 (-61.46%)
Mutual labels:  canvas
canvas-cast
Cast any <canvas> element to an LED Matrix over WebSockets with an Arduino/ESP8266.
Stars: ✭ 39 (-59.37%)
Mutual labels:  canvas
TriangleGAN
TriangleGAN, ACM MM 2019.
Stars: ✭ 28 (-70.83%)
Mutual labels:  image-generation
isometric
A lightweight JavaScript library, written in TypeScript to create isometric projections using SVGs
Stars: ✭ 53 (-44.79%)
Mutual labels:  draw
canvas-merge-video-in-vue
canvas+vue 实现视频碎片合并 比较粗陋,欢迎fork 升级++
Stars: ✭ 21 (-78.12%)
Mutual labels:  canvas
automatic-manga-colorization
Use keras.js and cyclegan-keras to colorize manga automatically. All computation in browser. Demo is online:
Stars: ✭ 20 (-79.17%)
Mutual labels:  image-generation

CanvasConstructor Logo

canvas-constructor

An ES6 chainable class for node-canvas with built-in utilities.

npm npm Total alerts GitHub license

Support Server


Installation

This module requires one of the following packages to be installed for Node.js:

Note: If you are building a website, no extra dependencies are required.


How to use it:

Node.js:

const { Canvas } = require('canvas-constructor/skia');
// or `canvas-constructor/cairo` if you are using `canvas`

new Canvas(300, 300)
	.setColor('#AEFD54')
	.printRectangle(5, 5, 290, 290)
	.setColor('#FFAE23')
	.setTextFont('28px Impact')
	.printText('Hello World!', 130, 150)
	.toBuffer();

Browser:

<script type="text/javascript" src="https://unpkg.com/canvas-constructor"></script>
<script type="text/javascript">
	const canvasElement = document.getElementById('canvas');
	new CanvasConstructor.Canvas(canvasElement)
		.setColor('#AEFD54')
		.printRectangle(5, 5, 290, 290)
		.setColor('#FFAE23')
		.setTextFont('28px Impact')
		.printText('Hello World!', 130, 150);
</script>
  • That will create a canvas with size of 300 pixels width, 300 pixels height.
  • Set the color to #AEFD54
  • Draw a rectangle with the previous color, covering all the pixels from (5, 5) to (290 + 5, 290 + 5)
  • Set the color to #FFAE23
  • Set the font size to 28 pixels with font Impact.
  • Write the text 'Hello World!' in the position (130, 150)
  • Return a buffer.

Now, let's suppose we want to add images, we'll use Canvas.resolveImage, which works in both Node.js and browser:

const { Canvas, resolveImage } = require('canvas-constructor/skia');

async function createCanvas() {
	const image = await resolveImage('./images/kitten.png');

	return new Canvas(300, 400)
		.printImage(image, 0, 0, 300, 400)
		.setColor('#FFAE23')
		.setTextFont('28px Impact')
		.setTextAlign('center')
		.printText('Kitten!', 150, 370)
		.toBufferAsync();
}
  • That will create a canvas with size of 300 pixels width, 400 pixels height.
  • Draw an image, given a Buffer (the image from the images folder).
  • Set the color to #FFAE23
  • Set the font size to 28 pixels with font Impact.
  • Set the text alignment to center.
  • Write the text 'Kitten!' in the position (150, 370)
  • Return a buffer.

And now, you have created an image with a kitten in the background and some centred text in the bottom of it.

If you experience issues with skia-canvas or canvas, please refer to their respective package repositories, this package is just a convenient wrapper for the two.

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].