mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 06:00:56 -05:00
parent
650bf5d616
commit
3dd0f1fc1b
3 changed files with 11 additions and 3 deletions
|
@ -2087,6 +2087,9 @@ var Item = Base.extend(Emitter, /** @lends Item# */{
|
|||
* @option [options.matchShapes=false] {Boolean} whether path items should
|
||||
* tried to be converted to SVG shape items (rect, circle, ellipse, line,
|
||||
* polyline, polygon), if their geometries match
|
||||
* @option [options.embedImages=true] {Boolean} whether raster images
|
||||
* should be embedded as base64 data inlined in the xlink:href attribute,
|
||||
* or kept as a link to their external URL.
|
||||
*
|
||||
* @param {Object} [options] the export options
|
||||
* @return {SVGElement} the item converted to an SVG node
|
||||
|
|
|
@ -643,6 +643,9 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
|
|||
* @option [options.matchShapes=false] {Boolean} whether path items should
|
||||
* tried to be converted to SVG shape items (rect, circle, ellipse, line,
|
||||
* polyline, polygon), if their geometries match
|
||||
* @option [options.embedImages=true] {Boolean} whether raster images
|
||||
* should be embedded as base64 data inlined in the xlink:href attribute,
|
||||
* or kept as a link to their external URL.
|
||||
*
|
||||
* @param {Object} [options] the export options
|
||||
* @return {SVGElement} the project converted to an SVG node
|
||||
|
|
|
@ -101,15 +101,17 @@ new function() {
|
|||
return node;
|
||||
}
|
||||
|
||||
function exportRaster(item) {
|
||||
function exportRaster(item, options) {
|
||||
var attrs = getTransform(item._matrix, true),
|
||||
size = item.getSize();
|
||||
size = item.getSize(),
|
||||
image = item.getImage();
|
||||
// Take into account that rasters are centered:
|
||||
attrs.x -= size.width / 2;
|
||||
attrs.y -= size.height / 2;
|
||||
attrs.width = size.width;
|
||||
attrs.height = size.height;
|
||||
attrs.href = item.toDataURL();
|
||||
attrs.href = options.embedImages === false && image && image.src
|
||||
|| item.toDataURL();
|
||||
return createElement('image', attrs);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue