@versatiles/style 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.MD
CHANGED
|
@@ -191,5 +191,5 @@ Iconsets can be defined in [`scripts/config-sprites.ts`](./scripts/config-sprite
|
|
|
191
191
|
|
|
192
192
|
# Licenses
|
|
193
193
|
|
|
194
|
-
* Sourcecode: [Unlicense](./
|
|
194
|
+
* Sourcecode: [Unlicense](./LICENSE.md)
|
|
195
195
|
* Iconsets and rendered Spritemaps: [CC0 1.0 Universal](./icons/LICENSE.md)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Color from 'color';
|
|
2
2
|
export interface RecolorOptions {
|
|
3
3
|
/** If true, inverts the colors. */
|
|
4
|
-
|
|
4
|
+
invertBrightness?: boolean;
|
|
5
5
|
/** The degree to rotate the hue of the color (in degrees). */
|
|
6
6
|
rotate?: number;
|
|
7
7
|
/** Adjusts the saturation level of the color. Positive values increase saturation, negative values decrease it. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Color from 'color';
|
|
2
2
|
export function getDefaultRecolorFlags() {
|
|
3
3
|
return {
|
|
4
|
-
|
|
4
|
+
invertBrightness: false,
|
|
5
5
|
rotate: 0,
|
|
6
6
|
saturate: 0,
|
|
7
7
|
gamma: 1,
|
|
@@ -14,7 +14,7 @@ export function getDefaultRecolorFlags() {
|
|
|
14
14
|
function isValidRecolorOptions(opt) {
|
|
15
15
|
if (!opt)
|
|
16
16
|
return false;
|
|
17
|
-
if ((opt.
|
|
17
|
+
if ((opt.invertBrightness != null) && opt.invertBrightness)
|
|
18
18
|
return true;
|
|
19
19
|
if ((opt.rotate != null) && (opt.rotate !== 0))
|
|
20
20
|
return true;
|
|
@@ -63,8 +63,8 @@ export class CachedRecolor {
|
|
|
63
63
|
export function recolor(color, opt) {
|
|
64
64
|
if (!isValidRecolorOptions(opt))
|
|
65
65
|
return color;
|
|
66
|
-
if (opt.
|
|
67
|
-
color = color
|
|
66
|
+
if (opt.invertBrightness ?? false)
|
|
67
|
+
color = invert(color);
|
|
68
68
|
if ((opt.rotate !== undefined) && (opt.rotate !== 0))
|
|
69
69
|
color = color.rotate(opt.rotate);
|
|
70
70
|
if ((opt.saturate !== undefined) && (opt.saturate !== 0))
|
|
@@ -78,6 +78,10 @@ export function recolor(color, opt) {
|
|
|
78
78
|
if ((opt.tint !== undefined) && (opt.tintColor !== undefined) && (opt.tint !== 0))
|
|
79
79
|
color = tint(color, opt.tint, Color(opt.tintColor));
|
|
80
80
|
return color;
|
|
81
|
+
function invert(c) {
|
|
82
|
+
c = c.hsl();
|
|
83
|
+
return c.lightness(100 - c.lightness()).rgb();
|
|
84
|
+
}
|
|
81
85
|
function gamma(c, value) {
|
|
82
86
|
if (value < 1e-3)
|
|
83
87
|
value = 1e-3;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Colorful from './colorful.js';
|
|
2
|
+
export default class Eclipse extends Colorful {
|
|
3
|
+
name = 'Eclipse';
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
this.transformDefaultColors(color => {
|
|
7
|
+
color = color.hsl();
|
|
8
|
+
return color.lightness(100 - color.lightness()).rgb();
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
}
|
package/dist/styles/index.d.ts
CHANGED
|
@@ -4,19 +4,23 @@ import type { MaplibreStyle } from '../types/maplibre.js';
|
|
|
4
4
|
import type { RecolorOptions } from '../style_builder/recolor.js';
|
|
5
5
|
export type { MaplibreStyle, RecolorOptions };
|
|
6
6
|
import Colorful from './colorful.js';
|
|
7
|
+
import Eclipse from './eclipse.js';
|
|
7
8
|
import Graybeard from './graybeard.js';
|
|
8
9
|
import Neutrino from './neutrino.js';
|
|
9
10
|
export type ColorfulOptions = StyleBuilderOptions<Colorful>;
|
|
11
|
+
export type EclipseOptions = StyleBuilderOptions<Eclipse>;
|
|
10
12
|
export type GraybeardOptions = StyleBuilderOptions<Graybeard>;
|
|
11
13
|
export type NeutrinoOptions = StyleBuilderOptions<Neutrino>;
|
|
12
|
-
export type SomeOptions = ColorfulOptions | GraybeardOptions | NeutrinoOptions;
|
|
14
|
+
export type SomeOptions = ColorfulOptions | EclipseOptions | GraybeardOptions | NeutrinoOptions;
|
|
13
15
|
type MakeStyle<T extends StyleBuilder<T>, O extends StyleBuilderOptions<T>> = ((options?: O) => MaplibreStyle) & {
|
|
14
16
|
getOptions: () => O;
|
|
15
17
|
};
|
|
16
18
|
export type ColorfulBuilder = MakeStyle<Colorful, ColorfulOptions>;
|
|
19
|
+
export type EclipseBuilder = MakeStyle<Eclipse, EclipseOptions>;
|
|
17
20
|
export type GraybeardBuilder = MakeStyle<Graybeard, GraybeardOptions>;
|
|
18
21
|
export type NeutrinoBuilder = MakeStyle<Neutrino, NeutrinoOptions>;
|
|
19
22
|
export type SomeBuilder = ColorfulBuilder | GraybeardBuilder | NeutrinoBuilder;
|
|
20
23
|
export declare const colorful: ColorfulBuilder;
|
|
24
|
+
export declare const eclipse: EclipseBuilder;
|
|
21
25
|
export declare const graybeard: GraybeardBuilder;
|
|
22
26
|
export declare const neutrino: NeutrinoBuilder;
|
package/dist/styles/index.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
// import styles
|
|
1
2
|
import Colorful from './colorful.js';
|
|
3
|
+
import Eclipse from './eclipse.js';
|
|
2
4
|
import Graybeard from './graybeard.js';
|
|
3
5
|
import Neutrino from './neutrino.js';
|
|
4
|
-
function
|
|
6
|
+
function getStyleBuilder(styleBuilder) {
|
|
5
7
|
const fn = function (options) {
|
|
6
8
|
return new styleBuilder().build(options);
|
|
7
9
|
};
|
|
8
10
|
fn.getOptions = () => new styleBuilder().getDefaultOptions();
|
|
9
11
|
return fn;
|
|
10
12
|
}
|
|
11
|
-
|
|
12
|
-
export const
|
|
13
|
-
export const
|
|
13
|
+
// generate style builders
|
|
14
|
+
export const colorful = getStyleBuilder(Colorful);
|
|
15
|
+
export const eclipse = getStyleBuilder(Eclipse);
|
|
16
|
+
export const graybeard = getStyleBuilder(Graybeard);
|
|
17
|
+
export const neutrino = getStyleBuilder(Neutrino);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versatiles/style",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "Generate StyleJSON for MapLibre",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -46,26 +46,26 @@
|
|
|
46
46
|
"@types/brace-expansion": "^1.1.2",
|
|
47
47
|
"@types/inquirer": "^9.0.7",
|
|
48
48
|
"@types/jest": "^29.5.12",
|
|
49
|
-
"@types/node": "^20.
|
|
49
|
+
"@types/node": "^20.12.4",
|
|
50
50
|
"@types/tar-stream": "^3.1.3",
|
|
51
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
52
|
-
"@typescript-eslint/parser": "^7.
|
|
51
|
+
"@typescript-eslint/eslint-plugin": "^7.5.0",
|
|
52
|
+
"@typescript-eslint/parser": "^7.5.0",
|
|
53
53
|
"@versatiles/container": "^1.2.1",
|
|
54
54
|
"@versatiles/release-tool": "^1.2.2",
|
|
55
55
|
"bin-pack": "^1.0.2",
|
|
56
56
|
"eslint": "^8.57.0",
|
|
57
|
-
"inquirer": "^9.2.
|
|
57
|
+
"inquirer": "^9.2.17",
|
|
58
58
|
"jest": "^29.7.0",
|
|
59
59
|
"jest-environment-jsdom": "^29.7.0",
|
|
60
60
|
"jest-ts-webcompat-resolver": "^1.0.0",
|
|
61
|
-
"npm-check-updates": "^16.14.
|
|
62
|
-
"rollup": "^4.
|
|
61
|
+
"npm-check-updates": "^16.14.18",
|
|
62
|
+
"rollup": "^4.14.0",
|
|
63
63
|
"rollup-plugin-dts": "^6.1.0",
|
|
64
|
-
"sharp": "^0.33.
|
|
64
|
+
"sharp": "^0.33.3",
|
|
65
65
|
"tar-stream": "^3.1.7",
|
|
66
66
|
"ts-jest": "^29.1.2",
|
|
67
67
|
"ts-node": "^10.9.2",
|
|
68
|
-
"tsx": "^4.7.
|
|
69
|
-
"typescript": "^5.
|
|
68
|
+
"tsx": "^4.7.2",
|
|
69
|
+
"typescript": "^5.4.4"
|
|
70
70
|
}
|
|
71
71
|
}
|