mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-06-28 13:17:59 +08:00
fix: 画面清晰度
This commit is contained in:
parent
f796e93240
commit
9628d7acb7
@ -990,7 +990,6 @@ export class TextContentParser {
|
|||||||
data.splitLines.push(this.wordBreak[index]);
|
data.splitLines.push(this.wordBreak[index]);
|
||||||
this.lineHeights.push(this.lineHeight);
|
this.lineHeights.push(this.lineHeight);
|
||||||
this.lineWidths.push(this.lineWidth);
|
this.lineWidths.push(this.lineWidth);
|
||||||
this.bsStart = index;
|
|
||||||
const text = data.text.slice(
|
const text = data.text.slice(
|
||||||
this.wordBreak[index] + 1,
|
this.wordBreak[index] + 1,
|
||||||
pointer + 1
|
pointer + 1
|
||||||
@ -1002,10 +1001,11 @@ export class TextContentParser {
|
|||||||
}
|
}
|
||||||
maxWidth = width;
|
maxWidth = width;
|
||||||
const metrics = ctx.measureText(text);
|
const metrics = ctx.measureText(text);
|
||||||
if (metrics.width < maxWidth) {
|
if (metrics.width < maxWidth || index === this.bsStart) {
|
||||||
this.lastBreakIndex = index;
|
this.lastBreakIndex = index;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
this.bsStart = index;
|
||||||
}
|
}
|
||||||
this.lineWidth = 0;
|
this.lineWidth = 0;
|
||||||
this.lineStart = pointer;
|
this.lineStart = pointer;
|
||||||
@ -1092,7 +1092,6 @@ export class TextContentParser {
|
|||||||
data.splitLines.push(this.wordBreak[index]);
|
data.splitLines.push(this.wordBreak[index]);
|
||||||
this.lineHeights.push(this.lineHeight);
|
this.lineHeights.push(this.lineHeight);
|
||||||
this.lineWidths.push(this.lineWidth);
|
this.lineWidths.push(this.lineWidth);
|
||||||
this.bsStart = index;
|
|
||||||
const text = data.text.slice(this.wordBreak[index] + 1);
|
const text = data.text.slice(this.wordBreak[index] + 1);
|
||||||
if (!isLast && text.length < guess / 4) {
|
if (!isLast && text.length < guess / 4) {
|
||||||
// 如果剩余文字很少,几乎不可能会单独成一行时,直接结束循环
|
// 如果剩余文字很少,几乎不可能会单独成一行时,直接结束循环
|
||||||
@ -1101,10 +1100,11 @@ export class TextContentParser {
|
|||||||
}
|
}
|
||||||
const metrics = ctx.measureText(text);
|
const metrics = ctx.measureText(text);
|
||||||
maxWidth = width;
|
maxWidth = width;
|
||||||
if (metrics.width < maxWidth) {
|
if (metrics.width < maxWidth || index === this.bsStart) {
|
||||||
this.lastBreakIndex = index;
|
this.lastBreakIndex = index;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
this.bsStart = index;
|
||||||
}
|
}
|
||||||
this.lineWidth = 0;
|
this.lineWidth = 0;
|
||||||
return true;
|
return true;
|
||||||
|
@ -628,13 +628,13 @@ export class Layer extends Container<ELayerEvent> {
|
|||||||
this.size(core._PX_, core._PY_);
|
this.size(core._PX_, core._PY_);
|
||||||
|
|
||||||
this.staticMap.setHD(false);
|
this.staticMap.setHD(false);
|
||||||
// this.staticMap.setAntiAliasing(false);
|
this.staticMap.setAntiAliasing(false);
|
||||||
this.staticMap.size(core._PX_, core._PY_);
|
this.staticMap.size(core._PX_, core._PY_);
|
||||||
this.movingMap.setHD(false);
|
this.movingMap.setHD(false);
|
||||||
// this.movingMap.setAntiAliasing(false);
|
this.movingMap.setAntiAliasing(false);
|
||||||
this.movingMap.size(core._PX_, core._PY_);
|
this.movingMap.size(core._PX_, core._PY_);
|
||||||
this.backMap.setHD(false);
|
this.backMap.setHD(false);
|
||||||
// this.backMap.setAntiAliasing(false);
|
this.backMap.setAntiAliasing(false);
|
||||||
this.backMap.size(core._PX_, core._PY_);
|
this.backMap.size(core._PX_, core._PY_);
|
||||||
this.main.setAntiAliasing(false);
|
this.main.setAntiAliasing(false);
|
||||||
this.main.setHD(false);
|
this.main.setHD(false);
|
||||||
@ -778,11 +778,11 @@ export class Layer extends Container<ELayerEvent> {
|
|||||||
if (!data) return;
|
if (!data) return;
|
||||||
|
|
||||||
const frame = data.frame;
|
const frame = data.frame;
|
||||||
const temp = this.requireCanvas();
|
const temp = this.requireCanvas(true, false);
|
||||||
temp.setHD(false);
|
temp.setHD(false);
|
||||||
temp.setAntiAliasing(false);
|
temp.setAntiAliasing(false);
|
||||||
for (let i = 0; i < frame; i++) {
|
for (let i = 0; i < frame; i++) {
|
||||||
const canvas = this.requireCanvas();
|
const canvas = this.requireCanvas(true, false);
|
||||||
const ctx = canvas.ctx;
|
const ctx = canvas.ctx;
|
||||||
const tempCtx = temp.ctx;
|
const tempCtx = temp.ctx;
|
||||||
const [sx, sy, w, h] = data.render[i];
|
const [sx, sy, w, h] = data.render[i];
|
||||||
@ -1198,7 +1198,7 @@ export class Layer extends Container<ELayerEvent> {
|
|||||||
const ex = Math.min(sx + blockSize, this.mapWidth);
|
const ex = Math.min(sx + blockSize, this.mapWidth);
|
||||||
const ey = Math.min(sy + blockSize, this.mapHeight);
|
const ey = Math.min(sy + blockSize, this.mapHeight);
|
||||||
|
|
||||||
const temp = this.requireCanvas();
|
const temp = this.requireCanvas(true, false);
|
||||||
temp.setAntiAliasing(false);
|
temp.setAntiAliasing(false);
|
||||||
temp.setHD(false);
|
temp.setHD(false);
|
||||||
temp.size(core._PX_, core._PY_);
|
temp.size(core._PX_, core._PY_);
|
||||||
|
@ -179,7 +179,7 @@ export class Winskin extends RenderItem<EWinskinEvent> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private generatePattern() {
|
private generatePattern() {
|
||||||
const pattern = this.requireCanvas();
|
const pattern = this.requireCanvas(true, false);
|
||||||
pattern.setScale(1);
|
pattern.setScale(1);
|
||||||
const img = this.image;
|
const img = this.image;
|
||||||
pattern.size(32, 16);
|
pattern.size(32, 16);
|
||||||
|
@ -461,7 +461,11 @@ export abstract class RenderItem<E extends ERenderItemEvent = ERenderItemEvent>
|
|||||||
*/
|
*/
|
||||||
requireCanvas(alpha: boolean = true, autoScale: boolean = true) {
|
requireCanvas(alpha: boolean = true, autoScale: boolean = true) {
|
||||||
const canvas = new MotaOffscreenCanvas2D(alpha);
|
const canvas = new MotaOffscreenCanvas2D(alpha);
|
||||||
canvas.setScale(this.scale);
|
if (autoScale) {
|
||||||
|
canvas.setScale(this.scale);
|
||||||
|
} else {
|
||||||
|
canvas.setScale(1);
|
||||||
|
}
|
||||||
this.canvases.add(canvas);
|
this.canvases.add(canvas);
|
||||||
this.canvasMap.set(canvas, { autoScale });
|
this.canvasMap.set(canvas, { autoScale });
|
||||||
return canvas;
|
return canvas;
|
||||||
|
Loading…
Reference in New Issue
Block a user