Skip to content

Commit

Permalink
fix: support pixelRatio setting for node-canvas.
Browse files Browse the repository at this point in the history
  • Loading branch information
simaQ committed Apr 25, 2018
1 parent 8271152 commit 85cb71d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/f2",
"version": "3.1.4-beta.1",
"version": "3.1.4-beta.2",
"description": "A canvas library which providing 2d draw for G2.",
"keywords": [
"canvas",
Expand Down
11 changes: 7 additions & 4 deletions src/graphic/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,16 @@ class Canvas {
if (Util.isBrowser) {
canvasDOM.style.width = width + 'px';
canvasDOM.style.height = height + 'px';
}

if (!Util.isWx && !Util.isMy) {
canvasDOM.width = width * pixelRatio;
canvasDOM.height = height * pixelRatio;
}

if (pixelRatio !== 1 && !Util.isWx && !Util.isMy) {
const ctx = this.get('context');
ctx.scale(pixelRatio, pixelRatio);
if (pixelRatio !== 1) {
const ctx = this.get('context');
ctx.scale(pixelRatio, pixelRatio);
}
}

this.set('width', width);
Expand Down

0 comments on commit 85cb71d

Please sign in to comment.