resizeCanvas styleOnly

This commit is contained in:
ckcz123 2019-08-19 10:23:11 +08:00
parent 42f6841e68
commit a97f9b6f6d
3 changed files with 13 additions and 7 deletions

View File

@ -1871,8 +1871,11 @@ core.ui.relocateCanvas(name, x, y)
重新定位一个自定义画布。x和y为画布的左上角坐标。
core.ui.resizeCanvas(name, width, height)
重新设置一个自定义画布的大小。width和height为新设置的宽高。此操作会清空画布。
core.ui.resizeCanvas(name, width, height, styleOnly)
重新设置一个自定义画布的大小。width和height为新设置的宽高。
styleOnly控制是否只修改画布的显示大小而不修改画布的内部大小
如果styleOnly为true则只修改其显示大小即canvas.style.width
否则,则会同时修改画布的显示大小和内部大小并清空画布内容。
core.ui.deleteCanvas(name)

View File

@ -1851,8 +1851,11 @@ core.ui.relocateCanvas(name, x, y)
重新定位一个自定义画布。x和y为画布的左上角坐标。
core.ui.resizeCanvas(name, width, height)
重新设置一个自定义画布的大小。width和height为新设置的宽高。此操作会清空画布。
core.ui.resizeCanvas(name, width, height, styleOnly)
重新设置一个自定义画布的大小。width和height为新设置的宽高。
styleOnly控制是否只修改画布的显示大小而不修改画布的内部大小
如果styleOnly为true则只修改其显示大小即canvas.style.width
否则,则会同时修改画布的显示大小和内部大小并清空画布内容。
core.ui.deleteCanvas(name)

View File

@ -2919,15 +2919,15 @@ ui.prototype.relocateCanvas = function (name, x, y) {
}
////// canvas重置 //////
ui.prototype.resizeCanvas = function (name, width, height) {
ui.prototype.resizeCanvas = function (name, width, height, styleOnly) {
var ctx = core.dymCanvas[name];
if (!core.isset(ctx)) return null;
if (core.isset(width)) {
ctx.canvas.width = width;
if (!styleOnly) ctx.canvas.width = width;
ctx.canvas.style.width = width * core.domStyle.scale + 'px';
}
if (core.isset(height)) {
ctx.canvas.height = height;
if (!styleOnly) ctx.canvas.height = height;
ctx.canvas.style.height = height * core.domStyle.scale + 'px';
}
return ctx;