From 186b4737c664d302db659f74c094624c737c57cd Mon Sep 17 00:00:00 2001 From: Aabhushan Gautam Date: Tue, 31 Oct 2023 21:25:34 +0545 Subject: [PATCH 1/2] Feat: Added missing templates: Jail, Bed and Colorfy --- src/assets/TemplateFactory.ts | 89 +++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/src/assets/TemplateFactory.ts b/src/assets/TemplateFactory.ts index 9558fec..662ac03 100644 --- a/src/assets/TemplateFactory.ts +++ b/src/assets/TemplateFactory.ts @@ -499,5 +499,94 @@ export const TemplateFactory = { return ret; })() }; + }), + Colorfy: createTemplate((image: ImageSource, color: string) => { + return { + steps: [ + { + image: [ + { + source: new TemplateImage(image), + x: 0, + y: 0 + } + ] + }, + { + preprocess(canvas, ctx) { + ctx.fillStyle = color; + ctx.fillRect(0, 0, canvas.width, canvas.height); + } + } + ] + }; + }), + Jail: createTemplate((image: ImageSource, greyscale?: boolean) => { + return { + steps: [ + { + image: [ + { + source: new TemplateImage(ImageFactory.JAIL), + x: 0, + y: 0 + } + ] + }, + { + image: [ + { + source: new TemplateImage(image), + x: 0, + y: 0, + width: 256, + height: 256, + postprocess(canvas, ctx) { + if (greyscale) { + ctx.filter = 'grayscale(100%)'; + } + } + } + ] + } + ] + }; + }), + Bed: createTemplate((image1: ImageSource, image2: ImageSource) => { + return { + steps: [ + { + image: [ + { + source: new TemplateImage(ImageFactory.BED), + x: 0, + y: 0 + } + ] + }, + { + image: [ + { + source: new TemplateImage(image1), + x: 0, + y: 0, + width: 256, + height: 256 + } + ] + }, + { + image: [ + { + source: new TemplateImage(image2), + x: 256, + y: 0, + width: 256, + height: 256 + } + ] + } + ] + }; }) }; From ecf6e65666109e5252862f45954d38bc8e2aafab Mon Sep 17 00:00:00 2001 From: Abhushan Gautam Date: Tue, 31 Oct 2023 21:37:10 +0545 Subject: [PATCH 2/2] Update src/assets/TemplateFactory.ts Co-authored-by: Archaeopteryx <46562212+twlite@users.noreply.github.com> --- src/assets/TemplateFactory.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/assets/TemplateFactory.ts b/src/assets/TemplateFactory.ts index 662ac03..3ebede5 100644 --- a/src/assets/TemplateFactory.ts +++ b/src/assets/TemplateFactory.ts @@ -514,6 +514,7 @@ export const TemplateFactory = { }, { preprocess(canvas, ctx) { + ctx.globalCompositeOperation = 'color'; ctx.fillStyle = color; ctx.fillRect(0, 0, canvas.width, canvas.height); }