From e9d97b96f04d4660fcba843f6fa5d619acf6433a Mon Sep 17 00:00:00 2001 From: daniellwdb Date: Wed, 22 Feb 2023 09:20:08 +0100 Subject: [PATCH 1/3] feat(plugin-color): export enum for color action names --- packages/jimp/types/test.ts | 2 ++ packages/plugin-color/index.d.ts | 28 +++++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/packages/jimp/types/test.ts b/packages/jimp/types/test.ts index 64ea93155..89e29abba 100644 --- a/packages/jimp/types/test.ts +++ b/packages/jimp/types/test.ts @@ -1,4 +1,5 @@ import * as Jimp from "jimp"; +import { ColorActionName } from "@jimp/plugin-color"; const jimpInst: Jimp = new Jimp("test"); @@ -11,6 +12,7 @@ jimpInst.displace(jimpInst, 2); jimpInst.shadow((err, val, coords) => {}); jimpInst.fishEye({ r: 12 }); jimpInst.circle({ radius: 12, x: 12, y: 12 }); +jimpInst.color([{ apply: ColorActionName.SATURATE, params: [90] }]); // $ExpectError jimpInst.PNG_FILTER_NONE; diff --git a/packages/plugin-color/index.d.ts b/packages/plugin-color/index.d.ts index 9ffc3ece6..bdf6b3f75 100644 --- a/packages/plugin-color/index.d.ts +++ b/packages/plugin-color/index.d.ts @@ -1,16 +1,22 @@ import { ImageCallback } from "@jimp/core"; -type ColorActionName = - | "mix" - | "tint" - | "shade" - | "xor" - | "red" - | "green" - | "blue" - | "hue" - | "lighten" - | "darken"; +export enum ColorActionName { + LIGHTEN = "lighten", + BRIGHTEN = "brighten", + DARKEN = "darken", + DESATURATE = "desaturate", + SATURATE = "saturate", + GREYSCALE = "greyscale", + SPIN = "spin", + HUE = "hue", + MIX = "mix", + TINT = "tint", + SHADE = "shade", + XOR = "xor", + RED = "red", + GREEN = "green", + BLUE = "blue", +} type ColorAction = { apply: ColorActionName; From 88e8e93ba279d4c5949ef255619d31a7f184fb0c Mon Sep 17 00:00:00 2001 From: daniellwdb Date: Thu, 23 Feb 2023 08:44:29 +0100 Subject: [PATCH 2/3] feat(plugin-color): export object for color action names --- packages/plugin-color/src/index.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/plugin-color/src/index.js b/packages/plugin-color/src/index.js index 1531a2a16..89621ec88 100644 --- a/packages/plugin-color/src/index.js +++ b/packages/plugin-color/src/index.js @@ -128,6 +128,24 @@ function colorFn(actions, cb) { return this; } +export const ColorActionName = Object.freeze({ + LIGHTEN: "lighten", + BRIGHTEN: "brighten", + DARKEN: "darken", + DESATURATE: "desaturate", + SATURATE: "saturate", + GREYSCALE: "greyscale", + SPIN: "spin", + HUE: "hue", + MIX: "mix", + TINT: "tint", + SHADE: "shade", + XOR: "xor", + RED: "red", + GREEN: "green", + BLUE: "blue", +}) + export default () => ({ /** * Adjusts the brightness of the image From 22f3f7d7c714a4e775510a97d87cd982f49eaf06 Mon Sep 17 00:00:00 2001 From: daniellwdb Date: Thu, 23 Feb 2023 08:46:04 +0100 Subject: [PATCH 3/3] chore(plugin-color): fix formatting --- packages/plugin-color/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-color/src/index.js b/packages/plugin-color/src/index.js index 89621ec88..82489caa0 100644 --- a/packages/plugin-color/src/index.js +++ b/packages/plugin-color/src/index.js @@ -144,7 +144,7 @@ export const ColorActionName = Object.freeze({ RED: "red", GREEN: "green", BLUE: "blue", -}) +}); export default () => ({ /**