Skip to content

Commit

Permalink
fix: bbox引用修改 #87
Browse files Browse the repository at this point in the history
  • Loading branch information
army8735 committed Oct 18, 2020
1 parent 35cb094 commit b681edd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12594,7 +12594,7 @@
return null;
}

var bbox = this.__cache.bbox;
var bbox = this.__cache.bbox.slice(0);

if (!isTop) {
bbox = util.transformBbox(bbox, matrix);
Expand Down Expand Up @@ -15563,13 +15563,17 @@
cacheTotal.dy = dy;
ctx = cacheTotal.ctx;
ctx.setTransform([1, 0, 0, 1, 0, 0]);
ctx.globalAlpha = 1;
ctx.globalAlpha = 1; // 计算total的相对原点与dom的相对原点偏移值,有cache使用它的bbox,没有用x1/y1

var dbx = 0,
dby = 0;

if (cache) {
dbx = cache.bbox[0] - cacheTotal.bbox[0];
dby = cache.bbox[1] - cacheTotal.bbox[1];
} else {
dbx = x1 - cacheTotal.bbox[0];
dby = y1 - cacheTotal.bbox[1];
}

cacheTotal.dbx = dbx;
Expand Down
2 changes: 1 addition & 1 deletion index.js.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/node/Dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -1439,11 +1439,16 @@ class Dom extends Xom {
ctx = cacheTotal.ctx;
ctx.setTransform([1, 0, 0, 1, 0, 0]);
ctx.globalAlpha = 1;
// 计算total的相对原点与dom的相对原点偏移值,有cache使用它的bbox,没有用x1/y1
let dbx = 0, dby = 0;
if(cache) {
dbx = cache.bbox[0] - cacheTotal.bbox[0];
dby = cache.bbox[1] - cacheTotal.bbox[1];
}
else {
dbx = x1 - cacheTotal.bbox[0];
dby = y1 - cacheTotal.bbox[1];
}
cacheTotal.dbx = dbx;
cacheTotal.dby = dby;
super.__applyCache(renderMode, lv, ctx, tx - 1 + dbx, ty - 1 + dby);
Expand Down
2 changes: 1 addition & 1 deletion src/node/Xom.js
Original file line number Diff line number Diff line change
Expand Up @@ -2041,7 +2041,7 @@ class Xom extends Node {
if(!this.__cache || !this.__cache.available) {
return null;
}
let bbox = this.__cache.bbox;
let bbox = this.__cache.bbox.slice(0);
if(!isTop) {
bbox = util.transformBbox(bbox, matrix);
}
Expand Down

0 comments on commit b681edd

Please sign in to comment.