Commit f82afcee authored by qinyang's avatar qinyang Committed by Bo Zhang

fix: 修复导出的PNG位置不居中和图片错位的问题 (#23)

* fix: 修复导出的PNG位置不居中和图片错位的问题

* fix(png): fix bug more elegant.

* fix(png): rollback to former status

thanks to @qingyang912

* fix(png): syntax error
parent bac91ac8
......@@ -101,8 +101,8 @@ define(function(require, exports, module) {
url: imageUrl,
width: imageSize.width,
height: imageSize.height,
x: -renderContainer.getBoundaryBox().x + imageRenderBox.x + 20,
y: -renderContainer.getBoundaryBox().y + imageRenderBox.y + 20
x: -renderContainer.getBoundaryBox().x + imageRenderBox.x,
y: -renderContainer.getBoundaryBox().y + imageRenderBox.y
};
imagesInfo.push(imageInfo);
......@@ -158,9 +158,9 @@ define(function(require, exports, module) {
function drawImage(ctx, image, x, y, width, height) {
if (width && height) {
ctx.drawImage(image, x, y, width, height);
ctx.drawImage(image, x + padding, y + padding, width, height);
} else {
ctx.drawImage(image, x, y);
ctx.drawImage(image, x + padding, y + padding);
}
}
......@@ -185,7 +185,7 @@ define(function(require, exports, module) {
return loadImages(imagesInfo);
}).then(function($images) {
for(var i = 0; i < $images.length; i++) {
drawImage(ctx, $images[i].element, $images[i].x, $images[i].y, $images[i].width, $images[i].height);
drawImage(ctx, $images[i].element, $images[i].x + offsetX, $images[i].y + offsetY, $images[i].width, $images[i].height);
}
DomURL.revokeObjectURL(svgDataUrl);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment