Skip to content

Commit

Permalink
update: H5 仅对使用uni创建的canvas做高清处理.
Browse files Browse the repository at this point in the history
  • Loading branch information
dcloudhdx committed Apr 23, 2019
1 parent 1f1eddd commit dd631b6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/core/helpers/hidpi.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ if (pixelRatio !== 1) {
forEach(ratioArgs, function (value, key) {
proto[key] = (function (_super) {
return function () {
if (this.__ignore__) {
if (!this.__hidpi__) {
return _super.apply(this, arguments)
}

Expand All @@ -63,7 +63,7 @@ if (pixelRatio !== 1) {

proto.stroke = (function (_super) {
return function () {
if (this.__ignore__) {
if (!this.__hidpi__) {
return _super.apply(this, arguments)
}
this.lineWidth *= pixelRatio
Expand All @@ -74,7 +74,7 @@ if (pixelRatio !== 1) {

proto.fillText = (function (_super) {
return function () {
if (this.__ignore__) {
if (!this.__hidpi__) {
return _super.apply(this, arguments)
}
const args = Array.prototype.slice.call(arguments)
Expand Down Expand Up @@ -102,7 +102,7 @@ if (pixelRatio !== 1) {

proto.strokeText = (function (_super) {
return function () {
if (this.__ignore__) {
if (!this.__hidpi__) {
return _super.apply(this, arguments)
}
var args = Array.prototype.slice.call(arguments)
Expand Down Expand Up @@ -130,7 +130,7 @@ if (pixelRatio !== 1) {

proto.drawImageByCanvas = (function (_super) {
return function (canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh, isScale) {
if (this.__ignore__) {
if (!this.__hidpi__) {
return _super.apply(this, arguments)
}
srcx *= pixelRatio
Expand All @@ -147,7 +147,7 @@ if (pixelRatio !== 1) {

proto.drawImage = (function (_super) {
return function () {
if (this.__ignore__) {
if (!this.__hidpi__) {
return _super.apply(this, arguments)
}
this.scale(pixelRatio, pixelRatio)
Expand All @@ -162,6 +162,7 @@ export function wrapper (canvas) {
canvas.style.width = canvas.width + 'px'
canvas.width *= pixelRatio
canvas.height *= pixelRatio
canvas.getContext('2d').__hidpi__ = true

console.log(canvas.width)
console.log(canvas.height)
Expand Down

0 comments on commit dd631b6

Please sign in to comment.