feat: 元素滤镜

This commit is contained in:
unanmed 2024-08-27 00:29:47 +08:00
parent 8440f222ac
commit 929ca6f18d
2 changed files with 30 additions and 18 deletions

View File

@ -1477,33 +1477,33 @@ maps.prototype.generateGroundPattern = function (floorId) {
maps.prototype.drawMap = function (floorId) { maps.prototype.drawMap = function (floorId) {
floorId = floorId || core.status.floorId; floorId = floorId || core.status.floorId;
if (!floorId) return; if (!floorId) return;
core.clearMap('all'); // core.clearMap('all');
this.generateGroundPattern(floorId); // this.generateGroundPattern(floorId);
core.status.floorId = floorId; core.status.floorId = floorId;
core.extractBlocks(floorId); core.extractBlocks(floorId);
core.status.thisMap = core.status.maps[floorId]; core.status.thisMap = core.status.maps[floorId];
this._drawMap_drawAll(); // this._drawMap_drawAll();
if (core.status.curtainColor) { // if (core.status.curtainColor) {
core.fillRect( // core.fillRect(
'curtain', // 'curtain',
0, // 0,
0, // 0,
core._PX_, // core._PX_,
core._PY_, // core._PY_,
core.arrayToRGBA(core.status.curtainColor) // core.arrayToRGBA(core.status.curtainColor)
); // );
} // }
core.drawHero(); // core.drawHero();
core.updateStatusBar(); core.updateStatusBar();
}; };
////// 重绘某张地图 ////// ////// 重绘某张地图 //////
maps.prototype.redrawMap = function () { maps.prototype.redrawMap = function () {
core.bigmap.canvas.forEach(function (one) { // core.bigmap.canvas.forEach(function (one) {
core.clearMap(one); // core.clearMap(one);
}); // });
this._drawMap_drawAll(null, { redraw: true }); // this._drawMap_drawAll(null, { redraw: true });
core.drawDamage(); core.drawDamage();
}; };

View File

@ -162,6 +162,8 @@ export abstract class RenderItem<E extends ERenderItemEvent = ERenderItemEvent>
antiAliasing: boolean = true; antiAliasing: boolean = true;
/** 是否被隐藏 */ /** 是否被隐藏 */
hidden: boolean = false; hidden: boolean = false;
/** 滤镜 */
filter: string = 'none';
/** 当前元素的父元素 */ /** 当前元素的父元素 */
parent?: RenderItem & IRenderChildable; parent?: RenderItem & IRenderChildable;
@ -226,6 +228,7 @@ export abstract class RenderItem<E extends ERenderItemEvent = ERenderItemEvent>
const ay = -this.anchorY * this.height; const ay = -this.anchorY * this.height;
canvas.ctx.save(); canvas.ctx.save();
canvas.ctx.filter = this.filter;
canvas.setAntiAliasing(this.antiAliasing); canvas.setAntiAliasing(this.antiAliasing);
if (this.type === 'static') transformCanvas(canvas, tran); if (this.type === 'static') transformCanvas(canvas, tran);
if (this.enableCache) { if (this.enableCache) {
@ -257,6 +260,15 @@ export abstract class RenderItem<E extends ERenderItemEvent = ERenderItemEvent>
this.transform.setTranslate(x, y); this.transform.setTranslate(x, y);
} }
/**
*
* @param filter
*/
seyFilter(filter: string) {
this.filter = filter;
this.update(this);
}
setAnchor(x: number, y: number): void { setAnchor(x: number, y: number): void {
this.anchorX = x; this.anchorX = x;
this.anchorY = y; this.anchorY = y;