Fabric Padding
FabricPD adds the capability to add padding to a Canvas. The framework is built on-top of Fabric.js
Getting Started
To use the Padding library, using fabric.Padding
, just register a fabric.Canvas
instance.
require('fabric-pd')('fabric');
fabric.Padding.registerCanvas(canvas);
Add de-register once finished:
fabric.Padding.deregisterCanvas(canvas);
Once the canvas is registered, calling the following methods will adjust padding
/**
* @param {Number}
* @param {Number}
* @param {Number}
* @param {Number}
*/
canvas.setPadding([top], [bottom], [left], [right]);
/**
* @param {Number}
*/
canvas.setPaddingTop([top]);
/**
* @param {Number}
*/
canvas.setPaddingBottom([bottom]);
/**
* @param {Number}
*/
canvas.setPaddingLeft([left]);
/**
* @param {Number}
*/
canvas.setPaddingRight([right]);
To get the current applied padding:
/**
* @return {Object}
*/
canvas.getPadding();
/**
* @return {Number}
*/
canvas.getPaddingTop();
/**
* @return {Number}
*/
canvas.getPaddingBottom();
/**
* @return {Number}
*/
canvas.getPaddingLeft();
/**
* @return {Number}
*/
canvas.getPaddingRight();