@tremolo-ui/functions 0.0.7 → 0.0.9
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/dist/cjs/components/NumberInput/type.js +1 -1
- package/dist/cjs/components/NumberInput/type.js.map +1 -1
- package/dist/cjs/components/NumberInput/types/components/NumberInput/type.d.ts +1 -1
- package/dist/cjs/components/NumberInput/types/components/NumberInput/type.d.ts.map +1 -1
- package/dist/cjs/components/NumberInput/types/components/Slider/type.d.ts +6 -31
- package/dist/cjs/components/NumberInput/types/components/Slider/type.d.ts.map +1 -1
- package/dist/cjs/components/NumberInput/types/math.d.ts +5 -0
- package/dist/cjs/components/NumberInput/types/math.d.ts.map +1 -1
- package/dist/cjs/components/NumberInput/types/midi.d.ts +2 -2
- package/dist/cjs/components/NumberInput/types/midi.d.ts.map +1 -1
- package/dist/cjs/components/NumberInput/types/util.d.ts +4 -0
- package/dist/cjs/components/NumberInput/types/util.d.ts.map +1 -1
- package/dist/cjs/components/Slider/type.js +10 -37
- package/dist/cjs/components/Slider/type.js.map +1 -1
- package/dist/cjs/components/Slider/types/components/NumberInput/type.d.ts +1 -1
- package/dist/cjs/components/Slider/types/components/NumberInput/type.d.ts.map +1 -1
- package/dist/cjs/components/Slider/types/components/Slider/type.d.ts +6 -31
- package/dist/cjs/components/Slider/types/components/Slider/type.d.ts.map +1 -1
- package/dist/cjs/components/Slider/types/math.d.ts +5 -0
- package/dist/cjs/components/Slider/types/math.d.ts.map +1 -1
- package/dist/cjs/components/Slider/types/midi.d.ts +2 -2
- package/dist/cjs/components/Slider/types/midi.d.ts.map +1 -1
- package/dist/cjs/components/Slider/types/util.d.ts +4 -0
- package/dist/cjs/components/Slider/types/util.d.ts.map +1 -1
- package/dist/cjs/index.js +36 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/NumberInput/type.d.ts +1 -1
- package/dist/cjs/types/components/NumberInput/type.d.ts.map +1 -1
- package/dist/cjs/types/components/Slider/type.d.ts +6 -31
- package/dist/cjs/types/components/Slider/type.d.ts.map +1 -1
- package/dist/cjs/types/math.d.ts +5 -0
- package/dist/cjs/types/math.d.ts.map +1 -1
- package/dist/cjs/types/midi.d.ts +2 -2
- package/dist/cjs/types/midi.d.ts.map +1 -1
- package/dist/cjs/types/util.d.ts +4 -0
- package/dist/cjs/types/util.d.ts.map +1 -1
- package/dist/esm/components/NumberInput/type.js +1 -1
- package/dist/esm/components/NumberInput/type.js.map +1 -1
- package/dist/esm/components/NumberInput/types/components/NumberInput/type.d.ts +1 -1
- package/dist/esm/components/NumberInput/types/components/NumberInput/type.d.ts.map +1 -1
- package/dist/esm/components/NumberInput/types/components/Slider/type.d.ts +6 -31
- package/dist/esm/components/NumberInput/types/components/Slider/type.d.ts.map +1 -1
- package/dist/esm/components/NumberInput/types/math.d.ts +5 -0
- package/dist/esm/components/NumberInput/types/math.d.ts.map +1 -1
- package/dist/esm/components/NumberInput/types/midi.d.ts +2 -2
- package/dist/esm/components/NumberInput/types/midi.d.ts.map +1 -1
- package/dist/esm/components/NumberInput/types/util.d.ts +4 -0
- package/dist/esm/components/NumberInput/types/util.d.ts.map +1 -1
- package/dist/esm/components/Slider/type.js +10 -33
- package/dist/esm/components/Slider/type.js.map +1 -1
- package/dist/esm/components/Slider/types/components/NumberInput/type.d.ts +1 -1
- package/dist/esm/components/Slider/types/components/NumberInput/type.d.ts.map +1 -1
- package/dist/esm/components/Slider/types/components/Slider/type.d.ts +6 -31
- package/dist/esm/components/Slider/types/components/Slider/type.d.ts.map +1 -1
- package/dist/esm/components/Slider/types/math.d.ts +5 -0
- package/dist/esm/components/Slider/types/math.d.ts.map +1 -1
- package/dist/esm/components/Slider/types/midi.d.ts +2 -2
- package/dist/esm/components/Slider/types/midi.d.ts.map +1 -1
- package/dist/esm/components/Slider/types/util.d.ts +4 -0
- package/dist/esm/components/Slider/types/util.d.ts.map +1 -1
- package/dist/esm/components/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/index.js +35 -11
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/NumberInput/type.d.ts +1 -1
- package/dist/esm/types/components/NumberInput/type.d.ts.map +1 -1
- package/dist/esm/types/components/Slider/type.d.ts +6 -31
- package/dist/esm/types/components/Slider/type.d.ts.map +1 -1
- package/dist/esm/types/math.d.ts +5 -0
- package/dist/esm/types/math.d.ts.map +1 -1
- package/dist/esm/types/midi.d.ts +2 -2
- package/dist/esm/types/midi.d.ts.map +1 -1
- package/dist/esm/types/util.d.ts +4 -0
- package/dist/esm/types/util.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/NumberInput/type.ts +1 -1
- package/src/components/Slider/type.ts +17 -77
- package/src/math.ts +11 -0
- package/src/midi.ts +18 -15
- package/src/util.ts +8 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../../src/components/NumberInput/type.ts"],"names":[],"mappings":"AAAA;;
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../../src/components/NumberInput/type.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;GAIG;AACH,MAAM,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAA;AAEtC,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAQxE;AAED,wBAAgB,UAAU,CACxB,WAAW,EAAE,MAAM,EACnB,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,EACtB,KAAK,CAAC,EAAE,MAAM,EACd,YAAY,SAAI;;;;EA6CjB;AAID,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,UAShE"}
|
|
@@ -1,35 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Slider
|
|
3
|
-
*/
|
|
4
|
-
export type Horizontal = 'right' | 'left';
|
|
5
|
-
export type Vertical = 'up' | 'down';
|
|
6
|
-
export type Direction = Horizontal | Vertical;
|
|
7
|
-
export declare function isHorizontal(d: Direction): d is "right" | "left";
|
|
8
|
-
export declare function isVertical(d: Direction): d is "up" | "down";
|
|
9
|
-
export declare function isReversed(d: Direction): d is "left" | "up";
|
|
10
|
-
export declare function gradientDirection(d: Direction): "right" | "left" | "top" | "bottom" | undefined;
|
|
3
|
+
*/
|
|
11
4
|
export type ScaleType = 'mark' | 'mark-number' | 'number';
|
|
12
|
-
export type
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
markColor?: string;
|
|
18
|
-
labelColor?: string;
|
|
19
|
-
length?: number | string;
|
|
20
|
-
thickness?: number | string;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
export declare function parseScaleOrderList(scale: ['step', ScaleType] | [number, ScaleType] | ScaleOrderList[] | undefined, min: number, max: number, step: number): ScaleOrderList[];
|
|
24
|
-
export type ScaleOption = {
|
|
25
|
-
/**
|
|
26
|
-
* @default 'mark-number'
|
|
27
|
-
*/
|
|
28
|
-
defaultType?: ScaleType;
|
|
29
|
-
markColor?: string;
|
|
30
|
-
labelColor?: string;
|
|
31
|
-
gap?: number | string;
|
|
32
|
-
labelWidth?: number | string;
|
|
33
|
-
style?: unknown;
|
|
34
|
-
};
|
|
5
|
+
export type ScaleOptions = ['step', ScaleType] | [number, ScaleType];
|
|
6
|
+
export declare function generateOptionsList(options: ScaleOptions, min: number, max: number, step: number): {
|
|
7
|
+
value: number;
|
|
8
|
+
type: ScaleType;
|
|
9
|
+
}[];
|
|
35
10
|
//# sourceMappingURL=type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../../src/components/Slider/type.ts"],"names":[],"mappings":"AAAA;;
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../../src/components/Slider/type.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,aAAa,GAAG,QAAQ,CAAA;AACzD,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;AAEpE,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,YAAY,EACrB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM;WAGH,MAAM;UACP,SAAS;IAYlB"}
|
package/dist/esm/types/math.d.ts
CHANGED
|
@@ -28,6 +28,11 @@ export declare function stepValue(value: number, step: number): number;
|
|
|
28
28
|
* @category Math
|
|
29
29
|
*/
|
|
30
30
|
export declare function toFixed(x: number, fractionDigits?: number): number;
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @category Math
|
|
34
|
+
*/
|
|
35
|
+
export declare function integerPart(x: number | string): string | undefined;
|
|
31
36
|
/**
|
|
32
37
|
*
|
|
33
38
|
* @category Math
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../src/math.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,UAE5D;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,IAAI,SAAI,UAKT;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CACtB,eAAe,EAAE,MAAM,EACvB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,IAAI,SAAI,UAQT;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,UAKZ;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAOpD;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,UAEzD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAElE;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,UAEpC;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,UAEpC;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,UAElC;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,UAEpC"}
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../src/math.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,UAE5D;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,IAAI,SAAI,UAKT;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CACtB,eAAe,EAAE,MAAM,EACvB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,IAAI,SAAI,UAQT;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,UAKZ;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAOpD;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,UAEzD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAKlE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAElE;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,UAEpC;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,UAEpC;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,UAElC;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,UAEpC"}
|
package/dist/esm/types/midi.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const whiteKeys: readonly ["A", "B", "C", "D", "E", "F", "G"];
|
|
|
5
5
|
/**
|
|
6
6
|
* @category MIDI
|
|
7
7
|
*/
|
|
8
|
-
export type WhiteKey = typeof whiteKeys[number];
|
|
8
|
+
export type WhiteKey = (typeof whiteKeys)[number];
|
|
9
9
|
/**
|
|
10
10
|
* @category MIDI
|
|
11
11
|
*/
|
|
@@ -13,7 +13,7 @@ export declare const noteNames: readonly ["C", "C#", "D", "D#", "E", "F", "F#",
|
|
|
13
13
|
/**
|
|
14
14
|
* @category MIDI
|
|
15
15
|
*/
|
|
16
|
-
export type NoteName = typeof noteNames[number];
|
|
16
|
+
export type NoteName = (typeof noteNames)[number];
|
|
17
17
|
/**
|
|
18
18
|
* @category MIDI
|
|
19
19
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"midi.d.ts","sourceRoot":"","sources":["../../../src/midi.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,SAAS,8CAA+C,CAAA;AAErE;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,SAAS,CAAC,MAAM,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"midi.d.ts","sourceRoot":"","sources":["../../../src/midi.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,SAAS,8CAA+C,CAAA;AAErE;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,SAAS,4EAaZ,CAAA;AAEV;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAA;AAEjD;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM;YAKJ,QAAQ;gBACpB,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,EAAE;;EAGzD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,UAK1C;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,UAI1C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,WAW/C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,WAErD;AAED,eAAO,MAAM,UAAU,UAAoD,CAAA"}
|
package/dist/esm/types/util.d.ts
CHANGED
|
@@ -12,5 +12,9 @@ export declare function isEmpty(obj: object): boolean;
|
|
|
12
12
|
* @category Utility
|
|
13
13
|
*/
|
|
14
14
|
export declare function mod(n: number, m: number): number;
|
|
15
|
+
/**
|
|
16
|
+
* @category Utility
|
|
17
|
+
*/
|
|
18
|
+
export declare function xor(a?: boolean, b?: boolean): boolean;
|
|
15
19
|
export {};
|
|
16
20
|
//# sourceMappingURL=util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AAErC;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;AAC3D,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,EAAE,EAAE,QAAQ,EACZ,UAAU,CAAC,EAAE,MAAM,GAClB,MAAM,CAAA;AAwBT;;GAEG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,WAElC;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,UAEvC"}
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AAErC;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;AAC3D,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,EAAE,EAAE,QAAQ,EACZ,UAAU,CAAC,EAAE,MAAM,GAClB,MAAM,CAAA;AAwBT;;GAEG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,WAElC;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,UAEvC;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,UAAQ,EAAE,CAAC,UAAQ,WAEvC"}
|
package/package.json
CHANGED
|
@@ -1,90 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Slider
|
|
3
|
-
*/
|
|
3
|
+
*/
|
|
4
4
|
|
|
5
5
|
import { decimalPart, toFixed } from '../../math'
|
|
6
6
|
|
|
7
|
-
// - | vertical | horizontal
|
|
8
|
-
// - | down | right
|
|
9
|
-
// rev | up | left
|
|
10
|
-
|
|
11
|
-
export type Horizontal = 'right' | 'left'
|
|
12
|
-
export type Vertical = 'up' | 'down'
|
|
13
|
-
export type Direction = Horizontal | Vertical
|
|
14
|
-
|
|
15
|
-
export function isHorizontal(d: Direction) {
|
|
16
|
-
return d == 'right' || d == 'left'
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function isVertical(d: Direction) {
|
|
20
|
-
return d == 'up' || d == 'down'
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function isReversed(d: Direction) {
|
|
24
|
-
return d == 'left' || d == 'up'
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function gradientDirection(d: Direction) {
|
|
28
|
-
if (d == 'left' || d == 'right') return d
|
|
29
|
-
if (d == 'up') return 'top'
|
|
30
|
-
if (d == 'down') return 'bottom'
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// export type SkewFunction = (x: number) => number
|
|
34
|
-
|
|
35
7
|
export type ScaleType = 'mark' | 'mark-number' | 'number'
|
|
36
|
-
export type
|
|
37
|
-
at: number
|
|
38
|
-
type?: ScaleType
|
|
39
|
-
text?: string
|
|
40
|
-
style?: {
|
|
41
|
-
markColor?: string
|
|
42
|
-
labelColor?: string
|
|
43
|
-
length?: number | string
|
|
44
|
-
thickness?: number | string
|
|
45
|
-
}
|
|
46
|
-
}
|
|
8
|
+
export type ScaleOptions = ['step', ScaleType] | [number, ScaleType]
|
|
47
9
|
|
|
48
|
-
export function
|
|
49
|
-
|
|
50
|
-
| ['step', ScaleType]
|
|
51
|
-
| [number, ScaleType]
|
|
52
|
-
| ScaleOrderList[]
|
|
53
|
-
| undefined,
|
|
10
|
+
export function generateOptionsList(
|
|
11
|
+
options: ScaleOptions,
|
|
54
12
|
min: number,
|
|
55
13
|
max: number,
|
|
56
14
|
step: number,
|
|
57
15
|
) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
)
|
|
71
|
-
scalesList.push({ at: at, type: scale[1] })
|
|
72
|
-
}
|
|
16
|
+
const optionsList: {
|
|
17
|
+
value: number
|
|
18
|
+
type: ScaleType
|
|
19
|
+
}[] = []
|
|
20
|
+
const per = options[0] == 'step' ? step : options[0]
|
|
21
|
+
const count = Math.floor(max / per) - Math.ceil(min / per) + 1
|
|
22
|
+
for (let i = 0; i < count; i++) {
|
|
23
|
+
const value = toFixed(
|
|
24
|
+
per * (Math.ceil(min / per) + i),
|
|
25
|
+
decimalPart(per)?.length,
|
|
26
|
+
)
|
|
27
|
+
optionsList.push({ value: value, type: options[1] })
|
|
73
28
|
}
|
|
74
|
-
return
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// TODO: anyにして、それぞれのプロジェクトにあった方法にオーバーライドする
|
|
78
|
-
// style
|
|
79
|
-
|
|
80
|
-
export type ScaleOption = {
|
|
81
|
-
/**
|
|
82
|
-
* @default 'mark-number'
|
|
83
|
-
*/
|
|
84
|
-
defaultType?: ScaleType
|
|
85
|
-
markColor?: string
|
|
86
|
-
labelColor?: string
|
|
87
|
-
gap?: number | string
|
|
88
|
-
labelWidth?: number | string
|
|
89
|
-
style?: unknown
|
|
29
|
+
return optionsList
|
|
90
30
|
}
|
package/src/math.ts
CHANGED
|
@@ -74,6 +74,17 @@ export function toFixed(x: number, fractionDigits?: number) {
|
|
|
74
74
|
return Number(x.toFixed(fractionDigits))
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* @category Math
|
|
80
|
+
*/
|
|
81
|
+
export function integerPart(x: number | string): string | undefined {
|
|
82
|
+
if (Number.isNaN(x)) {
|
|
83
|
+
return undefined
|
|
84
|
+
}
|
|
85
|
+
return String(x).split('.')[0]
|
|
86
|
+
}
|
|
87
|
+
|
|
77
88
|
/**
|
|
78
89
|
*
|
|
79
90
|
* @category Math
|
package/src/midi.ts
CHANGED
|
@@ -8,18 +8,30 @@ export const whiteKeys = ['A', 'B', 'C', 'D', 'E', 'F', 'G'] as const
|
|
|
8
8
|
/**
|
|
9
9
|
* @category MIDI
|
|
10
10
|
*/
|
|
11
|
-
export type WhiteKey = typeof whiteKeys[number]
|
|
11
|
+
export type WhiteKey = (typeof whiteKeys)[number]
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @category MIDI
|
|
15
15
|
*/
|
|
16
|
-
export const noteNames = [
|
|
16
|
+
export const noteNames = [
|
|
17
|
+
'C',
|
|
18
|
+
'C#',
|
|
19
|
+
'D',
|
|
20
|
+
'D#',
|
|
21
|
+
'E',
|
|
22
|
+
'F',
|
|
23
|
+
'F#',
|
|
24
|
+
'G',
|
|
25
|
+
'G#',
|
|
26
|
+
'A',
|
|
27
|
+
'A#',
|
|
28
|
+
'B',
|
|
29
|
+
] as const
|
|
17
30
|
|
|
18
31
|
/**
|
|
19
32
|
* @category MIDI
|
|
20
33
|
*/
|
|
21
|
-
export type NoteName = typeof noteNames[number]
|
|
22
|
-
|
|
34
|
+
export type NoteName = (typeof noteNames)[number]
|
|
23
35
|
|
|
24
36
|
/**
|
|
25
37
|
* @category MIDI
|
|
@@ -40,11 +52,7 @@ export function parseNoteName(noteName: string) {
|
|
|
40
52
|
* @category MIDI
|
|
41
53
|
*/
|
|
42
54
|
export function noteNumber(noteName: string) {
|
|
43
|
-
const {
|
|
44
|
-
letter,
|
|
45
|
-
accidental,
|
|
46
|
-
octave,
|
|
47
|
-
} = parseNoteName(noteName)
|
|
55
|
+
const { letter, accidental, octave } = parseNoteName(noteName)
|
|
48
56
|
const noteIndex = noteNames.indexOf(letter.toLocaleUpperCase() as NoteName)
|
|
49
57
|
const accidentalValue = (accidental[0] == 'b' ? -1 : 1) * accidental.length
|
|
50
58
|
return noteIndex + 12 * (Number(octave) + 1) + accidentalValue
|
|
@@ -83,9 +91,4 @@ export function isBlackKey(noteNumber: number | string) {
|
|
|
83
91
|
return !isWhiteKey(noteNumber)
|
|
84
92
|
}
|
|
85
93
|
|
|
86
|
-
export const scaleNames = [
|
|
87
|
-
'major',
|
|
88
|
-
'minor',
|
|
89
|
-
'natural minor',
|
|
90
|
-
'pentatonic',
|
|
91
|
-
]
|
|
94
|
+
export const scaleNames = ['major', 'minor', 'natural minor', 'pentatonic']
|
package/src/util.ts
CHANGED
|
@@ -43,5 +43,12 @@ export function isEmpty(obj: object) {
|
|
|
43
43
|
* @category Utility
|
|
44
44
|
*/
|
|
45
45
|
export function mod(n: number, m: number) {
|
|
46
|
-
return ((
|
|
46
|
+
return ((n % m) + m) % m
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @category Utility
|
|
51
|
+
*/
|
|
52
|
+
export function xor(a = false, b = false) {
|
|
53
|
+
return (a || b) && a != b
|
|
47
54
|
}
|