@zonsh/ui 0.0.0-stage → 0.2.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 +76 -2
- package/assets/illustrations/drawing/bracket-construction-dark.svg +77 -0
- package/assets/illustrations/drawing/bracket-construction-filled-dark.svg +50 -0
- package/assets/illustrations/drawing/bracket-construction-filled.svg +50 -0
- package/assets/illustrations/drawing/bracket-construction.svg +77 -0
- package/assets/illustrations/drawing/crescent-dark.svg +28 -0
- package/assets/illustrations/drawing/crescent-guides-dark.svg +33 -0
- package/assets/illustrations/drawing/crescent-guides.svg +33 -0
- package/assets/illustrations/drawing/crescent.svg +28 -0
- package/assets/illustrations/drawing/eclipse-dark.svg +187 -0
- package/assets/illustrations/drawing/eclipse-guides-dark.svg +191 -0
- package/assets/illustrations/drawing/eclipse-guides.svg +191 -0
- package/assets/illustrations/drawing/eclipse.svg +187 -0
- package/assets/illustrations/drawing/elevation-guides-dark.svg +31 -0
- package/assets/illustrations/drawing/elevation-guides-plain-dark.svg +9 -0
- package/assets/illustrations/drawing/elevation-guides-plain.svg +9 -0
- package/assets/illustrations/drawing/elevation-guides.svg +31 -0
- package/assets/illustrations/drawing/horizon-dark.svg +30 -0
- package/assets/illustrations/drawing/horizon.svg +30 -0
- package/assets/illustrations/drawing/nib-study-dark.svg +107 -0
- package/assets/illustrations/drawing/nib-study-plain-dark.svg +93 -0
- package/assets/illustrations/drawing/nib-study-plain.svg +93 -0
- package/assets/illustrations/drawing/nib-study.svg +107 -0
- package/assets/illustrations/editorial/assistant-640.webp +0 -0
- package/assets/illustrations/editorial/assistant.webp +0 -0
- package/assets/illustrations/editorial/automation-640.webp +0 -0
- package/assets/illustrations/editorial/automation.webp +0 -0
- package/assets/illustrations/editorial/bracket-left-640.webp +0 -0
- package/assets/illustrations/editorial/bracket-left.webp +0 -0
- package/assets/illustrations/editorial/bracket-right-640.webp +0 -0
- package/assets/illustrations/editorial/bracket-right.webp +0 -0
- package/assets/illustrations/editorial/custom-software-640.webp +0 -0
- package/assets/illustrations/editorial/custom-software.webp +0 -0
- package/assets/illustrations/editorial/digitalization-640.webp +0 -0
- package/assets/illustrations/editorial/digitalization.webp +0 -0
- package/assets/illustrations/editorial/integration-640.webp +0 -0
- package/assets/illustrations/editorial/integration.webp +0 -0
- package/assets/illustrations/editorial/problem-640.webp +0 -0
- package/assets/illustrations/editorial/problem.webp +0 -0
- package/assets/illustrations/editorial/process-analysis-640.webp +0 -0
- package/assets/illustrations/editorial/process-analysis.webp +0 -0
- package/assets/illustrations/editorial/process-concept-640.webp +0 -0
- package/assets/illustrations/editorial/process-concept.webp +0 -0
- package/assets/illustrations/editorial/process-development-640.webp +0 -0
- package/assets/illustrations/editorial/process-development.webp +0 -0
- package/assets/illustrations/editorial/process-discovery-640.webp +0 -0
- package/assets/illustrations/editorial/process-discovery.webp +0 -0
- package/assets/illustrations/editorial/process-maintenance-640.webp +0 -0
- package/assets/illustrations/editorial/process-maintenance.webp +0 -0
- package/assets/illustrations/editorial/process-prototype-640.webp +0 -0
- package/assets/illustrations/editorial/process-prototype.webp +0 -0
- package/assets/illustrations/editorial/process-testing-640.webp +0 -0
- package/assets/illustrations/editorial/process-testing.webp +0 -0
- package/assets/illustrations/iso/automation-dark.svg +6 -0
- package/assets/illustrations/iso/automation.svg +6 -0
- package/assets/illustrations/iso/bar-chart-dark.svg +6 -0
- package/assets/illustrations/iso/bar-chart.svg +6 -0
- package/assets/illustrations/iso/brackets-classic-dark.svg +6 -0
- package/assets/illustrations/iso/brackets-classic.svg +6 -0
- package/assets/illustrations/iso/brackets-dark.svg +6 -0
- package/assets/illustrations/iso/brackets.svg +6 -0
- package/assets/illustrations/iso/city-dark.svg +6 -0
- package/assets/illustrations/iso/city.svg +6 -0
- package/assets/illustrations/iso/conveyor-dark.svg +6 -0
- package/assets/illustrations/iso/conveyor.svg +6 -0
- package/assets/illustrations/iso/database-dark.svg +6 -0
- package/assets/illustrations/iso/database.svg +6 -0
- package/assets/illustrations/iso/documents-dark.svg +6 -0
- package/assets/illustrations/iso/documents.svg +6 -0
- package/assets/illustrations/iso/inbox-dark.svg +6 -0
- package/assets/illustrations/iso/inbox.svg +6 -0
- package/assets/illustrations/iso/laptop-dark.svg +6 -0
- package/assets/illustrations/iso/laptop.svg +6 -0
- package/assets/illustrations/iso/monitor-dark.svg +6 -0
- package/assets/illustrations/iso/monitor.svg +6 -0
- package/assets/illustrations/iso/pipeline-dark.svg +6 -0
- package/assets/illustrations/iso/pipeline.svg +6 -0
- package/assets/illustrations/iso/platform-dark.svg +6 -0
- package/assets/illustrations/iso/platform.svg +6 -0
- package/assets/illustrations/iso/server-dark.svg +6 -0
- package/assets/illustrations/iso/server.svg +6 -0
- package/assets/illustrations/iso/spreadsheet-dark.svg +6 -0
- package/assets/illustrations/iso/spreadsheet.svg +6 -0
- package/assets/illustrations/iso/timeline-dark.svg +6 -0
- package/assets/illustrations/iso/timeline.svg +6 -0
- package/assets/illustrations/sheet/construction.svg +115 -0
- package/assets/illustrations/sheet/crescent.svg +40 -0
- package/assets/illustrations/sheet/limb.svg +42 -0
- package/assets/illustrations/sheet/stress-axis.svg +119 -0
- package/assets/illustrations/sheet/totality.svg +215 -0
- package/assets/illustrations/sheet/vertical-metrics.svg +43 -0
- package/assets/logo-left.svg +1 -0
- package/assets/logo-right.svg +1 -0
- package/assets/logo.svg +1 -0
- package/dist/components/_overlay.d.ts +47 -0
- package/dist/components/_overlay.js +59 -0
- package/dist/components/accordion.d.ts +32 -0
- package/dist/components/accordion.js +39 -0
- package/dist/components/alert-dialog.d.ts +45 -0
- package/dist/components/alert-dialog.js +56 -0
- package/dist/components/alert.d.ts +35 -0
- package/dist/components/alert.js +42 -0
- package/dist/components/ascii-field.d.ts +34 -0
- package/dist/components/ascii-field.js +410 -0
- package/dist/components/aspect-ratio.d.ts +14 -0
- package/dist/components/aspect-ratio.js +17 -0
- package/dist/components/avatar.d.ts +42 -0
- package/dist/components/avatar.js +55 -0
- package/dist/components/badge.d.ts +70 -0
- package/dist/components/badge.js +62 -0
- package/dist/components/breadcrumb.d.ts +22 -0
- package/dist/components/breadcrumb.js +32 -0
- package/dist/components/button-group.d.ts +30 -0
- package/dist/components/button-group.js +47 -0
- package/dist/components/button.d.ts +53 -0
- package/dist/components/button.js +130 -0
- package/dist/components/calendar.d.ts +26 -0
- package/dist/components/calendar.js +164 -0
- package/dist/components/card.d.ts +42 -0
- package/dist/components/card.js +76 -0
- package/dist/components/carousel.d.ts +90 -0
- package/dist/components/carousel.js +213 -0
- package/dist/components/chart.d.ts +180 -0
- package/dist/components/chart.js +286 -0
- package/dist/components/checkbox.d.ts +23 -0
- package/dist/components/checkbox.js +43 -0
- package/dist/components/code-block.d.ts +45 -0
- package/dist/components/code-block.js +58 -0
- package/dist/components/code-highlight.d.ts +13 -0
- package/dist/components/code-highlight.js +107 -0
- package/dist/components/collapsible.d.ts +20 -0
- package/dist/components/collapsible.js +32 -0
- package/dist/components/color-picker.d.ts +85 -0
- package/dist/components/color-picker.js +407 -0
- package/dist/components/combobox.d.ts +81 -0
- package/dist/components/combobox.js +100 -0
- package/dist/components/command.d.ts +112 -0
- package/dist/components/command.js +212 -0
- package/dist/components/context-menu.d.ts +29 -0
- package/dist/components/context-menu.js +35 -0
- package/dist/components/conversation.d.ts +27 -0
- package/dist/components/conversation.js +293 -0
- package/dist/components/copy-button.d.ts +46 -0
- package/dist/components/copy-button.js +118 -0
- package/dist/components/data-table.d.ts +175 -0
- package/dist/components/data-table.js +302 -0
- package/dist/components/date-picker.d.ts +91 -0
- package/dist/components/date-picker.js +207 -0
- package/dist/components/dialog.d.ts +48 -0
- package/dist/components/dialog.js +92 -0
- package/dist/components/direction.d.ts +16 -0
- package/dist/components/direction.js +18 -0
- package/dist/components/drawer.d.ts +60 -0
- package/dist/components/drawer.js +76 -0
- package/dist/components/empty.d.ts +31 -0
- package/dist/components/empty.js +50 -0
- package/dist/components/feature-list.d.ts +54 -0
- package/dist/components/feature-list.js +43 -0
- package/dist/components/field.d.ts +15 -0
- package/dist/components/field.js +36 -0
- package/dist/components/file-drop.d.ts +55 -0
- package/dist/components/file-drop.js +197 -0
- package/dist/components/filter-bar.d.ts +106 -0
- package/dist/components/filter-bar.js +296 -0
- package/dist/components/form.d.ts +33 -0
- package/dist/components/form.js +34 -0
- package/dist/components/graph.d.ts +105 -0
- package/dist/components/graph.js +786 -0
- package/dist/components/illustration.d.ts +85 -0
- package/dist/components/illustration.js +165 -0
- package/dist/components/input-group.d.ts +127 -0
- package/dist/components/input-group.js +292 -0
- package/dist/components/input.d.ts +16 -0
- package/dist/components/input.js +25 -0
- package/dist/components/item.d.ts +64 -0
- package/dist/components/item.js +116 -0
- package/dist/components/kbd.d.ts +33 -0
- package/dist/components/kbd.js +38 -0
- package/dist/components/label.d.ts +12 -0
- package/dist/components/label.js +24 -0
- package/dist/components/layout.d.ts +136 -0
- package/dist/components/layout.js +162 -0
- package/dist/components/logo.d.ts +54 -0
- package/dist/components/logo.js +96 -0
- package/dist/components/menu.d.ts +60 -0
- package/dist/components/menu.js +138 -0
- package/dist/components/menubar.d.ts +62 -0
- package/dist/components/menubar.js +223 -0
- package/dist/components/message.d.ts +42 -0
- package/dist/components/message.js +56 -0
- package/dist/components/meter.d.ts +31 -0
- package/dist/components/meter.js +25 -0
- package/dist/components/native-select.d.ts +26 -0
- package/dist/components/native-select.js +35 -0
- package/dist/components/navigation-menu.d.ts +42 -0
- package/dist/components/navigation-menu.js +97 -0
- package/dist/components/number-field.d.ts +36 -0
- package/dist/components/number-field.js +153 -0
- package/dist/components/otp-field.d.ts +35 -0
- package/dist/components/otp-field.js +94 -0
- package/dist/components/pagination.d.ts +31 -0
- package/dist/components/pagination.js +70 -0
- package/dist/components/pdf-viewer.d.ts +69 -0
- package/dist/components/pdf-viewer.js +929 -0
- package/dist/components/popover.d.ts +33 -0
- package/dist/components/popover.js +48 -0
- package/dist/components/preview-card.d.ts +25 -0
- package/dist/components/preview-card.js +22 -0
- package/dist/components/progress.d.ts +27 -0
- package/dist/components/progress.js +23 -0
- package/dist/components/prompt-input.d.ts +131 -0
- package/dist/components/prompt-input.js +403 -0
- package/dist/components/quote.d.ts +22 -0
- package/dist/components/quote.js +15 -0
- package/dist/components/radio-group.d.ts +18 -0
- package/dist/components/radio-group.js +34 -0
- package/dist/components/reasoning.d.ts +31 -0
- package/dist/components/reasoning.js +70 -0
- package/dist/components/resizable.d.ts +38 -0
- package/dist/components/resizable.js +41 -0
- package/dist/components/response.d.ts +30 -0
- package/dist/components/response.js +538 -0
- package/dist/components/scroll-area.d.ts +33 -0
- package/dist/components/scroll-area.js +31 -0
- package/dist/components/select.d.ts +35 -0
- package/dist/components/select.js +60 -0
- package/dist/components/separator.d.ts +14 -0
- package/dist/components/separator.js +17 -0
- package/dist/components/sidebar.d.ts +147 -0
- package/dist/components/sidebar.js +489 -0
- package/dist/components/site-header.d.ts +59 -0
- package/dist/components/site-header.js +67 -0
- package/dist/components/skeleton.d.ts +31 -0
- package/dist/components/skeleton.js +29 -0
- package/dist/components/slider.d.ts +24 -0
- package/dist/components/slider.js +129 -0
- package/dist/components/sources.d.ts +25 -0
- package/dist/components/sources.js +35 -0
- package/dist/components/spinner.d.ts +36 -0
- package/dist/components/spinner.js +72 -0
- package/dist/components/suggestions.d.ts +20 -0
- package/dist/components/suggestions.js +18 -0
- package/dist/components/switch.d.ts +14 -0
- package/dist/components/switch.js +26 -0
- package/dist/components/table.d.ts +162 -0
- package/dist/components/table.js +758 -0
- package/dist/components/tabs.d.ts +25 -0
- package/dist/components/tabs.js +162 -0
- package/dist/components/tag.d.ts +41 -0
- package/dist/components/tag.js +88 -0
- package/dist/components/tags-input.d.ts +40 -0
- package/dist/components/tags-input.js +239 -0
- package/dist/components/textarea.d.ts +13 -0
- package/dist/components/textarea.js +16 -0
- package/dist/components/theme.d.ts +41 -0
- package/dist/components/theme.js +112 -0
- package/dist/components/time-field.d.ts +51 -0
- package/dist/components/time-field.js +437 -0
- package/dist/components/timeline.d.ts +76 -0
- package/dist/components/timeline.js +99 -0
- package/dist/components/toast.d.ts +72 -0
- package/dist/components/toast.js +196 -0
- package/dist/components/toggle-group.d.ts +41 -0
- package/dist/components/toggle-group.js +140 -0
- package/dist/components/toggle.d.ts +23 -0
- package/dist/components/toggle.js +35 -0
- package/dist/components/tool-call.d.ts +52 -0
- package/dist/components/tool-call.js +57 -0
- package/dist/components/toolbar.d.ts +17 -0
- package/dist/components/toolbar.js +34 -0
- package/dist/components/tooltip.d.ts +42 -0
- package/dist/components/tooltip.js +47 -0
- package/dist/components/tree.d.ts +75 -0
- package/dist/components/tree.js +636 -0
- package/dist/components/typography.d.ts +134 -0
- package/dist/components/typography.js +176 -0
- package/dist/components/video-player.d.ts +276 -0
- package/dist/components/video-player.js +1352 -0
- package/dist/components/whiteboard.d.ts +80 -0
- package/dist/components/whiteboard.js +389 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.js +86 -0
- package/dist/lib/cn.d.ts +20 -0
- package/dist/lib/cn.js +38 -0
- package/dist/lib/code-highlight.d.ts +31 -0
- package/dist/lib/code-highlight.js +24 -0
- package/dist/lib/code-theme.d.ts +19 -0
- package/dist/lib/code-theme.js +140 -0
- package/dist/lib/collapse-row.d.ts +9 -0
- package/dist/lib/collapse-row.js +129 -0
- package/dist/lib/digit-roll.d.ts +21 -0
- package/dist/lib/digit-roll.js +31 -0
- package/dist/lib/editorial-assets.d.ts +16 -0
- package/dist/lib/editorial-assets.js +56 -0
- package/dist/lib/figure/catalog.d.ts +127 -0
- package/dist/lib/figure/catalog.js +130 -0
- package/dist/lib/figure/figures/automation.d.ts +7 -0
- package/dist/lib/figure/figures/automation.js +143 -0
- package/dist/lib/figure/figures/bar-chart.d.ts +7 -0
- package/dist/lib/figure/figures/bar-chart.js +99 -0
- package/dist/lib/figure/figures/brackets-classic.d.ts +11 -0
- package/dist/lib/figure/figures/brackets-classic.js +170 -0
- package/dist/lib/figure/figures/brackets.d.ts +8 -0
- package/dist/lib/figure/figures/brackets.js +84 -0
- package/dist/lib/figure/figures/city.d.ts +7 -0
- package/dist/lib/figure/figures/city.js +93 -0
- package/dist/lib/figure/figures/conveyor.d.ts +7 -0
- package/dist/lib/figure/figures/conveyor.js +97 -0
- package/dist/lib/figure/figures/database.d.ts +7 -0
- package/dist/lib/figure/figures/database.js +65 -0
- package/dist/lib/figure/figures/documents.d.ts +7 -0
- package/dist/lib/figure/figures/documents.js +83 -0
- package/dist/lib/figure/figures/inbox.d.ts +7 -0
- package/dist/lib/figure/figures/inbox.js +92 -0
- package/dist/lib/figure/figures/laptop.d.ts +7 -0
- package/dist/lib/figure/figures/laptop.js +67 -0
- package/dist/lib/figure/figures/monitor.d.ts +7 -0
- package/dist/lib/figure/figures/monitor.js +59 -0
- package/dist/lib/figure/figures/pipeline.d.ts +8 -0
- package/dist/lib/figure/figures/pipeline.js +117 -0
- package/dist/lib/figure/figures/platform.d.ts +7 -0
- package/dist/lib/figure/figures/platform.js +117 -0
- package/dist/lib/figure/figures/server.d.ts +7 -0
- package/dist/lib/figure/figures/server.js +115 -0
- package/dist/lib/figure/figures/spreadsheet.d.ts +7 -0
- package/dist/lib/figure/figures/spreadsheet.js +87 -0
- package/dist/lib/figure/figures/timeline.d.ts +7 -0
- package/dist/lib/figure/figures/timeline.js +65 -0
- package/dist/lib/figure/kernel.d.ts +152 -0
- package/dist/lib/figure/kernel.js +576 -0
- package/dist/lib/figure/parts.d.ts +42 -0
- package/dist/lib/figure/parts.js +126 -0
- package/dist/lib/form-reset.d.ts +11 -0
- package/dist/lib/form-reset.js +22 -0
- package/dist/lib/glide.d.ts +53 -0
- package/dist/lib/glide.js +138 -0
- package/dist/lib/graph-layout.d.ts +58 -0
- package/dist/lib/graph-layout.js +200 -0
- package/dist/lib/illustration-drawings.d.ts +89 -0
- package/dist/lib/illustration-drawings.js +539 -0
- package/dist/lib/illustration-info.d.ts +37 -0
- package/dist/lib/illustration-info.js +22 -0
- package/dist/lib/illustration-library.d.ts +87 -0
- package/dist/lib/illustration-library.js +352 -0
- package/dist/lib/logo-geometry.d.ts +29 -0
- package/dist/lib/logo-geometry.js +67 -0
- package/dist/lib/markdown-guard.d.ts +16 -0
- package/dist/lib/markdown-guard.js +123 -0
- package/dist/lib/merge-refs.d.ts +10 -0
- package/dist/lib/merge-refs.js +26 -0
- package/dist/lib/motion.d.ts +6 -0
- package/dist/lib/motion.js +12 -0
- package/dist/lib/pdf-worker.d.ts +1 -0
- package/dist/lib/pdf-worker.js +6 -0
- package/dist/lib/pdf.d.ts +19 -0
- package/dist/lib/pdf.js +58 -0
- package/dist/lib/platform.d.ts +33 -0
- package/dist/lib/platform.js +68 -0
- package/dist/lib/room.d.ts +25 -0
- package/dist/lib/room.js +46 -0
- package/dist/lib/table-fit.d.ts +143 -0
- package/dist/lib/table-fit.js +577 -0
- package/dist/lib/theme-script.d.ts +18 -0
- package/dist/lib/theme-script.js +29 -0
- package/dist/styles/expressive.css +188 -0
- package/dist/styles/fonts.css +145 -0
- package/dist/styles/index.css +206 -0
- package/dist/styles/material.css +313 -0
- package/dist/styles/parts/ai.css +360 -0
- package/dist/styles/parts/brand.css +75 -0
- package/dist/styles/parts/controls.css +725 -0
- package/dist/styles/parts/data.css +222 -0
- package/dist/styles/parts/editorial.css +120 -0
- package/dist/styles/parts/feedback.css +273 -0
- package/dist/styles/parts/foundations.css +166 -0
- package/dist/styles/parts/graph.css +214 -0
- package/dist/styles/parts/inputs.css +261 -0
- package/dist/styles/parts/isometric.css +124 -0
- package/dist/styles/parts/navigation.css +232 -0
- package/dist/styles/parts/overlays.css +250 -0
- package/dist/styles/parts/pdf.css +154 -0
- package/dist/styles/parts/react-flow.css +519 -0
- package/dist/styles/parts/whiteboard.css +855 -0
- package/dist/styles/tokens.css +290 -0
- package/dist/vite.d.ts +116 -0
- package/dist/vite.js +129 -0
- package/package.json +189 -3
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spreadsheet — a sheet of cells with one that came loose and floats above its place. Cells near
|
|
3
|
+
* the pointer rise a little; bring the pointer to the loose cell and it settles back where it belongs.
|
|
4
|
+
*/
|
|
5
|
+
import { Spring, falloff, fit, lerp } from "../kernel.js";
|
|
6
|
+
import { faceLine, poly, topFace } from "../parts.js";
|
|
7
|
+
const figure = {
|
|
8
|
+
mount(ctx) {
|
|
9
|
+
const cols = 5;
|
|
10
|
+
const rows = 6;
|
|
11
|
+
const cw = 1.2;
|
|
12
|
+
const rh = 0.82;
|
|
13
|
+
const ix = 0.6;
|
|
14
|
+
const hy = 0.7;
|
|
15
|
+
const w = ix + cols * cw;
|
|
16
|
+
const d = hy + rows * rh;
|
|
17
|
+
const zs = 0.16;
|
|
18
|
+
const loose = { c: 1, r: 1 };
|
|
19
|
+
const float = 1.3;
|
|
20
|
+
const cam = fit([
|
|
21
|
+
[0, 0, 0],
|
|
22
|
+
[w, d, 0],
|
|
23
|
+
[0, 0, float + 0.6],
|
|
24
|
+
[w, 0, 0.8],
|
|
25
|
+
], 30);
|
|
26
|
+
ctx.box(0, 0, w, d, 0, zs, { r: 0.3, b: 0.2 }).draw(cam);
|
|
27
|
+
const head = ctx.path("crease");
|
|
28
|
+
const sheet = topFace(cam, 0, 0, zs);
|
|
29
|
+
head.attr("d", faceLine(sheet, [ix, 0.15], [ix, d - 0.15]) + faceLine(sheet, [0.15, hy], [w - 0.15, hy]));
|
|
30
|
+
// The loose cell's place: a dashed outline in the grid.
|
|
31
|
+
const lx = ix + loose.c * cw;
|
|
32
|
+
const ly = hy + loose.r * rh;
|
|
33
|
+
const hole = ctx.path("guide");
|
|
34
|
+
hole.attr("d", poly(cam, [[lx + 0.06, ly + 0.06, zs], [lx + cw - 0.06, ly + 0.06, zs], [lx + cw - 0.06, ly + rh - 0.06, zs], [lx + 0.06, ly + rh - 0.06, zs]], true));
|
|
35
|
+
const cells = [];
|
|
36
|
+
for (let k = 0; k < cols + rows - 1; k++)
|
|
37
|
+
for (let c = 0; c < cols; c++) {
|
|
38
|
+
const r = k - c;
|
|
39
|
+
if (r < 0 || r >= rows || (c === loose.c && r === loose.r))
|
|
40
|
+
continue;
|
|
41
|
+
const x = ix + c * cw;
|
|
42
|
+
const y = hy + r * rh;
|
|
43
|
+
const box = ctx.box(x + 0.07, y + 0.07, x + cw - 0.07, y + rh - 0.07, zs, zs + 0.1, { r: 0.08, b: 0 });
|
|
44
|
+
cells.push({ box, mark: ctx.path("crease", box.g), x: x + cw / 2, y: y + rh / 2, s: new Spring(0), c, r });
|
|
45
|
+
}
|
|
46
|
+
const tether = ctx.path("guide");
|
|
47
|
+
const cellBox = ctx.box(lx + 0.07, ly + 0.07, lx + cw - 0.07, ly + rh - 0.07, zs, zs + 0.45, { r: 0.1, b: 0.08 });
|
|
48
|
+
const cellMark = ctx.path("crease", cellBox.g);
|
|
49
|
+
const height = new Spring(float);
|
|
50
|
+
const draw = () => {
|
|
51
|
+
for (const cell of cells) {
|
|
52
|
+
cell.box.draw(cam, [0, 0, cell.s.x]);
|
|
53
|
+
const f = topFace(cam, cell.x - cw / 2, cell.y - rh / 2, zs + 0.1 + cell.s.x);
|
|
54
|
+
const len = 0.3 + ((cell.c * 7 + cell.r * 3) % 4) * 0.13;
|
|
55
|
+
cell.mark.attr("d", (cell.c + cell.r) % 5 === 3 ? null : faceLine(f, [0.25, rh / 2], [0.25 + len, rh / 2]));
|
|
56
|
+
}
|
|
57
|
+
const hz = height.x;
|
|
58
|
+
cellBox.draw(cam, [0, 0, hz]);
|
|
59
|
+
cellMark.attr("d", faceLine(topFace(cam, lx, ly, zs + 0.45 + hz), [0.3, rh / 2], [0.8, rh / 2]));
|
|
60
|
+
tether.attr("d", hz > 0.05 ? poly(cam, [[lx + cw / 2, ly + rh / 2, zs], [lx + cw / 2, ly + rh / 2, zs + hz]]) : null);
|
|
61
|
+
// While it floats, the loose cell is the bright one; once it is back, nothing needs looking at.
|
|
62
|
+
cellBox.hi(hz > 0.25);
|
|
63
|
+
};
|
|
64
|
+
ctx.loop((dt) => {
|
|
65
|
+
const p = ctx.pointer;
|
|
66
|
+
if (p.over) {
|
|
67
|
+
const [x, y] = cam.unproj(p.x, p.y, zs);
|
|
68
|
+
for (const cell of cells)
|
|
69
|
+
cell.s.t = 0.42 * falloff(Math.hypot(x - cell.x, y - cell.y), 2.4);
|
|
70
|
+
height.t = lerp(float, 0, Math.min(1, falloff(Math.hypot(x - (lx + cw / 2), y - (ly + rh / 2)), 3.2) * 1.4));
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
for (const cell of cells)
|
|
74
|
+
cell.s.t = 0;
|
|
75
|
+
height.t = float;
|
|
76
|
+
}
|
|
77
|
+
let moving = false;
|
|
78
|
+
for (const s of [height, ...cells.map((c) => c.s)])
|
|
79
|
+
if (s.step(dt, ctx.reduced))
|
|
80
|
+
moving = true;
|
|
81
|
+
draw();
|
|
82
|
+
return moving;
|
|
83
|
+
});
|
|
84
|
+
draw();
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
export default figure;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timeline — seven steps of a project on a track, each a little higher than the last. The pointer
|
|
3
|
+
* picks a step: it rises, its neighbours follow one after another, and a marker travels to it.
|
|
4
|
+
*/
|
|
5
|
+
import { type Figure } from "../kernel.js";
|
|
6
|
+
declare const figure: Figure;
|
|
7
|
+
export default figure;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timeline — seven steps of a project on a track, each a little higher than the last. The pointer
|
|
3
|
+
* picks a step: it rises, its neighbours follow one after another, and a marker travels to it.
|
|
4
|
+
*/
|
|
5
|
+
import { Spring, Tween, fit } from "../kernel.js";
|
|
6
|
+
import { bandIndex, faceLine, frontFace } from "../parts.js";
|
|
7
|
+
const figure = {
|
|
8
|
+
mount(ctx) {
|
|
9
|
+
const n = 7;
|
|
10
|
+
const step = 2.3;
|
|
11
|
+
const s = 1.6;
|
|
12
|
+
const heights = [0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0];
|
|
13
|
+
const cam = fit([
|
|
14
|
+
[-0.4, -0.4, 0],
|
|
15
|
+
[n * step, 3.6, 0],
|
|
16
|
+
[-0.4, -0.4, 3.2],
|
|
17
|
+
[n * step, 0, 3.4],
|
|
18
|
+
], 26);
|
|
19
|
+
ctx.box(-0.4, -0.4, n * step - 0.3, 3.6, -0.35, 0, { r: 0.5, b: 0.3 }).draw(cam);
|
|
20
|
+
const track = ctx.path("guide");
|
|
21
|
+
track.attr("d", `M${cam.P(0.4, 2.85, 0).join(" ")}L${cam.P(n * step - 1.1, 2.85, 0).join(" ")}`);
|
|
22
|
+
const plinths = [];
|
|
23
|
+
for (let i = 0; i < n; i++) {
|
|
24
|
+
const x = i * step;
|
|
25
|
+
const box = ctx.box(x, 0, x + s, s, 0, heights[i], { r: 0.3, b: 0.2 });
|
|
26
|
+
plinths.push({ box, dots: ctx.path("crease", box.g), t: new Tween(0) });
|
|
27
|
+
}
|
|
28
|
+
const marker = ctx.solid();
|
|
29
|
+
const bands = plinths.map((_, i) => cam.P(i * step + s / 2, s / 2, 0)[0]);
|
|
30
|
+
let chosen = -1;
|
|
31
|
+
const pos = new Spring(2 * step + s / 2);
|
|
32
|
+
const rest = 2;
|
|
33
|
+
const choose = (a, now) => {
|
|
34
|
+
if (a === chosen)
|
|
35
|
+
return;
|
|
36
|
+
chosen = a;
|
|
37
|
+
// The chosen step rises; its neighbours follow, outwards from it (rule 02).
|
|
38
|
+
plinths.forEach((p, i) => p.t.set(i === a ? 0.9 : Math.max(0, 0.32 - Math.abs(i - a) * 0.12), now, Math.abs(i - a) * 45));
|
|
39
|
+
pos.t = a * step + s / 2;
|
|
40
|
+
};
|
|
41
|
+
const draw = (now) => {
|
|
42
|
+
plinths.forEach((p, i) => {
|
|
43
|
+
const z = p.t.value(now);
|
|
44
|
+
p.box.draw(cam, [0, 0, z]);
|
|
45
|
+
p.box.hi(i === chosen);
|
|
46
|
+
// Its number, counted in short strokes on the front (rule 10).
|
|
47
|
+
const f = frontFace(cam, i * step, s, z);
|
|
48
|
+
p.dots.attr("d", Array.from({ length: i + 1 }, (_, k) => faceLine(f, [0.3 + k * 0.17, heights[i] - 0.28], [0.3 + k * 0.17, heights[i] - 0.14])).join(""));
|
|
49
|
+
});
|
|
50
|
+
const ring = Array.from({ length: 20 }, (_, k) => [pos.x + 0.42 * Math.cos((k / 20) * 6.283), 2.85 + 0.42 * Math.sin((k / 20) * 6.283)]);
|
|
51
|
+
const inner = ring.map(([x, y]) => [pos.x + (x - pos.x) * 0.7, 2.85 + (y - 2.85) * 0.7]);
|
|
52
|
+
marker.draw(cam, ring, inner, 0, 0.3);
|
|
53
|
+
};
|
|
54
|
+
ctx.loop((dt, now) => {
|
|
55
|
+
const p = ctx.pointer;
|
|
56
|
+
choose(p.over ? Math.max(0, Math.min(n - 1, Math.round(bandIndex(p.x, bands)))) : rest, now);
|
|
57
|
+
const moving = pos.step(dt, ctx.reduced) || plinths.some((q) => q.t.moving(now));
|
|
58
|
+
draw(ctx.reduced ? Infinity : now);
|
|
59
|
+
return moving;
|
|
60
|
+
});
|
|
61
|
+
choose(rest, -Infinity);
|
|
62
|
+
draw(Infinity);
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
export default figure;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
export type V2 = [number, number];
|
|
2
|
+
export type V3 = [number, number, number];
|
|
3
|
+
/** The frame every figure shares. */
|
|
4
|
+
export declare const VIEW: {
|
|
5
|
+
readonly w: 400;
|
|
6
|
+
readonly h: 320;
|
|
7
|
+
readonly cx: 200;
|
|
8
|
+
readonly cy: 166;
|
|
9
|
+
};
|
|
10
|
+
/** The isometric camera: azimuth 45°, elevation 30°, scale S, centred on (ox, oy). */
|
|
11
|
+
export declare class Cam {
|
|
12
|
+
S: number;
|
|
13
|
+
ox: number;
|
|
14
|
+
oy: number;
|
|
15
|
+
constructor(S?: number, ox?: number, oy?: number);
|
|
16
|
+
/** World → frame. */
|
|
17
|
+
P(x: number, y: number, z?: number): V2;
|
|
18
|
+
/** A frame point back onto the plane at height z, in world x, y. */
|
|
19
|
+
unproj(sx: number, sy: number, z?: number): V2;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A camera that fits these world points in the frame, with `pad` to spare (rule 03: fit the
|
|
23
|
+
* extreme pose). It fits all eight corners of their bounding box, so no corner can be missed.
|
|
24
|
+
*/
|
|
25
|
+
export declare function fit(points: V3[], pad?: number): Cam;
|
|
26
|
+
/**
|
|
27
|
+
* A camera that fits exactly these world points, for a figure whose footprint is not a box — a
|
|
28
|
+
* cross, a ring, an L — where the box's empty corners would only shrink it. Pass every corner
|
|
29
|
+
* that matters, in the extreme pose: nothing between the points is checked.
|
|
30
|
+
*/
|
|
31
|
+
export declare function fitPoints(points: V3[], pad?: number): Cam;
|
|
32
|
+
/** A rounded rectangle on the ground, counter-clockwise: `steps` segments round each corner. */
|
|
33
|
+
export declare function rrect(x0: number, y0: number, x1: number, y1: number, r: number, steps?: number): V2[];
|
|
34
|
+
/** A circle on the ground. */
|
|
35
|
+
export declare const circle: (cx: number, cy: number, r: number, steps?: number) => V2[];
|
|
36
|
+
/** The convex hull of frame points. */
|
|
37
|
+
export declare function hull(pts: V2[]): V2[];
|
|
38
|
+
/** The run of a counter-clockwise ring that faces the viewer (its outward normals point to +x, +y). */
|
|
39
|
+
export declare function front(ring: V2[]): V2[];
|
|
40
|
+
/** Path data through frame points. */
|
|
41
|
+
export declare const line: (pts: V2[], closed?: boolean) => string;
|
|
42
|
+
/** A spring for where the pointer is (rule 08): k 100 · c 18 · m 1. */
|
|
43
|
+
export declare class Spring {
|
|
44
|
+
x: number;
|
|
45
|
+
v: number;
|
|
46
|
+
t: number;
|
|
47
|
+
k: number;
|
|
48
|
+
c: number;
|
|
49
|
+
/** k and c default to the rule's 100 and 18; a lower c lets it bounce, for things that land. */
|
|
50
|
+
constructor(x?: number, k?: number, c?: number);
|
|
51
|
+
/** Advance; false once it has settled. */
|
|
52
|
+
step(dt: number, snap?: boolean): boolean;
|
|
53
|
+
}
|
|
54
|
+
/** cubic-bezier(.32, .72, 0, 1): the long ease-out for which part is chosen (rule 08). */
|
|
55
|
+
export declare function settle(p: number): number;
|
|
56
|
+
/** A tween for which part is chosen: 700ms on `settle`, with an optional delay (rule 02). */
|
|
57
|
+
export declare class Tween {
|
|
58
|
+
from: number;
|
|
59
|
+
to: number;
|
|
60
|
+
start: number;
|
|
61
|
+
dur: number;
|
|
62
|
+
constructor(x?: number, dur?: number);
|
|
63
|
+
set(to: number, now: number, delay?: number): void;
|
|
64
|
+
value(now: number): number;
|
|
65
|
+
moving(now: number): boolean;
|
|
66
|
+
}
|
|
67
|
+
/** How strongly a part answers at distance d from the pointer, for reach R (rule 03): 1 → .31 at 42% → .09 at R → 0. */
|
|
68
|
+
export declare function falloff(d: number, R: number): number;
|
|
69
|
+
export declare const clamp: (v: number, lo: number, hi: number) => number;
|
|
70
|
+
export declare const lerp: (a: number, b: number, t: number) => number;
|
|
71
|
+
export declare const hash: (n: number) => number;
|
|
72
|
+
/** A node in the figure: a real SVG element, or a virtual one for static files. */
|
|
73
|
+
export interface Node {
|
|
74
|
+
/** Set an attribute, if it changed. */
|
|
75
|
+
attr(name: string, value: string | null): Node;
|
|
76
|
+
/** Toggle a class. */
|
|
77
|
+
cls(name: string, on: boolean): Node;
|
|
78
|
+
append(child: Node): Node;
|
|
79
|
+
/** Paint these children in this order (moves only what is out of place). */
|
|
80
|
+
order(children: Node[]): void;
|
|
81
|
+
}
|
|
82
|
+
export type Make = (tag: string) => Node;
|
|
83
|
+
/** A rounded solid: a filled silhouette and one crease. */
|
|
84
|
+
export declare class Solid {
|
|
85
|
+
g: Node;
|
|
86
|
+
sil: Node;
|
|
87
|
+
crease: Node;
|
|
88
|
+
constructor(make: Make, parent: Node);
|
|
89
|
+
/** Draw it from its rings: the silhouette is the hull of both, the crease the top ring's inner front. */
|
|
90
|
+
draw(cam: Cam, ring: V2[], inner: V2[] | null, z0: number, z1: number, d?: V3): this;
|
|
91
|
+
/** Draw it from any two faces in the frame (a hinged lid, a tilted plate): hull, plus a crease you pass. */
|
|
92
|
+
drawFaces(a: V2[], b: V2[], crease: V2[] | null): this;
|
|
93
|
+
hi(on: boolean): this;
|
|
94
|
+
}
|
|
95
|
+
/** A rounded box from its footprint: ring and inner ring (inset by b) precomputed. */
|
|
96
|
+
export declare class Box {
|
|
97
|
+
solid: Solid;
|
|
98
|
+
ring: V2[];
|
|
99
|
+
inner: V2[];
|
|
100
|
+
z0: number;
|
|
101
|
+
z1: number;
|
|
102
|
+
constructor(make: Make, parent: Node, x0: number, y0: number, x1: number, y1: number, z0: number, z1: number, r?: number, b?: number, steps?: number);
|
|
103
|
+
draw(cam: Cam, d?: V3, h?: number): this;
|
|
104
|
+
hi(on: boolean): this;
|
|
105
|
+
get g(): Node;
|
|
106
|
+
}
|
|
107
|
+
export interface Pointer {
|
|
108
|
+
/** In the 400 × 320 frame. */
|
|
109
|
+
x: number;
|
|
110
|
+
y: number;
|
|
111
|
+
/** On the figure (or its trigger), or held by `active`. */
|
|
112
|
+
over: boolean;
|
|
113
|
+
}
|
|
114
|
+
export interface Ctx {
|
|
115
|
+
/** It answers the pointer and its loop runs. False for stills. */
|
|
116
|
+
live: boolean;
|
|
117
|
+
/** Under reduced motion: springs and tweens land at once, the figure still answers. */
|
|
118
|
+
reduced: boolean;
|
|
119
|
+
make: Make;
|
|
120
|
+
/** The figure's group, inside the svg. */
|
|
121
|
+
root: Node;
|
|
122
|
+
pointer: Pointer;
|
|
123
|
+
/** A group / path under `parent` (the root by default). */
|
|
124
|
+
g(parent?: Node): Node;
|
|
125
|
+
path(cls: string, parent?: Node): Node;
|
|
126
|
+
box(x0: number, y0: number, x1: number, y1: number, z0: number, z1: number, opts?: {
|
|
127
|
+
r?: number;
|
|
128
|
+
b?: number;
|
|
129
|
+
steps?: number;
|
|
130
|
+
parent?: Node;
|
|
131
|
+
}): Box;
|
|
132
|
+
solid(parent?: Node): Solid;
|
|
133
|
+
/** Run every frame while it returns true; `wake()` starts it again (pointer moves wake it too). */
|
|
134
|
+
loop(tick: (dt: number, now: number) => boolean): void;
|
|
135
|
+
wake(): void;
|
|
136
|
+
/** A click (or right-click, `e.button === 2`) at a frame point. */
|
|
137
|
+
onClick(fn: (x: number, y: number, e: MouseEvent) => void): void;
|
|
138
|
+
}
|
|
139
|
+
export interface Figure {
|
|
140
|
+
/** Build the figure at rest, register its loop. */
|
|
141
|
+
mount(ctx: Ctx): void;
|
|
142
|
+
}
|
|
143
|
+
/** A figure at rest, as the inside of an <svg viewBox="0 0 400 320"> (for static files). */
|
|
144
|
+
export declare function renderStill(figure: Figure): string;
|
|
145
|
+
/**
|
|
146
|
+
* Draw a figure into an <svg> and let it answer the pointer. The pointer is read on `trigger`
|
|
147
|
+
* (an ancestor with `data-iso-trigger`, or the svg); `data-active` on the svg holds it over the
|
|
148
|
+
* figure's centre. Returns a function that stops it and empties the svg.
|
|
149
|
+
*/
|
|
150
|
+
export declare function mountFigure(svg: SVGSVGElement, figure: Figure, opts: {
|
|
151
|
+
live: boolean;
|
|
152
|
+
}): () => void;
|