mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-17 02:01:05 +00:00
Document fabric.loadSVGFromString. Replace canvas.loadSVGFromURL with fabric.loadSVGFromURL.
This commit is contained in:
parent
ace016c694
commit
044866cf44
4 changed files with 11 additions and 7 deletions
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
//console.profile('parsing');
|
||||
|
||||
canvas.loadSVGFromURL('tiger2.svg', function(objects) {
|
||||
fabric.loadSVGFromURL('tiger2.svg', function(objects) {
|
||||
|
||||
//console.profileEnd('parsing');
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
//console.profile('parsing');
|
||||
|
||||
canvas.loadSVGFromURL('dragon.svg', function(objects) {
|
||||
fabric.loadSVGFromURL('dragon.svg', function(objects) {
|
||||
|
||||
//console.profileEnd('parsing');
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
<script id="main">
|
||||
var canvas = new fabric.Canvas('c');
|
||||
|
||||
canvas.loadSVGFromURL('../kitchensink/assets/135.svg', function(objects) {
|
||||
fabric.loadSVGFromURL('../kitchensink/assets/135.svg', function(objects) {
|
||||
|
||||
var obj = objects[0].scale(0.25);
|
||||
canvas.centerObjectH(obj).centerObjectV(obj);
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@
|
|||
};
|
||||
|
||||
/**
|
||||
* Takes url corresponding to an SVG document, and parses it to a set of objects
|
||||
* Takes url corresponding to an SVG document, and parses it into a set of fabric objects
|
||||
* @method loadSVGFromURL
|
||||
* @param {String} url
|
||||
* @param {Function} callback
|
||||
|
|
@ -181,8 +181,6 @@
|
|||
var doc = xml.documentElement;
|
||||
if (!doc) return;
|
||||
|
||||
console.log(doc);
|
||||
|
||||
fabric.parseSVGDocument(doc, function (results, options) {
|
||||
svgCache.set(url, {
|
||||
objects: fabric.util.array.invoke(results, 'toObject'),
|
||||
|
|
@ -207,7 +205,13 @@
|
|||
|
||||
return ({ objects: objects, options: options });
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Takes string corresponding to an SVG document, and parses it into a set of fabric objects
|
||||
* @method loadSVGFromString
|
||||
* @param {String} string
|
||||
* @param {Function} callback
|
||||
*/
|
||||
function loadSVGFromString(string, callback) {
|
||||
var doc;
|
||||
if (typeof DOMParser !== 'undefined') {
|
||||
|
|
|
|||
Loading…
Reference in a new issue