0.1.8 • Published 1 year ago

canvas-for-print v0.1.8

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

@martialgrin/CanvasForPrint

CanvasForPrint is a little library to create and export easily your picture or sequence canvas in high resolution.

- Under construction, some bugs can appears, report them into the issues

##Installation

NPM install

npm install canvas-for-print
import CanvasForPrint from "canvas-for-print";

CDN install

<link
	href="https://unpkg.com/canvas-for-print@latest/dist/canvas-for-print.cjs.css"
	rel="stylesheet"
/>
<script src="https://unpkg.com/canvas-for-print@latest/dist/canvas-for-print.umd.js"></script>

initialisation

const cPrint = CanvasForPrint({
	...settings,
});

cPrint.create();

settings table

typelabelDescription
numberwidthwidth of your desired canvas || default: 210
numberheightheight of your desired canvas || default: 297
numberppiresolution of the canvas in ppi || default: 300
stringunitunit of measure of the canvas || default: "mm"
DOM Elementcontainercontainer of your canvas || default: document.body
stringidid of your canvas || default: "canvas-for-print"
stringcontextcontext of your canvas || default: "2d"
stringfileNamefileName of your file when you save it || default: "CanvasForPrint"
stringmodemode for the saving file || default: "picture"
objectrecordingFrames!only for sequence mode starting & ending recording frame of the canvas || default: {start:0, end: 100, current: 0 }
booleanp5Modeturn to true if you use p5 || default: false
booleanGUITo display the GUI || default: true

##Current Features

####Save Canvas save frame or sequence in png format with transparent support

cPrint.saveCanvas();

####context get the context of the canvas

const ctx = cPrint.ctx;

####Saving Mode

Mode supported
cPrint.setMode("picture");

save juste one frame of your canvas..

cPrint.setMode("sequence");

save a sequence related to recordingFrames settings.

####Setting fileName get the context of the canvas

cPrint.setFileName("your-filename");

Listeners

A set of listeners to available

cPrint.on("resize",${your-code});

when canvas is resized

cPrint.on("frameSaved", ${your-code});

when canvas is saved, use this to call update function on sequence mode

cPrint.on("saved", ${your-code});

when all frames requested are saved

cPrint.on("startSaving", ${your-code});

before entering in saving mode

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago