paint-board
basic usage
let paintBoard = new PaintBoard({
canvas,
logicalWidth : window.innerWidth,
logicalHeight : window.innerHeight,
strokeConfig : {
strokeWidth : 10,
strokeColor : penColor
}
});
paintBoard.Tool('pen');
Demo List
configs
HTMLCanvasElement
canvas destination output
Number
logicalWidth canvas resolution width
Number
logicalHeight canvas resolution height
Object
strokeConfig contains
-
strokeWidth
Number
line width to init
-
strokeColor
String
line color to init
Object
background contains
-
color
String
-
image
HTMLImageElement
Boolean
enableHistory enable history
Number
historyMax history record stack max length
Number
historyInterval a time to help determine whether the new history record's creation between two operations
String
clearColor if you do wanna do real clear , just set its value to transparent
Number
clearRadius actually clear is not a line but a dot.
Method codes
INSTANCE.Method(CODE)
Undo
Apply last one (base on current history index) history record
enableHistory is required
Redo
Apply next one (base on current history index) history record
enableHistory is required
clear
Clean canvas
Tool codes
INSTANCE.Tool(CODE)
pen
line
polygon
eraser
Other
SaveData Function
with one Object
parameter that contains
-
returnType
String
-
arraybuffer
beware arraybuffer do not contains metadata or other infos but only pixels data.
return Buffer -
file
This return a real file that like you choose a file from local.
you need combine use the cb parameter.
-
base64
return
String
-
-
compBg
Boolean
represent the output will be blend with background image (in the config).
cb
Function
callback for returnType : 'file' since this is an asynchronous action.