@ax-design/reveal-highlight 0.4.1 → 0.4.2

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.
@@ -1,58 +1,58 @@
1
- export const extractRGBValue = (x: string) => {
2
- if (x === '') {
3
- return '';
4
- }
5
-
6
- if (x[0] === '#') {
7
- // Thanks bro:
8
- // https://stackoverflow.com/a/11508164/3931936
9
- const hexVal = parseInt(x.substring(1), 16);
10
-
11
- var r = (hexVal >> 16) & 255;
12
- var g = (hexVal >> 8) & 255;
13
- var b = hexVal & 255;
14
-
15
- return r + ',' + g + ',' + b;
16
- } else {
17
- let result = '';
18
- let beginSearch = false;
19
- let numberPointer = 0;
20
-
21
- for (let i = 0; i < x.length; i++) {
22
- const char = x[i];
23
- const charCode = char.charCodeAt(0) - 48;
24
- const charIsNumber = charCode >= 0 && charCode < 10;
25
-
26
- if (char === ' ') {
27
- continue;
28
- }
29
-
30
- if (beginSearch && !charIsNumber && char !== ',' && char !== ')') {
31
- throw new SyntaxError(`${x} is not a validate color value!`);
32
- }
33
-
34
- if (!beginSearch && char === '(') {
35
- beginSearch = true;
36
- continue;
37
- }
38
-
39
- if (numberPointer < 2 && char === ')') {
40
- throw new SyntaxError(`${x} should have at least three color channel`);
41
- }
42
-
43
- if (char === ',') {
44
- numberPointer++;
45
- }
46
-
47
- if (char === ')') {
48
- return result;
49
- }
50
-
51
- if (beginSearch) {
52
- result += char;
53
- }
54
- }
55
-
56
- return result;
57
- }
58
- };
1
+ export const extractRGBValue = (x: string) => {
2
+ if (x === '') {
3
+ return '';
4
+ }
5
+
6
+ if (x[0] === '#') {
7
+ // Thanks bro:
8
+ // https://stackoverflow.com/a/11508164/3931936
9
+ const hexVal = parseInt(x.substring(1), 16);
10
+
11
+ var r = (hexVal >> 16) & 255;
12
+ var g = (hexVal >> 8) & 255;
13
+ var b = hexVal & 255;
14
+
15
+ return r + ',' + g + ',' + b;
16
+ } else {
17
+ let result = '';
18
+ let beginSearch = false;
19
+ let numberPointer = 0;
20
+
21
+ for (let i = 0; i < x.length; i++) {
22
+ const char = x[i];
23
+ const charCode = char.charCodeAt(0) - 48;
24
+ const charIsNumber = charCode >= 0 && charCode < 10;
25
+
26
+ if (char === ' ') {
27
+ continue;
28
+ }
29
+
30
+ if (beginSearch && !charIsNumber && char !== ',' && char !== ')') {
31
+ throw new SyntaxError(`${x} is not a validate color value!`);
32
+ }
33
+
34
+ if (!beginSearch && char === '(') {
35
+ beginSearch = true;
36
+ continue;
37
+ }
38
+
39
+ if (numberPointer < 2 && char === ')') {
40
+ throw new SyntaxError(`${x} should have at least three color channel`);
41
+ }
42
+
43
+ if (char === ',') {
44
+ numberPointer++;
45
+ }
46
+
47
+ if (char === ')') {
48
+ return result;
49
+ }
50
+
51
+ if (beginSearch) {
52
+ result += char;
53
+ }
54
+ }
55
+
56
+ return result;
57
+ }
58
+ };
@@ -1,8 +1,8 @@
1
- import type { BorderDecoration } from './types.js';
2
-
3
- export const isValidateBorderDecorationType = (x: string): x is BorderDecoration => {
4
- if (x === 'round') return true;
5
- if (x === 'bevel') return true;
6
- if (x === 'miter') return true;
7
- return false;
8
- };
1
+ import type { BorderDecoration } from './types.js';
2
+
3
+ export const isValidateBorderDecorationType = (x: string): x is BorderDecoration => {
4
+ if (x === 'round') return true;
5
+ if (x === 'bevel') return true;
6
+ if (x === 'miter') return true;
7
+ return false;
8
+ };
@@ -1,106 +1,106 @@
1
- export type BorderDecoration = 'round' | 'bevel' | 'miter';
2
-
3
- export interface CachedBoundingRect {
4
- top: number;
5
- left: number;
6
- width: number;
7
- height: number;
8
- }
9
-
10
- export interface CachedStyle {
11
- color: string;
12
- opacity: number;
13
- trueFillRadius: [number, number];
14
- borderColor: string;
15
- borderFillRadius: number;
16
- borderDecorationType: BorderDecoration;
17
- borderDecorationRadius: number;
18
- topLeftBorderDecorationRadius: number;
19
- topRightBorderDecorationRadius: number;
20
- bottomLeftBorderDecorationRadius: number;
21
- bottomRightBorderDecorationRadius: number;
22
- /**
23
- * @param withLeftBorderFactor
24
- * If the left border is shown, this value is 1, or the value is 0.
25
- */
26
- withLeftBorderFactor: number;
27
- /**
28
- * @param withRightBorderFactor
29
- * If the right border is shown, this value is 1, or the value is 0.
30
- */
31
- withRightBorderFactor: number;
32
- /**
33
- * @param withTopBorderFactor
34
- * If the top border is shown, this value is 1, or the value is 0.
35
- */
36
- withTopBorderFactor: number;
37
- /**
38
- * @param withBottomBorderFactor
39
- * If the bottom border is shown, this value is 1, or the value is 0.
40
- */
41
- withBottomBorderFactor: number;
42
- borderWidth: number;
43
- hoverLight: boolean;
44
- hoverLightColor: string;
45
- hoverLightFillMode: string;
46
- hoverLightFillRadius: number;
47
- diffuse: boolean;
48
- pressAnimation: boolean;
49
- pressAnimationFillMode: string;
50
- pressAnimationColor: string;
51
- pressAnimationSpeed: number;
52
- releaseAnimationAccelerateRate: number;
53
- }
54
-
55
- interface CachedReveal {
56
- radius: number;
57
- radiusFactor: number;
58
- color: string;
59
- opacity: number;
60
- pattern: CanvasPattern | null;
61
- }
62
-
63
- /**
64
- * Cached border and body pattern, for faster painting on the canvas.
65
- * @interface CachedRevealBitmap
66
- */
67
- export interface CachedRevealBitmap {
68
- cachedReveal: {
69
- borderReveal: CachedReveal;
70
- fillReveal: CachedReveal;
71
- };
72
- cachedCanvas: {
73
- borderReveal: HTMLCanvasElement;
74
- fillReveal: HTMLCanvasElement;
75
- };
76
- cachedCtx: {
77
- borderReveal: CanvasRenderingContext2D | null;
78
- fillReveal: CanvasRenderingContext2D | null;
79
- };
80
- }
81
-
82
- /**
83
- * Cached border and body pattern, just to store something in similar way.
84
- * @interface CachedRevealPath
85
- */
86
- export interface CachedRevealPath {
87
- cachedReveal: {
88
- readonly borderReveal: CachedReveal;
89
- readonly fillReveal: CachedReveal;
90
- };
91
- cachedPath: {
92
- readonly borderReveal: SVGPathElement;
93
- readonly fillReveal: SVGPathElement;
94
- readonly rippleReveal: SVGPathElement;
95
- };
96
- cachedGradient: {
97
- readonly borderReveal: SVGRadialGradientElement;
98
- readonly fillReveal: SVGRadialGradientElement;
99
- readonly rippleReveal: SVGRadialGradientElement;
100
- };
101
- cachedGradientStop: {
102
- readonly borderReveal: Readonly<[SVGStopElement, SVGStopElement]>;
103
- readonly fillReveal: Readonly<[SVGStopElement, SVGStopElement]>;
104
- readonly rippleReveal: Readonly<[SVGStopElement, SVGStopElement, SVGStopElement]>;
105
- };
1
+ export type BorderDecoration = 'round' | 'bevel' | 'miter';
2
+
3
+ export interface CachedBoundingRect {
4
+ top: number;
5
+ left: number;
6
+ width: number;
7
+ height: number;
8
+ }
9
+
10
+ export interface CachedStyle {
11
+ color: string;
12
+ opacity: number;
13
+ trueFillRadius: [number, number];
14
+ borderColor: string;
15
+ borderFillRadius: number;
16
+ borderDecorationType: BorderDecoration;
17
+ borderDecorationRadius: number;
18
+ topLeftBorderDecorationRadius: number;
19
+ topRightBorderDecorationRadius: number;
20
+ bottomLeftBorderDecorationRadius: number;
21
+ bottomRightBorderDecorationRadius: number;
22
+ /**
23
+ * @param withLeftBorderFactor
24
+ * If the left border is shown, this value is 1, or the value is 0.
25
+ */
26
+ withLeftBorderFactor: number;
27
+ /**
28
+ * @param withRightBorderFactor
29
+ * If the right border is shown, this value is 1, or the value is 0.
30
+ */
31
+ withRightBorderFactor: number;
32
+ /**
33
+ * @param withTopBorderFactor
34
+ * If the top border is shown, this value is 1, or the value is 0.
35
+ */
36
+ withTopBorderFactor: number;
37
+ /**
38
+ * @param withBottomBorderFactor
39
+ * If the bottom border is shown, this value is 1, or the value is 0.
40
+ */
41
+ withBottomBorderFactor: number;
42
+ borderWidth: number;
43
+ hoverLight: boolean;
44
+ hoverLightColor: string;
45
+ hoverLightFillMode: string;
46
+ hoverLightFillRadius: number;
47
+ diffuse: boolean;
48
+ pressAnimation: boolean;
49
+ pressAnimationFillMode: string;
50
+ pressAnimationColor: string;
51
+ pressAnimationSpeed: number;
52
+ releaseAnimationAccelerateRate: number;
53
+ }
54
+
55
+ interface CachedReveal {
56
+ radius: number;
57
+ radiusFactor: number;
58
+ color: string;
59
+ opacity: number;
60
+ pattern: CanvasPattern | null;
61
+ }
62
+
63
+ /**
64
+ * Cached border and body pattern, for faster painting on the canvas.
65
+ * @interface CachedRevealBitmap
66
+ */
67
+ export interface CachedRevealBitmap {
68
+ cachedReveal: {
69
+ borderReveal: CachedReveal;
70
+ fillReveal: CachedReveal;
71
+ };
72
+ cachedCanvas: {
73
+ borderReveal: HTMLCanvasElement;
74
+ fillReveal: HTMLCanvasElement;
75
+ };
76
+ cachedCtx: {
77
+ borderReveal: CanvasRenderingContext2D | null;
78
+ fillReveal: CanvasRenderingContext2D | null;
79
+ };
80
+ }
81
+
82
+ /**
83
+ * Cached border and body pattern, just to store something in similar way.
84
+ * @interface CachedRevealPath
85
+ */
86
+ export interface CachedRevealPath {
87
+ cachedReveal: {
88
+ readonly borderReveal: CachedReveal;
89
+ readonly fillReveal: CachedReveal;
90
+ };
91
+ cachedPath: {
92
+ readonly borderReveal: SVGPathElement;
93
+ readonly fillReveal: SVGPathElement;
94
+ readonly rippleReveal: SVGPathElement;
95
+ };
96
+ cachedGradient: {
97
+ readonly borderReveal: SVGRadialGradientElement;
98
+ readonly fillReveal: SVGRadialGradientElement;
99
+ readonly rippleReveal: SVGRadialGradientElement;
100
+ };
101
+ cachedGradientStop: {
102
+ readonly borderReveal: Readonly<[SVGStopElement, SVGStopElement]>;
103
+ readonly fillReveal: Readonly<[SVGStopElement, SVGStopElement]>;
104
+ readonly rippleReveal: Readonly<[SVGStopElement, SVGStopElement, SVGStopElement]>;
105
+ };
106
106
  }
package/src/variables.ts CHANGED
@@ -1 +1 @@
1
- export const MAGIC_DEFAULT_COLOR = 'magic';
1
+ export const MAGIC_DEFAULT_COLOR = 'magic';