@dstackai/sqircle 0.1.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/LICENSE +21 -0
- package/README.md +94 -0
- package/dist/SquircleEditor.d.ts +24 -0
- package/dist/SquircleScene.d.ts +3 -0
- package/dist/codeExport.d.ts +10 -0
- package/dist/geometry.d.ts +42 -0
- package/dist/index.d.ts +8 -0
- package/dist/palettes.d.ts +181 -0
- package/dist/sqircle.js +1339 -0
- package/dist/sqircle.js.map +1 -0
- package/dist/style.css +2 -0
- package/dist/types.d.ts +71 -0
- package/docs/README.md +26 -0
- package/docs/design/README.md +20 -0
- package/docs/design/colors.md +150 -0
- package/docs/design/geometry.md +118 -0
- package/docs/design/rendering.md +116 -0
- package/docs/design/single-squircle-states.md +121 -0
- package/docs/react/README.md +168 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dstack
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Squircle
|
|
2
|
+
|
|
3
|
+
Squircle is a React/TypeScript component for rendering precise isometric squircle-prism SVG compositions. The reusable implementation lives in `src/squircle`; the HTML files are visual fixtures, demos, and constructor prototypes that preserve earlier design decisions.
|
|
4
|
+
|
|
5
|
+
Use this repo when you need:
|
|
6
|
+
|
|
7
|
+
- `SquircleScene`: a configurable SVG renderer for 0-N squircle layers.
|
|
8
|
+
- `SquircleEditor`: a small constructor UI for editing layers and copying React code.
|
|
9
|
+
- A documented visual system for squircle geometry, gradients, wireframes, top-plane text, and dashed inlays.
|
|
10
|
+
- Static HTML reference pages for regression checks and agent handoff.
|
|
11
|
+
|
|
12
|
+
## Quick Start
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm install
|
|
16
|
+
npm run dev
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Open `react.html` from the Vite dev server to use the React constructor demo.
|
|
20
|
+
|
|
21
|
+
For production checks:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
npm run typecheck
|
|
25
|
+
npm run build
|
|
26
|
+
git diff --check -- .
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## React Usage
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { SquircleScene, type SquircleLayerConfig } from "./squircle";
|
|
33
|
+
|
|
34
|
+
const layers: SquircleLayerConfig[] = [
|
|
35
|
+
{
|
|
36
|
+
id: "bottom",
|
|
37
|
+
offset: { y: 176 },
|
|
38
|
+
base: { material: "wireframe", paletteId: "15" }
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: "top",
|
|
42
|
+
offset: { y: 0 },
|
|
43
|
+
base: { material: "solid", paletteId: "15", text: "GPU", dash: true },
|
|
44
|
+
hover: { material: "wireframe", paletteId: "20" }
|
|
45
|
+
}
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
export function ExampleSquircle() {
|
|
49
|
+
return <SquircleScene theme="light" layers={layers} />;
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
For the full API, layer model, palette fields, editor props, and generated-code export, read [React Component Guide](docs/react/README.md).
|
|
54
|
+
|
|
55
|
+
## Documentation Map
|
|
56
|
+
|
|
57
|
+
Start at [Documentation Index](docs/README.md). The docs are split by purpose:
|
|
58
|
+
|
|
59
|
+
- [React Component Guide](docs/react/README.md): how to use and configure `SquircleScene`, `SquircleEditor`, and code export.
|
|
60
|
+
- [Design Documentation](docs/design/README.md): geometry, rendering, color, annotation, wireframe, and single-squircle visual rules.
|
|
61
|
+
- [Static Prototype Documentation](docs/static/README.md): `index.html`, `demo.html`, and `constructor.html` contracts.
|
|
62
|
+
- [Verification Checklist](docs/verification.md): static checks, render checks, and expected behavior.
|
|
63
|
+
|
|
64
|
+
## Repository Shape
|
|
65
|
+
|
|
66
|
+
| Path | Role |
|
|
67
|
+
| --- | --- |
|
|
68
|
+
| `src/squircle` | Main React/TypeScript component implementation |
|
|
69
|
+
| `react.html` | Vite entry for the React constructor demo |
|
|
70
|
+
| `index.html` | Static CSS-only hero and variant fixture |
|
|
71
|
+
| `demo.html` | Static preset gallery fixture |
|
|
72
|
+
| `constructor.html` | Legacy dynamic constructor prototype that exports React code |
|
|
73
|
+
| `public/static/styles.css` | Shared static-page fixture styles, served at `/static/styles.css` |
|
|
74
|
+
| `static/styles.css` | Symlink for opening static HTML files directly with `file://` |
|
|
75
|
+
| `docs/` | Agent-facing component, design, static-page, and verification docs |
|
|
76
|
+
|
|
77
|
+
## Current Visual Defaults
|
|
78
|
+
|
|
79
|
+
- Superellipse: `n = 12`, `N = 160`, `a = 225.49`
|
|
80
|
+
- Prism height: `h = 10`
|
|
81
|
+
- Projection: `20deg`
|
|
82
|
+
- ViewBox: `0 0 800 480`
|
|
83
|
+
- Default palette: `15 Alpha`
|
|
84
|
+
- Default three-layer offsets: bottom `y = 176`, middle `y = 88`, top `y = 0`
|
|
85
|
+
|
|
86
|
+
## Hard Rules
|
|
87
|
+
|
|
88
|
+
- New reusable work should go through `src/squircle`.
|
|
89
|
+
- Component styles belong beside their components in `src/squircle`; static fixture styles live under `public/static/`, with `static/styles.css` kept as a direct-file symlink.
|
|
90
|
+
- Do not hand-edit generated prism, inlay, or hidden-edge coordinates; regenerate from [Geometry Contract](docs/design/geometry.md).
|
|
91
|
+
- Keep hover swaps opacity-only: no transform, scale, filter, halo, or layer-gap changes.
|
|
92
|
+
- Render top-plane text as one SVG text element on the projected top plane. Do not duplicate it for filled and wireframe states.
|
|
93
|
+
- Keep variant colors synchronized with [Color System](docs/design/colors.md).
|
|
94
|
+
- Keep the body background transparent.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { SquircleLayerConfig, SquircleTheme } from "./types";
|
|
2
|
+
import "./SquircleEditor.css";
|
|
3
|
+
export interface SquircleEditorProps {
|
|
4
|
+
value?: SquircleLayerConfig[];
|
|
5
|
+
initialLayers?: SquircleLayerConfig[];
|
|
6
|
+
onChange?: (layers: SquircleLayerConfig[]) => void;
|
|
7
|
+
title?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
/** @deprecated The editor now exports React code instead of schema-tagged JSON. */
|
|
10
|
+
schema?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
layerGap?: number;
|
|
13
|
+
showCode?: boolean;
|
|
14
|
+
/** @deprecated Use showCode. */
|
|
15
|
+
showConfig?: boolean;
|
|
16
|
+
codeComponentName?: string;
|
|
17
|
+
codeImportPath?: string;
|
|
18
|
+
theme?: SquircleTheme;
|
|
19
|
+
defaultTheme?: SquircleTheme;
|
|
20
|
+
onThemeChange?: (theme: SquircleTheme) => void;
|
|
21
|
+
showThemeSwitch?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function createDefaultSquircleEditorLayers(paletteId?: string): SquircleLayerConfig[];
|
|
24
|
+
export declare function SquircleEditor({ value, initialLayers, onChange, title, description, className, layerGap, showCode, showConfig, codeComponentName, codeImportPath, theme, defaultTheme, onThemeChange, showThemeSwitch }: SquircleEditorProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { SquircleSceneProps } from "./types";
|
|
2
|
+
import "./SquircleScene.css";
|
|
3
|
+
export declare function SquircleScene({ layers, geometry, selectedLayerId, theme, idPrefix, className, ariaLabel, fitToLayers, transitionMs, onLayerSelect }: SquircleSceneProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SquircleLayerConfig, SquircleTheme } from "./types";
|
|
2
|
+
export interface SquircleReactCodeOptions {
|
|
3
|
+
layers: SquircleLayerConfig[];
|
|
4
|
+
theme: SquircleTheme;
|
|
5
|
+
componentName?: string;
|
|
6
|
+
importPath?: string;
|
|
7
|
+
ariaLabel?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function createSquircleReactCode({ layers, theme, componentName, importPath, ariaLabel }: SquircleReactCodeOptions): string;
|
|
10
|
+
export declare function toComponentName(input: string): string;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { SquircleGeometryConfig, SquircleLayerConfig, SquirclePoint } from "./types";
|
|
2
|
+
export declare const DEFAULT_GEOMETRY: {
|
|
3
|
+
readonly width: 800;
|
|
4
|
+
readonly viewBoxHeight: 480;
|
|
5
|
+
readonly exponent: 12;
|
|
6
|
+
readonly samples: 160;
|
|
7
|
+
readonly prismHeight: 10;
|
|
8
|
+
readonly angleDegrees: 20;
|
|
9
|
+
readonly inlayScale: 0.6;
|
|
10
|
+
};
|
|
11
|
+
interface Bounds {
|
|
12
|
+
minX: number;
|
|
13
|
+
minY: number;
|
|
14
|
+
maxX: number;
|
|
15
|
+
maxY: number;
|
|
16
|
+
}
|
|
17
|
+
export interface SquircleGeometry {
|
|
18
|
+
config: Required<Omit<SquircleGeometryConfig, "halfSize" | "center">> & {
|
|
19
|
+
halfSize: number;
|
|
20
|
+
center: SquirclePoint;
|
|
21
|
+
};
|
|
22
|
+
cosA: number;
|
|
23
|
+
sinA: number;
|
|
24
|
+
topPoints: SquirclePoint[];
|
|
25
|
+
bottomPoints: SquirclePoint[];
|
|
26
|
+
wallPoints: SquirclePoint[];
|
|
27
|
+
hiddenPoints: SquirclePoint[];
|
|
28
|
+
inlayPoints: SquirclePoint[];
|
|
29
|
+
labelTransform: string;
|
|
30
|
+
topBounds: Bounds;
|
|
31
|
+
sideBounds: Bounds;
|
|
32
|
+
viewBox: string;
|
|
33
|
+
}
|
|
34
|
+
export declare function createSquircleGeometry(input?: SquircleGeometryConfig): SquircleGeometry;
|
|
35
|
+
export declare function pointsToString(points: SquirclePoint[]): string;
|
|
36
|
+
export declare function createSquircleLayers(count: number, options?: {
|
|
37
|
+
gap?: number;
|
|
38
|
+
paletteId?: string;
|
|
39
|
+
material?: "solid" | "transparent" | "wireframe";
|
|
40
|
+
}): SquircleLayerConfig[];
|
|
41
|
+
export declare function reflowLayerOffsets(layers: SquircleLayerConfig[], gap?: number): SquircleLayerConfig[];
|
|
42
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { SquircleScene } from "./SquircleScene";
|
|
2
|
+
export { SquircleEditor, createDefaultSquircleEditorLayers } from "./SquircleEditor";
|
|
3
|
+
export { createSquircleReactCode, toComponentName } from "./codeExport";
|
|
4
|
+
export { DEFAULT_GEOMETRY, createSquircleGeometry, createSquircleLayers, reflowLayerOffsets } from "./geometry";
|
|
5
|
+
export { DEFAULT_PALETTE_ID, SQUIRCLE_PALETTE_IDS, SQUIRCLE_PALETTES, getSquirclePalette } from "./palettes";
|
|
6
|
+
export type { SquircleReactCodeOptions } from "./codeExport";
|
|
7
|
+
export type { SquircleEditorProps } from "./SquircleEditor";
|
|
8
|
+
export type { SquircleAnnotationColor, SquircleGeometryConfig, SquircleLayerConfig, SquircleMaterial, SquircleOpacityConfig, SquircleSceneProps, SquircleStrokeConfig, SquircleTextStyle, SquircleTheme, SquircleVariantConfig } from "./types";
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
export interface SquircleGradientStop {
|
|
2
|
+
offset: number;
|
|
3
|
+
color: string;
|
|
4
|
+
}
|
|
5
|
+
export interface SquirclePalette {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
top: SquircleGradientStop[];
|
|
9
|
+
side: SquircleGradientStop[];
|
|
10
|
+
textWire: SquircleGradientStop[];
|
|
11
|
+
labelFill: string;
|
|
12
|
+
topEdge: string;
|
|
13
|
+
sideEdge: string;
|
|
14
|
+
swatch: [string, string];
|
|
15
|
+
}
|
|
16
|
+
export declare const SQUIRCLE_PALETTES: {
|
|
17
|
+
"13": {
|
|
18
|
+
id: string;
|
|
19
|
+
label: string;
|
|
20
|
+
top: {
|
|
21
|
+
offset: number;
|
|
22
|
+
color: string;
|
|
23
|
+
}[];
|
|
24
|
+
side: {
|
|
25
|
+
offset: number;
|
|
26
|
+
color: string;
|
|
27
|
+
}[];
|
|
28
|
+
textWire: {
|
|
29
|
+
offset: number;
|
|
30
|
+
color: string;
|
|
31
|
+
}[];
|
|
32
|
+
labelFill: string;
|
|
33
|
+
topEdge: string;
|
|
34
|
+
sideEdge: string;
|
|
35
|
+
swatch: [string, string];
|
|
36
|
+
};
|
|
37
|
+
"14": {
|
|
38
|
+
id: string;
|
|
39
|
+
label: string;
|
|
40
|
+
top: {
|
|
41
|
+
offset: number;
|
|
42
|
+
color: string;
|
|
43
|
+
}[];
|
|
44
|
+
side: {
|
|
45
|
+
offset: number;
|
|
46
|
+
color: string;
|
|
47
|
+
}[];
|
|
48
|
+
textWire: {
|
|
49
|
+
offset: number;
|
|
50
|
+
color: string;
|
|
51
|
+
}[];
|
|
52
|
+
labelFill: string;
|
|
53
|
+
topEdge: string;
|
|
54
|
+
sideEdge: string;
|
|
55
|
+
swatch: [string, string];
|
|
56
|
+
};
|
|
57
|
+
"15": {
|
|
58
|
+
id: string;
|
|
59
|
+
label: string;
|
|
60
|
+
top: {
|
|
61
|
+
offset: number;
|
|
62
|
+
color: string;
|
|
63
|
+
}[];
|
|
64
|
+
side: {
|
|
65
|
+
offset: number;
|
|
66
|
+
color: string;
|
|
67
|
+
}[];
|
|
68
|
+
textWire: {
|
|
69
|
+
offset: number;
|
|
70
|
+
color: string;
|
|
71
|
+
}[];
|
|
72
|
+
labelFill: string;
|
|
73
|
+
topEdge: string;
|
|
74
|
+
sideEdge: string;
|
|
75
|
+
swatch: [string, string];
|
|
76
|
+
};
|
|
77
|
+
"16": {
|
|
78
|
+
id: string;
|
|
79
|
+
label: string;
|
|
80
|
+
top: {
|
|
81
|
+
offset: number;
|
|
82
|
+
color: string;
|
|
83
|
+
}[];
|
|
84
|
+
side: {
|
|
85
|
+
offset: number;
|
|
86
|
+
color: string;
|
|
87
|
+
}[];
|
|
88
|
+
textWire: {
|
|
89
|
+
offset: number;
|
|
90
|
+
color: string;
|
|
91
|
+
}[];
|
|
92
|
+
labelFill: string;
|
|
93
|
+
topEdge: string;
|
|
94
|
+
sideEdge: string;
|
|
95
|
+
swatch: [string, string];
|
|
96
|
+
};
|
|
97
|
+
"17": {
|
|
98
|
+
id: string;
|
|
99
|
+
label: string;
|
|
100
|
+
top: {
|
|
101
|
+
offset: number;
|
|
102
|
+
color: string;
|
|
103
|
+
}[];
|
|
104
|
+
side: {
|
|
105
|
+
offset: number;
|
|
106
|
+
color: string;
|
|
107
|
+
}[];
|
|
108
|
+
textWire: {
|
|
109
|
+
offset: number;
|
|
110
|
+
color: string;
|
|
111
|
+
}[];
|
|
112
|
+
labelFill: string;
|
|
113
|
+
topEdge: string;
|
|
114
|
+
sideEdge: string;
|
|
115
|
+
swatch: [string, string];
|
|
116
|
+
};
|
|
117
|
+
"18": {
|
|
118
|
+
id: string;
|
|
119
|
+
label: string;
|
|
120
|
+
top: {
|
|
121
|
+
offset: number;
|
|
122
|
+
color: string;
|
|
123
|
+
}[];
|
|
124
|
+
side: {
|
|
125
|
+
offset: number;
|
|
126
|
+
color: string;
|
|
127
|
+
}[];
|
|
128
|
+
textWire: {
|
|
129
|
+
offset: number;
|
|
130
|
+
color: string;
|
|
131
|
+
}[];
|
|
132
|
+
labelFill: string;
|
|
133
|
+
topEdge: string;
|
|
134
|
+
sideEdge: string;
|
|
135
|
+
swatch: [string, string];
|
|
136
|
+
};
|
|
137
|
+
"19": {
|
|
138
|
+
id: string;
|
|
139
|
+
label: string;
|
|
140
|
+
top: {
|
|
141
|
+
offset: number;
|
|
142
|
+
color: string;
|
|
143
|
+
}[];
|
|
144
|
+
side: {
|
|
145
|
+
offset: number;
|
|
146
|
+
color: string;
|
|
147
|
+
}[];
|
|
148
|
+
textWire: {
|
|
149
|
+
offset: number;
|
|
150
|
+
color: string;
|
|
151
|
+
}[];
|
|
152
|
+
labelFill: string;
|
|
153
|
+
topEdge: string;
|
|
154
|
+
sideEdge: string;
|
|
155
|
+
swatch: [string, string];
|
|
156
|
+
};
|
|
157
|
+
"20": {
|
|
158
|
+
id: string;
|
|
159
|
+
label: string;
|
|
160
|
+
top: {
|
|
161
|
+
offset: number;
|
|
162
|
+
color: string;
|
|
163
|
+
}[];
|
|
164
|
+
side: {
|
|
165
|
+
offset: number;
|
|
166
|
+
color: string;
|
|
167
|
+
}[];
|
|
168
|
+
textWire: {
|
|
169
|
+
offset: number;
|
|
170
|
+
color: string;
|
|
171
|
+
}[];
|
|
172
|
+
labelFill: string;
|
|
173
|
+
topEdge: string;
|
|
174
|
+
sideEdge: string;
|
|
175
|
+
swatch: [string, string];
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
export type SquirclePaletteId = keyof typeof SQUIRCLE_PALETTES;
|
|
179
|
+
export declare const SQUIRCLE_PALETTE_IDS: SquirclePaletteId[];
|
|
180
|
+
export declare const DEFAULT_PALETTE_ID: SquirclePaletteId;
|
|
181
|
+
export declare function getSquirclePalette(paletteId: string | undefined): SquirclePalette;
|