-
StackOverflow 文件
-
fabricjs 教程
-
FabricJS 畫布序列化
-
帆布系列
<canvas id = "canvas" height='400' width='500'></canvas>
var canvas = new fabric.Canvas(document.getElementById('canvas'));
console.log(JSON.stringify(canvas)); // '{"objects":[],"background":""}'
canvas.add(new fabric.Rect({
left: 10,
top: 10,
height: 50,
width: 50,
fill: 'green',
stroke:'black'
}));
canvas.renderAll();
console.log(JSON.stringify(canvas));//logs the string representation
console.log(canvas.toObject());//logs canvas as an object
console.log(canvas.toSVG());//logs the SVG representation of canvas
小提琴