From dcafaca1d4b2eba7004676d4bb535d5596172685 Mon Sep 17 00:00:00 2001 From: Bill Date: Wed, 8 Dec 2021 21:19:37 -0500 Subject: [PATCH] Add adjustment filter --- src/nitro/avatar/AvatarImage.ts | 11 +++++++++-- src/nitro/avatar/animation/AvatarDataContainer.ts | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/nitro/avatar/AvatarImage.ts b/src/nitro/avatar/AvatarImage.ts index 9593206e..3cac0682 100644 --- a/src/nitro/avatar/AvatarImage.ts +++ b/src/nitro/avatar/AvatarImage.ts @@ -391,7 +391,14 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener partCount--; } - if(this._avatarSpriteData && this._avatarSpriteData.paletteIsGrayscale) this.convertToGrayscale(container); + if(this._avatarSpriteData) + { + if(!container.filters) container.filters = []; + + if(this._avatarSpriteData.colorTransform) container.filters.push(this._avatarSpriteData.colorTransform); + + if(this._avatarSpriteData.paletteIsGrayscale) this.convertToGrayscale(container); + } if(!cache) { @@ -1019,7 +1026,7 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener colorFilter.matrix = [_local_3, _local_4, _local_5, 0, 0, _local_3, _local_4, _local_5, 0, 0, _local_3, _local_4, _local_5, 0, 0, 0, 0, 0, 1, 0]; - container.filters = [ colorFilter ]; + container.filters.push(colorFilter); return container; } diff --git a/src/nitro/avatar/animation/AvatarDataContainer.ts b/src/nitro/avatar/animation/AvatarDataContainer.ts index 9fef8136..642779a9 100644 --- a/src/nitro/avatar/animation/AvatarDataContainer.ts +++ b/src/nitro/avatar/animation/AvatarDataContainer.ts @@ -48,6 +48,7 @@ export class AvatarDataContainer implements IAvatarDataContainer this._paletteIsGrayscale = false; } + this._colorTransform = new AdjustmentFilter({ red: (this._r / 255), green: (this._g / 255), blue: (this._b / 255), alpha: this._alphaMultiplier }); this._colorMap = this.generatePaletteMapForGrayscale(this._backGround, this._foreGround); }