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

View File

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