mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -05:00
Added data URLs for Rasters in Node.js
This commit is contained in:
parent
7c2e57e105
commit
269b93e888
1 changed files with 10 additions and 4 deletions
|
@ -297,11 +297,17 @@ var Raster = this.Raster = Item.extend(/** @lends Raster# */{
|
||||||
image.src = src;
|
image.src = src;
|
||||||
}
|
}
|
||||||
/*#*/ } else if (options.server) {
|
/*#*/ } else if (options.server) {
|
||||||
// If we're running on the server and it's a string,
|
|
||||||
// load it from disk:
|
|
||||||
// TODO: load images async, calling setImage once loaded as above
|
|
||||||
var image = new Image();
|
var image = new Image();
|
||||||
image.src = fs.readFileSync(src);
|
// If we're running on the server and it's a string,
|
||||||
|
// check if it is a data URL
|
||||||
|
var protocol = src.split('/')[0];
|
||||||
|
if (protocol && protocol.equals("data:image")) {
|
||||||
|
image.src = src;
|
||||||
|
} else {
|
||||||
|
// load it from disk:
|
||||||
|
// TODO: load images async, calling setImage once loaded as above
|
||||||
|
image.src = fs.readFileSync(src);
|
||||||
|
}
|
||||||
/*#*/ } // options.server
|
/*#*/ } // options.server
|
||||||
this.setImage(image);
|
this.setImage(image);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue