From 2db0043d95843daf4e04ad6c6af3f1bd19d33fc3 Mon Sep 17 00:00:00 2001 From: xnv Date: Mon, 25 Dec 2023 16:01:36 +0900 Subject: [PATCH] fix: ceil non-integer size for Surface --- CHANGELOG.md | 3 +++ package-lock.json | 4 ++-- package.json | 2 +- src/Surface.ts | 12 +++--------- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3eadc9..6319626 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +## 2.8.5 +* `Surface` 生成時、非整数のサイズをエラーにせず整数に切り上げるように + ## 2.8.4 * ペンタブレットによるドラッグ時、意図しない操作が起きる問題を修正 diff --git a/package-lock.json b/package-lock.json index 8139cad..91a2bd5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@akashic/pdi-browser", - "version": "2.8.4", + "version": "2.8.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@akashic/pdi-browser", - "version": "2.8.4", + "version": "2.8.5", "license": "MIT", "dependencies": { "@akashic/trigger": "^2.0.1" diff --git a/package.json b/package.json index c89a781..a0da6b0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@akashic/pdi-browser", - "version": "2.8.4", + "version": "2.8.5", "description": "An akashic-pdi implementation for Web browsers", "main": "index.js", "typings": "lib/full/index.d.ts", diff --git a/src/Surface.ts b/src/Surface.ts index 73f2f52..81e8201 100644 --- a/src/Surface.ts +++ b/src/Surface.ts @@ -9,15 +9,9 @@ export abstract class Surface implements pdi.Surface { _destroyed: boolean | undefined; constructor(width: number, height: number, drawable: any) { - this.width = width; - this.height = height; - this._drawable = drawable; - if (width % 1 !== 0 || height % 1 !== 0) { - throw new Error("Surface#constructor: width and height must be integers"); - } - - this.width = width; - this.height = height; + // 非整数の動作は保証していないが、環境依存でエラーになるトラブルを軽減するため切り上げ。 + this.width = Math.ceil(width); + this.height = Math.ceil(height); this._drawable = drawable; }