@phun-ky/moebius 2.0.27 → 2.0.29

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
@@ -1,35 +1,16 @@
1
- # @phun-ky/moebius `möbius`
1
+ # `möbius`
2
2
 
3
- ![logo](./public/images/logo/logo-ring.png)
3
+ ![logo](./docs/public/logo/logo-ring.png)
4
4
 
5
5
  > Generate harmonious, customizable color palettes from a single base color - instantly and programmatically.
6
6
 
7
7
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-green.svg)](http://makeapullrequest.com) [![SemVer 2.0](https://img.shields.io/badge/SemVer-2.0-green.svg)](http://semver.org/spec/v2.0.0.html) ![npm version](https://img.shields.io/npm/v/@phun-ky/moebius) ![issues](https://img.shields.io/github/issues/phun-ky/moebius) ![license](https://img.shields.io/npm/l/@phun-ky/moebius) ![size](https://img.shields.io/bundlephobia/min/@phun-ky/moebius) ![npm](https://img.shields.io/npm/dm/%40phun-ky/moebius) ![GitHub Repo stars](https://img.shields.io/github/stars/phun-ky/moebius) [![codecov](https://codecov.io/gh/phun-ky/moebius/graph/badge.svg?token=VA91DL7ZLZ)](https://codecov.io/gh/phun-ky/moebius) [![build](https://github.com/phun-ky/moebius/actions/workflows/check.yml/badge.svg)](https://github.com/phun-ky/moebius/actions/workflows/check.yml)
8
8
 
9
- - [@phun-ky/moebius `möbius`](#phun-kymoebius-möbius)
9
+ - [`möbius`](#möbius)
10
10
  - [About](#about)
11
11
  - [Features](#features)
12
- - [Demo](#demo)
13
- - [Install](#install)
14
- - [Full API-reference](#full-api-reference)
15
- - [Usage](#usage)
16
- - [Creating palettes](#creating-palettes)
17
- - [Default options](#default-options)
18
- - [Interpolate](#interpolate)
19
- - [Luminance shift](#luminance-shift)
20
- - [Monochromatic](#monochromatic)
21
- - [Complement](#complement)
22
- - [Split](#split)
23
- - [Triadic](#triadic)
24
- - [Tetradic](#tetradic)
25
- - [Pentadic](#pentadic)
26
- - [Hexadic](#hexadic)
27
- - [Analogous](#analogous)
28
- - [Get color objects](#get-color-objects)
29
- - [toString](#tostring)
30
- - [toObject](#toobject)
31
- - [toFloat](#tofloat)
32
- - [Types](#types)
12
+ - [Documentation](#documentation)
13
+ - [Try it online](#try-it-online)
33
14
  - [Contributing](#contributing)
34
15
  - [License](#license)
35
16
  - [Changelog](#changelog)
@@ -37,7 +18,7 @@
37
18
 
38
19
  ## About
39
20
 
40
- Möbius is a color palette generation tool designed for developers and designers who need quick, consistent, and attractive color schemes. It supports a wide variety of palette types and exports color data in multiple formats RGB, HSL, LAB, CMYK, and more - making it ideal for both web design and data visualization.
21
+ Möbius is a color palette generation tool designed for developers and designers who need quick, consistent, and attractive color schemes. It supports a wide variety of palette types and exports color data in multiple formats - RGB, HSL, LAB, CMYK, and more - making it ideal for both web design and data visualization.
41
22
 
42
23
  ## Features
43
24
 
@@ -50,383 +31,13 @@ Möbius is a color palette generation tool designed for developers and designers
50
31
  - Diverging palette support
51
32
  - TypeScript-friendly API
52
33
 
53
- ## Demo
34
+ ## Documentation
54
35
 
55
- You can check out a working CodePen where you can [adjust settings and colors here](https://codepen.io/phun-ky/full/LYqQMqL), or the website [moebius.wtf](https://moebius.wtf/).
36
+ Checkout the documentation at [https://phun-ky.net/moebius/](https://https://phun-ky.net/moebius/).
56
37
 
57
- ## Install
38
+ ## Try it online
58
39
 
59
- ```shell-session
60
- npm i -S @phun-ky/moebius
61
- ```
62
-
63
- ## Full API-reference
64
-
65
- You can find the full API documentation [here](https://github.com/phun-ky/moebius/blob/main/api/README.md).
66
-
67
- ## Usage
68
-
69
- Import and run the required function:
70
-
71
- ```ts
72
- import Moebius from '@phun-ky/moebius';
73
-
74
- const { MoebiusColor, MoebiusPalettes } = await Moebius();
75
-
76
- const palette = new MoebiusPalettes({
77
- baseColor: new MoebiusColor('#1e90ff')
78
- });
79
-
80
- console.log(palette.colors.interpolate); // ['#1e90ff', '#3298d8', ...]
81
- ```
82
-
83
- ### Creating palettes
84
-
85
- The main feature is the ability to create palettes with a given primary color and a secondary color (used for diverging palettes). You can also give the color to diverge to/from.
86
-
87
- #### Default options
88
-
89
- ```ts
90
- const defaultOptions = {
91
- diverging: false,
92
- bezier: false,
93
- randomOffset: false,
94
- correctLightness: false,
95
- noDuplicates: true,
96
- colorScaleMode: 'lch',
97
- reverseDirection: false,
98
- divergentColor: '#f5f5f5'
99
- };
100
- ```
101
-
102
- You initiate `MoebiusPalette` like this:
103
-
104
- ```ts
105
- import Moebius from '@phun-ky/moebius';
106
-
107
- const { MoebiusPalette, MoebiusColor } = await Moebius();
108
-
109
- const palettes = new MoebiusPalettes({
110
- baseColor: new MoebiusColor('#003f5c'),
111
- secondaryColor: new MoebiusColor('#ff9900'),
112
- ...options
113
- });
114
- ```
115
-
116
- And then you can enjoy your palettes!
117
-
118
- #### Interpolate
119
-
120
- ```ts
121
- console.log(palettes.colors.interpolate);
122
- /*
123
- [
124
- "#003f5c",
125
- "#2b4e4d",
126
- "#555d3d",
127
- "#806c2e",
128
- "#aa7b1f",
129
- "#d58a0f",
130
- "#ff9900"
131
- ]
132
- */
133
- ```
134
-
135
- Gives you an array of hex-colors.
136
-
137
- ![logo](./public/images/interpolate.png)
138
-
139
- #### Luminance shift
140
-
141
- ```ts
142
- console.log(palettes.colors.luminanceShift);
143
- /*
144
- [
145
- "#003f5c",
146
- "#5f8bac",
147
- "#b3dff2",
148
- "#f5f5f5",
149
- "#fcb852",
150
- "#d17300",
151
- "#762800"
152
- ]
153
- */
154
- ```
155
-
156
- Gives you an array of hex-colors.
157
- ![logo](./public/images/luminance-shift.png)
158
-
159
- If you diverge them, it could look like this:
160
- ![logo](./public/images/luminance-shift-diverging.png)
161
-
162
- #### Monochromatic
163
-
164
- ```ts
165
- console.log(palettes.colors.monochromatic);
166
- /*
167
- [
168
- "#003f5c",
169
- "#003342",
170
- "#002329",
171
- "#000e0f",
172
- "#000000"
173
- ]
174
- */
175
- ```
176
-
177
- Gives you an array of hex-colors.
178
- ![logo](./public/images/monochromatic.png)
179
-
180
- #### Complement
181
-
182
- ```ts
183
- console.log(palettes.colors.complement);
184
- /*
185
- [
186
- "#003f5c",
187
- "#0f394d",
188
- "#1f343d",
189
- "#2e2e2e",
190
- "#3d281f",
191
- "#4d230f",
192
- "#5c1d00"
193
- ]
194
- */
195
- ```
196
-
197
- Gives you an array of hex-colors.
198
- ![logo](./public/images/complement.png)
199
-
200
- #### Split
201
-
202
- ```ts
203
- console.log(palettes.colors.split);
204
- /*
205
- [
206
- "#003f5c",
207
- "#1f2a43",
208
- "#3d152a",
209
- "#5c0011",
210
- "#5c190b",
211
- "#5c3206",
212
- "#5c4b00"
213
- ]
214
- */
215
- ```
216
-
217
- Gives you an array of hex-colors.
218
- ![logo](./public/images/split.png)
219
-
220
- #### Triadic
221
-
222
- ```ts
223
- console.log(palettes.colors.triadic);
224
- /*
225
- [
226
- "#003f5c",
227
- "#1f2a52",
228
- "#3d1549",
229
- "#5c003f",
230
- "#521f2a",
231
- "#493d15",
232
- "#3f5c00"
233
- ]
234
- */
235
- ```
236
-
237
- Gives you an array of hex-colors.
238
- ![logo](./public/images/triadic.png)
239
-
240
- #### Tetradic
241
-
242
- ```ts
243
- console.log(palettes.colors.tetradic);
244
- /*
245
- [
246
- "#003f5c",
247
- "#26205c",
248
- "#4b005c",
249
- "#540f2e",
250
- "#5c1d00",
251
- "#363d00",
252
- "#115c00"
253
- ]
254
- */
255
- ```
256
-
257
- Gives you an array of hex-colors.
258
- ![logo](./public/images/tetradic.png)
259
-
260
- #### Pentadic
261
-
262
- ```ts
263
- console.log(palettes.colors.pentadic);
264
- /*
265
- [
266
- "#003f5c",
267
- "#2e203b",
268
- "#5c001a",
269
- "#5c2a0d",
270
- "#5c5400",
271
- "#2e5806",
272
- "#005c0b"
273
- ]
274
- */
275
- ```
276
-
277
- Gives you an array of hex-colors.
278
- ![logo](./public/images/pentadic.png)
279
-
280
- #### Hexadic
281
-
282
- ```ts
283
- console.log(palettes.colors.hexadic);
284
- /*
285
- [
286
- "#003f5c",
287
- "#3d1549",
288
- "#5c0a2a",
289
- "#5c1d00",
290
- "#494700",
291
- "#2a5c0a",
292
- "#005c1d"
293
- ]
294
- */
295
- ```
296
-
297
- Gives you an array of hex-colors.
298
- ![logo](./public/images/hexadic.png)
299
-
300
- #### Analogous
301
-
302
- ```ts
303
- console.log(palettes.colors.interpolate);
304
- /*
305
- [
306
- "#003f5c",
307
- "#00285c",
308
- "#00115c",
309
- "#0f085c",
310
- "#1d005c",
311
- "#34005c",
312
- "#4b005c"
313
- ]
314
- */
315
- ```
316
-
317
- Gives you an array of hex-colors.
318
- ![logo](./public/images/analogous.png)
319
-
320
- ### Get color objects
321
-
322
- ```ts
323
- import Moebius from '@phun-ky/moebius';
324
-
325
- const { MoebiusColor } = await Moebius();
326
-
327
- //
328
- const color = new MoebiusColor('#003f5c');
329
-
330
- console.log(color.hsl); // hsl(199, 100%, 18%);
331
- ```
332
-
333
- This will make available a color object with all of the colors readily converted and ready to use. This is an example output of the color object:
334
-
335
- ```json
336
- {
337
- "color": "#003f5c",
338
- "name": "Maniac Mansion",
339
- "hex": "#003f5c",
340
- "rgb": "rgb(0, 63, 92)",
341
- "hsl": {
342
- "h": 199,
343
- "s": 100,
344
- "l": 18
345
- },
346
- "hwb": {
347
- "h": 0.45,
348
- "w": 0,
349
- "b": 0.64
350
- },
351
- "hsv": {
352
- "h": 198.91,
353
- "s": 1,
354
- "v": 0.36
355
- },
356
- "lab": {
357
- "l": 24.72,
358
- "a": -5.95,
359
- "b": -22.26
360
- },
361
- "xyz": {
362
- "x": 0.37,
363
- "y": 0.43,
364
- "z": 0.38
365
- },
366
- "lch": {
367
- "l": 24.72,
368
- "c": 23.04,
369
- "h": 255.03
370
- },
371
- "oklch": {
372
- "l": 0.35,
373
- "c": 0.08,
374
- "h": 236.65
375
- },
376
- "hsi": {
377
- "h": 197.96,
378
- "s": 1,
379
- "i": 0.2
380
- },
381
- "oklab": {
382
- "l": 0.35,
383
- "a": -0.04,
384
- "b": -0.06
385
- },
386
- "cmyk": {
387
- "c": 100,
388
- "m": 0,
389
- "y": 32,
390
- "k": 64
391
- }
392
- }
393
- ```
394
-
395
- #### toString
396
-
397
- For the non-CSS units, the color object also exposes a `toString` method pr unit:
398
-
399
- ```ts
400
- const color = new MoebiusColor('#003f5c');
401
-
402
- console.log(color.hsl.toString()); // "199, 100, 18"
403
- ```
404
-
405
- #### toObject
406
-
407
- The color object exposes a `toObject` method, that allows to objectify from any color unit given to either a color object for the hsl units, or default rgb:
408
-
409
- ```ts
410
- const color = new MoebiusColor('#003f5c');
411
-
412
- console.log(color.toObject('hsl')); // "199, 100, 18"
413
- console.log(color.toObject(); // "0, 63, 92"
414
- ```
415
-
416
- #### toFloat
417
-
418
- The color object exposes a `toFloat` method, that allows to objectify to float values, as in `0-1` instead of `0-255`/`0-100` from any color unit given to either a color object for the hsl units, or default rgb:
419
-
420
- ```ts
421
- const color = new MoebiusColor('#003f5c');
422
-
423
- console.log(color.toFloat('hsl')); // "199, 1, 0.18"
424
- console.log(color.toFloat(); // "0, 0.25, 0.36"
425
- ```
426
-
427
- ### Types
428
-
429
- Types can be found in `@phun-ky/moebius/moebius.d.ts`.
40
+ You can check out the online-generator at [moebius.wtf](https://moebius.wtf/).
430
41
 
431
42
  ## Contributing
432
43
 
@@ -448,6 +59,6 @@ The sponsorship is an unique opportunity to alleviate more hours for me to maint
448
59
 
449
60
  [Support me on GitHub Sponsors](https://github.com/sponsors/phun-ky).
450
61
 
451
- ![logo](./public/images/logo/logo-ring.png)
62
+ ![logo](./docs/public/logo/logo-ring.png)
452
63
 
453
64
  p.s. **Ukraine is still under brutal Russian invasion. A lot of Ukrainian people are hurt, without shelter and need help**. You can help in various ways, for instance, directly helping refugees, spreading awareness, putting pressure on your local government or companies. You can also support Ukraine by donating e.g. to [Red Cross](https://www.icrc.org/en/donate/ukraine), [Ukraine humanitarian organisation](https://savelife.in.ua/en/donate-en/#donate-army-card-weekly) or [donate Ambulances for Ukraine](https://www.gofundme.com/f/help-to-save-the-lives-of-civilians-in-a-war-zone).
package/dist/moebius.d.ts CHANGED
@@ -52,8 +52,8 @@ declare class MoebiusColor implements MoebiusColorInterface {
52
52
  declare class MoebiusPalettes implements MoebiusPaletteInterface {
53
53
  baseColor: MoebiusColorInterface;
54
54
  secondaryColor: MoebiusColorInterface;
55
- colors: Record<string, unknown> | MoebiusPaletteColorsInterface;
56
- themes: Record<string, unknown> | MoebiusThemeColorsInterface;
55
+ colors: MoebiusPaletteColorsInterface;
56
+ themes: MoebiusThemeColorsInterface;
57
57
  defaultOptions: MoebiusPaletteDefaultOptionsType;
58
58
  options: MoebiusPaletteOptionsType;
59
59
  all: MoebiusColorValueHexType[];
@@ -228,7 +228,7 @@ declare class MoebiusPalettes implements MoebiusPaletteInterface {
228
228
  * console.log(interpolatedPalette); // ['#3498db', '#5d6d7e', '#8473a9', '#ad7a95', '#db3434']
229
229
  * ```
230
230
  */
231
- interpolate(primaryColor: MoebiusColorValueHexType, secondaryColor: MoebiusColorValueHexType, options?: Record<string, unknown> | MoebiusPaletteOptionsType): MoebiusColorValueHexType[];
231
+ interpolate(primaryColor: MoebiusColorValueHexType, secondaryColor: MoebiusColorValueHexType, options?: MoebiusPaletteOptionsType): MoebiusColorValueHexType[];
232
232
  /**
233
233
  * Generate a luminance shift palette based on an array of colors, with optional diverging colors.
234
234
  *
@@ -251,7 +251,7 @@ declare class MoebiusPalettes implements MoebiusPaletteInterface {
251
251
  * console.log(luminanceShiftPalette); // ['#3498db', '#99db34', '#dbd134', '#db3434', '#8f34db']
252
252
  * ```
253
253
  */
254
- luminanceShift(colors: MoebiusColorValueHexType[], divergingColors?: MoebiusColorValueHexType[], options?: Record<string, unknown> | MoebiusPaletteOptionsType): MoebiusColorValueHexType[];
254
+ luminanceShift(colors: MoebiusColorValueHexType[], divergingColors?: MoebiusColorValueHexType[], options?: MoebiusPaletteOptionsType): MoebiusColorValueHexType[];
255
255
  /**
256
256
  * Generates a monochromatic color palette based on the given color.
257
257
  * @param {MoebiusChromaColorInputType} color - The base color for the palette.
@@ -317,6 +317,8 @@ declare class MoebiusSVGHelper {
317
317
  getColorPiePaths(colors: MoebiusColorValueHexType[][], size?: number): DocumentFragment;
318
318
  }
319
319
 
320
+ type MoebiusInterpolationMode = 'hcl' | 'hsi' | 'hsl' | 'hsv' | 'lab' | 'lch' | 'lrgb' | 'oklab' | 'oklch' | 'rgb';
321
+ type MoebiusPaletteType = 'protanomaly' | 'protanopia' | 'deuteranomaly' | 'deuteranopia' | 'tritanomaly' | 'tritanopia' | 'achromatomaly' | 'achromatopsia';
320
322
  /**
321
323
  * Represents a color object with various color representations.
322
324
  */
@@ -352,8 +354,8 @@ type MoebiusReturnType = Promise<{
352
354
  interface MoebiusPaletteInterface {
353
355
  baseColor: MoebiusColorInterface;
354
356
  secondaryColor: MoebiusColorInterface;
355
- colors: Record<string, unknown> | MoebiusPaletteColorsInterface;
356
- themes: Record<string, unknown> | MoebiusThemeColorsInterface;
357
+ colors?: MoebiusPaletteColorsInterface;
358
+ themes?: MoebiusThemeColorsInterface;
357
359
  defaultOptions: MoebiusPaletteDefaultOptionsType;
358
360
  options: MoebiusPaletteOptionsType;
359
361
  all: MoebiusColorValueHexType[];
@@ -407,7 +409,7 @@ type MoebiusPaletteOptionsType = {
407
409
  randomOffset?: boolean;
408
410
  correctLightness?: boolean;
409
411
  noDuplicates?: boolean;
410
- colorScaleMode?: string;
412
+ colorScaleMode?: MoebiusInterpolationMode;
411
413
  divergingColor?: string;
412
414
  reverseDirection?: boolean;
413
415
  numberOfColors?: number;
@@ -422,7 +424,7 @@ type MoebiusPaletteDefaultOptionsType = {
422
424
  randomOffset: boolean;
423
425
  correctLightness: boolean;
424
426
  noDuplicates: boolean;
425
- colorScaleMode: string;
427
+ colorScaleMode: MoebiusInterpolationMode;
426
428
  reverseDirection: boolean;
427
429
  numberOfColors?: number;
428
430
  };
@@ -539,6 +541,23 @@ interface NearestColorColorMatchInterface {
539
541
  * Input types accepted by Chroma or Moebius logic.
540
542
  */
541
543
  type MoebiusChromaColorInputType = MoebiusCMYKObjectType | MoebiusLCHObjectType | MoebiusHSLObjectType | MoebiusColorValueHexType | string;
544
+ /**
545
+ * Represents the mouse event object for an element.
546
+ * @template T - Type of the element used as a target.
547
+ */
548
+ type MouseEventType<T> = MouseEvent & {
549
+ target: T & {
550
+ files?: FileList | null;
551
+ id: string;
552
+ parentElement: Element | null;
553
+ value?: string | null;
554
+ };
555
+ offsetX?: number;
556
+ offsetY?: number;
557
+ currentTarget: HTMLElement & {
558
+ documentElement: HTMLElement;
559
+ };
560
+ };
542
561
 
543
562
  /**
544
563
  * Initializes and returns Moebius utilities with dynamic color naming support.
@@ -563,4 +582,4 @@ declare function Moebius(): MoebiusReturnType;
563
582
  //# sourceMappingURL=main.d.ts.map
564
583
 
565
584
  export { Moebius as default };
566
- export type { MoebiusCMYKObjectType, MoebiusChromaColorInputType, MoebiusColorInterface, MoebiusColorValueHexType, MoebiusColorValueHslType, MoebiusColorValueHslaType, MoebiusColorValueRgbType, MoebiusColorValueRgbaType, MoebiusHSIObjectType, MoebiusHSLObjectType, MoebiusHSVObjectType, MoebiusHWBObjectType, MoebiusLABObjectType, MoebiusLCHObjectType, MoebiusPaletteAccentColorsInterface, MoebiusPaletteColorsInterface, MoebiusPaletteDefaultOptionsType, MoebiusPaletteInterface, MoebiusPaletteOptionsType, MoebiusRGBObjectType, MoebiusReturnType, MoebiusThemeColorsInterface, MoebiusXYZObjectType, NearestColorColorMatchInterface, NearestColorColorSpecInterface };
585
+ export type { MoebiusCMYKObjectType, MoebiusChromaColorInputType, MoebiusColorInterface, MoebiusColorValueHexType, MoebiusColorValueHslType, MoebiusColorValueHslaType, MoebiusColorValueRgbType, MoebiusColorValueRgbaType, MoebiusHSIObjectType, MoebiusHSLObjectType, MoebiusHSVObjectType, MoebiusHWBObjectType, MoebiusInterpolationMode, MoebiusLABObjectType, MoebiusLCHObjectType, MoebiusPaletteAccentColorsInterface, MoebiusPaletteColorsInterface, MoebiusPaletteDefaultOptionsType, MoebiusPaletteInterface, MoebiusPaletteOptionsType, MoebiusPaletteType, MoebiusRGBObjectType, MoebiusReturnType, MoebiusThemeColorsInterface, MoebiusXYZObjectType, MouseEventType, NearestColorColorMatchInterface, NearestColorColorSpecInterface };