Skip to content

Commit

Permalink
Export ColorActionName enum (#1205)
Browse files Browse the repository at this point in the history
* feat(plugin-color): export enum for color action names

* feat(plugin-color): export object for color action names

* chore(plugin-color): fix formatting
  • Loading branch information
daniellwdb authored Feb 24, 2023
1 parent 8360424 commit 3236973
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 11 deletions.
2 changes: 2 additions & 0 deletions packages/jimp/types/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as Jimp from "jimp";
import { ColorActionName } from "@jimp/plugin-color";

const jimpInst: Jimp = new Jimp("test");

Expand All @@ -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;

Expand Down
28 changes: 17 additions & 11 deletions packages/plugin-color/index.d.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
18 changes: 18 additions & 0 deletions packages/plugin-color/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3236973

Please sign in to comment.