@tetrax/squircle 1.0.0 → 1.0.1
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/core.d.mts +68 -68
- package/dist/core.d.ts +68 -68
- package/dist/core.js +629 -629
- package/dist/core.mjs +599 -599
- package/dist/react/index.d.mts +21 -21
- package/dist/react/index.d.ts +21 -21
- package/dist/react/index.js +809 -809
- package/dist/react/index.mjs +773 -773
- package/dist/react-native/index.d.ts +18 -18
- package/dist/react-native/index.js +360 -360
- package/dist/react-native/index.mjs +325 -325
- package/package.json +1 -1
package/dist/core.d.mts
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
interface SquirclePathParams {
|
|
2
|
-
width: number;
|
|
3
|
-
height: number;
|
|
4
|
-
cornerRadius?: number;
|
|
5
|
-
topLeftCornerRadius?: number;
|
|
6
|
-
topRightCornerRadius?: number;
|
|
7
|
-
bottomRightCornerRadius?: number;
|
|
8
|
-
bottomLeftCornerRadius?: number;
|
|
9
|
-
cornerSmoothing?: number;
|
|
10
|
-
preserveSmoothing?: boolean;
|
|
11
|
-
g2Continuous?: boolean;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Generate an SVG path string for a squircle rectangle.
|
|
15
|
-
* Direct port of figma-squircle's getSvgPath(), with optional pure G2 Bézier mode.
|
|
16
|
-
*/
|
|
17
|
-
declare function getSvgPath({ cornerRadius, topLeftCornerRadius, topRightCornerRadius, bottomRightCornerRadius, bottomLeftCornerRadius, cornerSmoothing, width, height, preserveSmoothing, g2Continuous, }: SquirclePathParams): string;
|
|
18
|
-
/**
|
|
19
|
-
* Compute an SVG path string from width/height/radius/smoothing.
|
|
20
|
-
* Convenience wrapper around getSvgPath().
|
|
21
|
-
*/
|
|
22
|
-
declare function computeSquirclePath(width: number, height: number, cornerRadius: number, cornerSmoothing?: number, preserveSmoothing?: boolean, g2Continuous?: boolean): string;
|
|
23
|
-
/**
|
|
24
|
-
* Render a squircle rectangle directly onto a Canvas 2D context using
|
|
25
|
-
* G2 curvature-continuous Bézier curves (Pavel Klavík's optimal coefficients).
|
|
26
|
-
*
|
|
27
|
-
* FIX #5: Rewrote to use the same *relative delta* G2 coefficients as the
|
|
28
|
-
* SVG path drawer, so Canvas and SVG paths are numerically identical.
|
|
29
|
-
* Previous version used accumulated offsets (0.804, 0.912, 0.961) which
|
|
30
|
-
* did not match the SVG path coefficients (0.185, 0.293, 0.342).
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* const ctx = canvas.getContext('2d');
|
|
34
|
-
* ctx.beginPath();
|
|
35
|
-
* drawSquircleRect(ctx, 0, 0, 200, 100, 24);
|
|
36
|
-
* ctx.fillStyle = '#3b82f6';
|
|
37
|
-
* ctx.fill();
|
|
38
|
-
*/
|
|
39
|
-
declare function drawSquircleRect(ctx: CanvasRenderingContext2D | any, x: number, y: number, width: number, height: number, cornerRadius: number | {
|
|
40
|
-
tl?: number;
|
|
41
|
-
tr?: number;
|
|
42
|
-
br?: number;
|
|
43
|
-
bl?: number;
|
|
44
|
-
}, smoothing?: number): void;
|
|
45
|
-
|
|
46
|
-
interface SquircleClassConfig {
|
|
47
|
-
cornerRadius: number | null;
|
|
48
|
-
cornerSmoothing: number;
|
|
49
|
-
squircleBorder: boolean;
|
|
50
|
-
borderColor: string | null;
|
|
51
|
-
borderWidth: number;
|
|
52
|
-
g2Continuous: boolean;
|
|
53
|
-
restClasses: string;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Parse Tailwind-style class names and extract squircle config.
|
|
57
|
-
*
|
|
58
|
-
* When `squircle-border` is present, standard Tailwind `border-{color}` and
|
|
59
|
-
* `border-{width}` classes are intercepted for the squircle border overlay.
|
|
60
|
-
* Opacity modifiers like `border-gray-600/50` are fully supported.
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* parseSquircleClasses("rounded-squircle-24 squircle-border border-gray-600/50")
|
|
64
|
-
* // → { cornerRadius: 24, squircleBorder: true, borderColor: "rgba(75, 85, 99, 0.5)", ... }
|
|
65
|
-
*/
|
|
66
|
-
declare function parseSquircleClasses(className?: string): SquircleClassConfig;
|
|
67
|
-
|
|
68
|
-
export { type SquircleClassConfig, computeSquirclePath, drawSquircleRect, getSvgPath, parseSquircleClasses };
|
|
1
|
+
interface SquirclePathParams {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
cornerRadius?: number;
|
|
5
|
+
topLeftCornerRadius?: number;
|
|
6
|
+
topRightCornerRadius?: number;
|
|
7
|
+
bottomRightCornerRadius?: number;
|
|
8
|
+
bottomLeftCornerRadius?: number;
|
|
9
|
+
cornerSmoothing?: number;
|
|
10
|
+
preserveSmoothing?: boolean;
|
|
11
|
+
g2Continuous?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Generate an SVG path string for a squircle rectangle.
|
|
15
|
+
* Direct port of figma-squircle's getSvgPath(), with optional pure G2 Bézier mode.
|
|
16
|
+
*/
|
|
17
|
+
declare function getSvgPath({ cornerRadius, topLeftCornerRadius, topRightCornerRadius, bottomRightCornerRadius, bottomLeftCornerRadius, cornerSmoothing, width, height, preserveSmoothing, g2Continuous, }: SquirclePathParams): string;
|
|
18
|
+
/**
|
|
19
|
+
* Compute an SVG path string from width/height/radius/smoothing.
|
|
20
|
+
* Convenience wrapper around getSvgPath().
|
|
21
|
+
*/
|
|
22
|
+
declare function computeSquirclePath(width: number, height: number, cornerRadius: number, cornerSmoothing?: number, preserveSmoothing?: boolean, g2Continuous?: boolean): string;
|
|
23
|
+
/**
|
|
24
|
+
* Render a squircle rectangle directly onto a Canvas 2D context using
|
|
25
|
+
* G2 curvature-continuous Bézier curves (Pavel Klavík's optimal coefficients).
|
|
26
|
+
*
|
|
27
|
+
* FIX #5: Rewrote to use the same *relative delta* G2 coefficients as the
|
|
28
|
+
* SVG path drawer, so Canvas and SVG paths are numerically identical.
|
|
29
|
+
* Previous version used accumulated offsets (0.804, 0.912, 0.961) which
|
|
30
|
+
* did not match the SVG path coefficients (0.185, 0.293, 0.342).
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* const ctx = canvas.getContext('2d');
|
|
34
|
+
* ctx.beginPath();
|
|
35
|
+
* drawSquircleRect(ctx, 0, 0, 200, 100, 24);
|
|
36
|
+
* ctx.fillStyle = '#3b82f6';
|
|
37
|
+
* ctx.fill();
|
|
38
|
+
*/
|
|
39
|
+
declare function drawSquircleRect(ctx: CanvasRenderingContext2D | any, x: number, y: number, width: number, height: number, cornerRadius: number | {
|
|
40
|
+
tl?: number;
|
|
41
|
+
tr?: number;
|
|
42
|
+
br?: number;
|
|
43
|
+
bl?: number;
|
|
44
|
+
}, smoothing?: number): void;
|
|
45
|
+
|
|
46
|
+
interface SquircleClassConfig {
|
|
47
|
+
cornerRadius: number | null;
|
|
48
|
+
cornerSmoothing: number;
|
|
49
|
+
squircleBorder: boolean;
|
|
50
|
+
borderColor: string | null;
|
|
51
|
+
borderWidth: number;
|
|
52
|
+
g2Continuous: boolean;
|
|
53
|
+
restClasses: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Parse Tailwind-style class names and extract squircle config.
|
|
57
|
+
*
|
|
58
|
+
* When `squircle-border` is present, standard Tailwind `border-{color}` and
|
|
59
|
+
* `border-{width}` classes are intercepted for the squircle border overlay.
|
|
60
|
+
* Opacity modifiers like `border-gray-600/50` are fully supported.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* parseSquircleClasses("rounded-squircle-24 squircle-border border-gray-600/50")
|
|
64
|
+
* // → { cornerRadius: 24, squircleBorder: true, borderColor: "rgba(75, 85, 99, 0.5)", ... }
|
|
65
|
+
*/
|
|
66
|
+
declare function parseSquircleClasses(className?: string): SquircleClassConfig;
|
|
67
|
+
|
|
68
|
+
export { type SquircleClassConfig, computeSquirclePath, drawSquircleRect, getSvgPath, parseSquircleClasses };
|
package/dist/core.d.ts
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
interface SquirclePathParams {
|
|
2
|
-
width: number;
|
|
3
|
-
height: number;
|
|
4
|
-
cornerRadius?: number;
|
|
5
|
-
topLeftCornerRadius?: number;
|
|
6
|
-
topRightCornerRadius?: number;
|
|
7
|
-
bottomRightCornerRadius?: number;
|
|
8
|
-
bottomLeftCornerRadius?: number;
|
|
9
|
-
cornerSmoothing?: number;
|
|
10
|
-
preserveSmoothing?: boolean;
|
|
11
|
-
g2Continuous?: boolean;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Generate an SVG path string for a squircle rectangle.
|
|
15
|
-
* Direct port of figma-squircle's getSvgPath(), with optional pure G2 Bézier mode.
|
|
16
|
-
*/
|
|
17
|
-
declare function getSvgPath({ cornerRadius, topLeftCornerRadius, topRightCornerRadius, bottomRightCornerRadius, bottomLeftCornerRadius, cornerSmoothing, width, height, preserveSmoothing, g2Continuous, }: SquirclePathParams): string;
|
|
18
|
-
/**
|
|
19
|
-
* Compute an SVG path string from width/height/radius/smoothing.
|
|
20
|
-
* Convenience wrapper around getSvgPath().
|
|
21
|
-
*/
|
|
22
|
-
declare function computeSquirclePath(width: number, height: number, cornerRadius: number, cornerSmoothing?: number, preserveSmoothing?: boolean, g2Continuous?: boolean): string;
|
|
23
|
-
/**
|
|
24
|
-
* Render a squircle rectangle directly onto a Canvas 2D context using
|
|
25
|
-
* G2 curvature-continuous Bézier curves (Pavel Klavík's optimal coefficients).
|
|
26
|
-
*
|
|
27
|
-
* FIX #5: Rewrote to use the same *relative delta* G2 coefficients as the
|
|
28
|
-
* SVG path drawer, so Canvas and SVG paths are numerically identical.
|
|
29
|
-
* Previous version used accumulated offsets (0.804, 0.912, 0.961) which
|
|
30
|
-
* did not match the SVG path coefficients (0.185, 0.293, 0.342).
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* const ctx = canvas.getContext('2d');
|
|
34
|
-
* ctx.beginPath();
|
|
35
|
-
* drawSquircleRect(ctx, 0, 0, 200, 100, 24);
|
|
36
|
-
* ctx.fillStyle = '#3b82f6';
|
|
37
|
-
* ctx.fill();
|
|
38
|
-
*/
|
|
39
|
-
declare function drawSquircleRect(ctx: CanvasRenderingContext2D | any, x: number, y: number, width: number, height: number, cornerRadius: number | {
|
|
40
|
-
tl?: number;
|
|
41
|
-
tr?: number;
|
|
42
|
-
br?: number;
|
|
43
|
-
bl?: number;
|
|
44
|
-
}, smoothing?: number): void;
|
|
45
|
-
|
|
46
|
-
interface SquircleClassConfig {
|
|
47
|
-
cornerRadius: number | null;
|
|
48
|
-
cornerSmoothing: number;
|
|
49
|
-
squircleBorder: boolean;
|
|
50
|
-
borderColor: string | null;
|
|
51
|
-
borderWidth: number;
|
|
52
|
-
g2Continuous: boolean;
|
|
53
|
-
restClasses: string;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Parse Tailwind-style class names and extract squircle config.
|
|
57
|
-
*
|
|
58
|
-
* When `squircle-border` is present, standard Tailwind `border-{color}` and
|
|
59
|
-
* `border-{width}` classes are intercepted for the squircle border overlay.
|
|
60
|
-
* Opacity modifiers like `border-gray-600/50` are fully supported.
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* parseSquircleClasses("rounded-squircle-24 squircle-border border-gray-600/50")
|
|
64
|
-
* // → { cornerRadius: 24, squircleBorder: true, borderColor: "rgba(75, 85, 99, 0.5)", ... }
|
|
65
|
-
*/
|
|
66
|
-
declare function parseSquircleClasses(className?: string): SquircleClassConfig;
|
|
67
|
-
|
|
68
|
-
export { type SquircleClassConfig, computeSquirclePath, drawSquircleRect, getSvgPath, parseSquircleClasses };
|
|
1
|
+
interface SquirclePathParams {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
cornerRadius?: number;
|
|
5
|
+
topLeftCornerRadius?: number;
|
|
6
|
+
topRightCornerRadius?: number;
|
|
7
|
+
bottomRightCornerRadius?: number;
|
|
8
|
+
bottomLeftCornerRadius?: number;
|
|
9
|
+
cornerSmoothing?: number;
|
|
10
|
+
preserveSmoothing?: boolean;
|
|
11
|
+
g2Continuous?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Generate an SVG path string for a squircle rectangle.
|
|
15
|
+
* Direct port of figma-squircle's getSvgPath(), with optional pure G2 Bézier mode.
|
|
16
|
+
*/
|
|
17
|
+
declare function getSvgPath({ cornerRadius, topLeftCornerRadius, topRightCornerRadius, bottomRightCornerRadius, bottomLeftCornerRadius, cornerSmoothing, width, height, preserveSmoothing, g2Continuous, }: SquirclePathParams): string;
|
|
18
|
+
/**
|
|
19
|
+
* Compute an SVG path string from width/height/radius/smoothing.
|
|
20
|
+
* Convenience wrapper around getSvgPath().
|
|
21
|
+
*/
|
|
22
|
+
declare function computeSquirclePath(width: number, height: number, cornerRadius: number, cornerSmoothing?: number, preserveSmoothing?: boolean, g2Continuous?: boolean): string;
|
|
23
|
+
/**
|
|
24
|
+
* Render a squircle rectangle directly onto a Canvas 2D context using
|
|
25
|
+
* G2 curvature-continuous Bézier curves (Pavel Klavík's optimal coefficients).
|
|
26
|
+
*
|
|
27
|
+
* FIX #5: Rewrote to use the same *relative delta* G2 coefficients as the
|
|
28
|
+
* SVG path drawer, so Canvas and SVG paths are numerically identical.
|
|
29
|
+
* Previous version used accumulated offsets (0.804, 0.912, 0.961) which
|
|
30
|
+
* did not match the SVG path coefficients (0.185, 0.293, 0.342).
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* const ctx = canvas.getContext('2d');
|
|
34
|
+
* ctx.beginPath();
|
|
35
|
+
* drawSquircleRect(ctx, 0, 0, 200, 100, 24);
|
|
36
|
+
* ctx.fillStyle = '#3b82f6';
|
|
37
|
+
* ctx.fill();
|
|
38
|
+
*/
|
|
39
|
+
declare function drawSquircleRect(ctx: CanvasRenderingContext2D | any, x: number, y: number, width: number, height: number, cornerRadius: number | {
|
|
40
|
+
tl?: number;
|
|
41
|
+
tr?: number;
|
|
42
|
+
br?: number;
|
|
43
|
+
bl?: number;
|
|
44
|
+
}, smoothing?: number): void;
|
|
45
|
+
|
|
46
|
+
interface SquircleClassConfig {
|
|
47
|
+
cornerRadius: number | null;
|
|
48
|
+
cornerSmoothing: number;
|
|
49
|
+
squircleBorder: boolean;
|
|
50
|
+
borderColor: string | null;
|
|
51
|
+
borderWidth: number;
|
|
52
|
+
g2Continuous: boolean;
|
|
53
|
+
restClasses: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Parse Tailwind-style class names and extract squircle config.
|
|
57
|
+
*
|
|
58
|
+
* When `squircle-border` is present, standard Tailwind `border-{color}` and
|
|
59
|
+
* `border-{width}` classes are intercepted for the squircle border overlay.
|
|
60
|
+
* Opacity modifiers like `border-gray-600/50` are fully supported.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* parseSquircleClasses("rounded-squircle-24 squircle-border border-gray-600/50")
|
|
64
|
+
* // → { cornerRadius: 24, squircleBorder: true, borderColor: "rgba(75, 85, 99, 0.5)", ... }
|
|
65
|
+
*/
|
|
66
|
+
declare function parseSquircleClasses(className?: string): SquircleClassConfig;
|
|
67
|
+
|
|
68
|
+
export { type SquircleClassConfig, computeSquirclePath, drawSquircleRect, getSvgPath, parseSquircleClasses };
|