fabric.StaticCanvas Class
_common\_js\fabric\fabric.require.js:5600
Static canvas class
Methods
-
[options]
-
[reviver]
Returns SVG representation of canvas
Parameters:
-
[options]
Object optionalOptions object for SVG output
-
[reviver]
Function optionalMethod for further parsing of svg elements, called after each fabric object converted into svg representation.
Returns:
SVG string
Example:
Normal SVG output var svg = canvas.toSVG();
SVG output without preamble (without <?xml ../>) var svg = canvas.toSVG({suppressPreamble: true});
SVG output with viewBox attribute var svg = canvas.toSVG({ viewBox: { x: 100, y: 100, width: 200, height: 300 } });
SVG output with different encoding (default: UTF-8) var svg = canvas.toSVG({encoding: 'ISO-8859-1'});
Modify SVG output with reviver function var svg = canvas.toSVG(null, function(svg) { return svg.replace('stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; ', ''); });
-
[propertiesToInclude]
Returns JSON representation of canvas
Parameters:
-
[propertiesToInclude]
Array optionalAny properties that you might want to additionally include in the output
Returns:
JSON string
Example:
JSON without additional properties var json = canvas.toJSON();
JSON with additional properties included var json = canvas.toJSON(['lockMovementX', 'lockMovementY', 'lockRotation', 'lockScalingX', 'lockScalingY', 'lockUniScaling']);
JSON without default values canvas.includeDefaultValues = false; var json = canvas.toJSON();