@zonsh/ui 0.0.0 → 0.4.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/LICENSE +43 -0
- package/README.md +81 -1
- 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/bottom-nav.d.ts +86 -0
- package/dist/components/bottom-nav.js +175 -0
- package/dist/components/breadcrumb.d.ts +31 -0
- package/dist/components/breadcrumb.js +37 -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 +179 -0
- package/dist/components/card.d.ts +42 -0
- package/dist/components/card.js +76 -0
- package/dist/components/carousel.d.ts +109 -0
- package/dist/components/carousel.js +231 -0
- package/dist/components/chart.d.ts +189 -0
- package/dist/components/chart.js +323 -0
- package/dist/components/checkbox.d.ts +23 -0
- package/dist/components/checkbox.js +43 -0
- package/dist/components/code-block.d.ts +55 -0
- package/dist/components/code-block.js +100 -0
- package/dist/components/collapsible.d.ts +20 -0
- package/dist/components/collapsible.js +32 -0
- package/dist/components/color-picker.d.ts +107 -0
- package/dist/components/color-picker.js +428 -0
- package/dist/components/combobox.d.ts +99 -0
- package/dist/components/combobox.js +172 -0
- package/dist/components/command.d.ts +132 -0
- package/dist/components/command.js +257 -0
- package/dist/components/context-menu.d.ts +29 -0
- package/dist/components/context-menu.js +35 -0
- package/dist/components/conversation.d.ts +36 -0
- package/dist/components/conversation.js +303 -0
- package/dist/components/copy-button.d.ts +55 -0
- package/dist/components/copy-button.js +133 -0
- package/dist/components/data-table.d.ts +235 -0
- package/dist/components/data-table.js +655 -0
- package/dist/components/date-picker.d.ts +160 -0
- package/dist/components/date-picker.js +338 -0
- package/dist/components/dialog.d.ts +57 -0
- package/dist/components/dialog.js +95 -0
- package/dist/components/direction.d.ts +16 -0
- package/dist/components/direction.js +18 -0
- package/dist/components/drawer.d.ts +69 -0
- package/dist/components/drawer.js +79 -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 +34 -0
- package/dist/components/field.js +81 -0
- package/dist/components/file-drop.d.ts +77 -0
- package/dist/components/file-drop.js +258 -0
- package/dist/components/filter-bar.d.ts +153 -0
- package/dist/components/filter-bar.js +334 -0
- package/dist/components/form.d.ts +35 -0
- package/dist/components/form.js +56 -0
- package/dist/components/graph.d.ts +146 -0
- package/dist/components/graph.js +825 -0
- package/dist/components/illustration.d.ts +85 -0
- package/dist/components/illustration.js +165 -0
- package/dist/components/input-group.d.ts +138 -0
- package/dist/components/input-group.js +312 -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 +50 -0
- package/dist/components/kbd.js +45 -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/lightbox.d.ts +100 -0
- package/dist/components/lightbox.js +439 -0
- package/dist/components/locale.d.ts +44 -0
- package/dist/components/locale.js +37 -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 +140 -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 +59 -0
- package/dist/components/meter.d.ts +31 -0
- package/dist/components/meter.js +27 -0
- package/dist/components/money-input.d.ts +80 -0
- package/dist/components/money-input.js +253 -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 +55 -0
- package/dist/components/number-field.js +164 -0
- package/dist/components/otp-field.d.ts +48 -0
- package/dist/components/otp-field.js +102 -0
- package/dist/components/pagination.d.ts +37 -0
- package/dist/components/pagination.js +81 -0
- package/dist/components/pdf-viewer.d.ts +134 -0
- package/dist/components/pdf-viewer.js +996 -0
- package/dist/components/phone-input.d.ts +79 -0
- package/dist/components/phone-input.js +282 -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 +25 -0
- package/dist/components/prompt-input.d.ts +156 -0
- package/dist/components/prompt-input.js +415 -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/rating.d.ts +73 -0
- package/dist/components/rating.js +124 -0
- package/dist/components/reasoning.d.ts +46 -0
- package/dist/components/reasoning.js +73 -0
- package/dist/components/resizable.d.ts +47 -0
- package/dist/components/resizable.js +44 -0
- package/dist/components/response.d.ts +41 -0
- package/dist/components/response.js +566 -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 +71 -0
- package/dist/components/separator.d.ts +14 -0
- package/dist/components/separator.js +17 -0
- package/dist/components/sidebar.d.ts +163 -0
- package/dist/components/sidebar.js +505 -0
- package/dist/components/site-header.d.ts +93 -0
- package/dist/components/site-header.js +121 -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 +131 -0
- package/dist/components/sortable.d.ts +178 -0
- package/dist/components/sortable.js +1258 -0
- package/dist/components/sources.d.ts +40 -0
- package/dist/components/sources.js +42 -0
- package/dist/components/spinner.d.ts +48 -0
- package/dist/components/spinner.js +75 -0
- package/dist/components/stat.d.ts +91 -0
- package/dist/components/stat.js +141 -0
- package/dist/components/stepper.d.ts +71 -0
- package/dist/components/stepper.js +101 -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 +172 -0
- package/dist/components/table.js +895 -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 +56 -0
- package/dist/components/tags-input.js +271 -0
- package/dist/components/textarea.d.ts +13 -0
- package/dist/components/textarea.js +16 -0
- package/dist/components/theme.d.ts +55 -0
- package/dist/components/theme.js +120 -0
- package/dist/components/time-field.d.ts +70 -0
- package/dist/components/time-field.js +450 -0
- package/dist/components/timeline.d.ts +92 -0
- package/dist/components/timeline.js +108 -0
- package/dist/components/tippy.d.ts +48 -0
- package/dist/components/tippy.js +648 -0
- package/dist/components/toast.d.ts +88 -0
- package/dist/components/toast.js +205 -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 +63 -0
- package/dist/components/tool-call.js +68 -0
- package/dist/components/toolbar.d.ts +17 -0
- package/dist/components/toolbar.js +39 -0
- package/dist/components/tooltip.d.ts +42 -0
- package/dist/components/tooltip.js +47 -0
- package/dist/components/tour.d.ts +127 -0
- package/dist/components/tour.js +648 -0
- package/dist/components/tree.d.ts +75 -0
- package/dist/components/tree.js +649 -0
- package/dist/components/typography.d.ts +134 -0
- package/dist/components/typography.js +176 -0
- package/dist/components/video-player.d.ts +284 -0
- package/dist/components/video-player.js +1392 -0
- package/dist/illustration.d.ts +2 -0
- package/dist/illustration.js +7 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.js +94 -0
- package/dist/lib/cn.d.ts +20 -0
- package/dist/lib/cn.js +38 -0
- package/dist/lib/code-highlight.d.ts +18 -0
- package/dist/lib/code-highlight.js +174 -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/field-errors.d.ts +28 -0
- package/dist/lib/field-errors.js +24 -0
- package/dist/lib/field-value.d.ts +13 -0
- package/dist/lib/field-value.js +44 -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 +209 -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/money.d.ts +73 -0
- package/dist/lib/money.js +343 -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/phone-countries.d.ts +1 -0
- package/dist/lib/phone-countries.js +281 -0
- package/dist/lib/phone.d.ts +90 -0
- package/dist/lib/phone.js +286 -0
- package/dist/lib/platform.d.ts +38 -0
- package/dist/lib/platform.js +75 -0
- package/dist/lib/room.d.ts +25 -0
- package/dist/lib/room.js +46 -0
- package/dist/lib/row-index.d.ts +15 -0
- package/dist/lib/row-index.js +136 -0
- package/dist/lib/table-fit.d.ts +143 -0
- package/dist/lib/table-fit.js +596 -0
- package/dist/lib/theme-script.d.ts +31 -0
- package/dist/lib/theme-script.js +49 -0
- package/dist/lib/tippy/pixels.d.ts +47 -0
- package/dist/lib/tippy/pixels.js +187 -0
- package/dist/lib/tippy/sprite.d.ts +86 -0
- package/dist/lib/tippy/sprite.js +753 -0
- package/dist/messages/de.d.ts +12 -0
- package/dist/messages/de.js +326 -0
- package/dist/styles/expressive.css +203 -0
- package/dist/styles/fonts.css +145 -0
- package/dist/styles/index.css +207 -0
- package/dist/styles/material.css +317 -0
- package/dist/styles/parts/ai.css +361 -0
- package/dist/styles/parts/brand.css +75 -0
- package/dist/styles/parts/controls.css +774 -0
- package/dist/styles/parts/data.css +222 -0
- package/dist/styles/parts/editorial.css +120 -0
- package/dist/styles/parts/feedback.css +340 -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 +424 -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/tokens.css +299 -0
- package/dist/vite.d.ts +66 -0
- package/dist/vite.js +29 -0
- package/package.json +183 -5
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform — a core on a tiled base, with modules plugged in around it. Modules near the pointer
|
|
3
|
+
* rise; over an empty tile a module's outline waits. Click a tile to plug a module in or take it out.
|
|
4
|
+
*/
|
|
5
|
+
import { Spring, falloff, fit, line } from "../kernel.js";
|
|
6
|
+
import { markOutline, poly, topFace } from "../parts.js";
|
|
7
|
+
const HEIGHTS = { "0-0": 1.2, "1-0": 0.9, "2-0": 2.4, "3-0": 1.5, "0-1": 0.8, "3-1": 1.0, "0-2": 1.9, "3-2": 1.3, "0-3": 1.7, "1-3": 0.7, "2-3": 1.1, "3-3": 2.0 };
|
|
8
|
+
const figure = {
|
|
9
|
+
mount(ctx) {
|
|
10
|
+
const n = 4;
|
|
11
|
+
const t = 2;
|
|
12
|
+
const gap = 0.16;
|
|
13
|
+
const on = new Set(["0-0", "2-0", "3-1", "0-3", "2-3"]);
|
|
14
|
+
const cam = fit([
|
|
15
|
+
[0, 0, -0.5],
|
|
16
|
+
[n * t, n * t, -0.5],
|
|
17
|
+
[0, 0, 3.4],
|
|
18
|
+
[n * t, 0, 3.0],
|
|
19
|
+
], 28);
|
|
20
|
+
for (let y = 0; y < n; y++)
|
|
21
|
+
for (let x = 0; x < n; x++)
|
|
22
|
+
ctx.box(x * t + gap / 2, y * t + gap / 2, (x + 1) * t - gap / 2, (y + 1) * t - gap / 2, -0.5, 0, { r: 0.25, b: 0.15 }).draw(cam);
|
|
23
|
+
const ghost = ctx.path("guide");
|
|
24
|
+
const ids = Object.keys(HEIGHTS);
|
|
25
|
+
const at = (id) => id.split("-").map(Number);
|
|
26
|
+
const pieces = [...ids.map((id) => ({ id, depth: at(id)[0] + at(id)[1] })), { id: "core", depth: 2.9 }].sort((a, b) => a.depth - b.depth);
|
|
27
|
+
const modules = new Map();
|
|
28
|
+
let core;
|
|
29
|
+
const coreMark = ctx.path("mid");
|
|
30
|
+
for (const p of pieces) {
|
|
31
|
+
if (p.id === "core") {
|
|
32
|
+
core = ctx.box(2.35, 2.35, 5.65, 5.65, 0, 1.5, { r: 0.45, b: 0.3 });
|
|
33
|
+
core.g.append(coreMark);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const [x, y] = at(p.id);
|
|
37
|
+
modules.set(p.id, { box: ctx.box(x * t + 0.45, y * t + 0.45, x * t + t - 0.45, y * t + t - 0.45, 0, HEIGHTS[p.id], { r: 0.22, b: 0.15 }), lift: new Spring(0), drop: new Spring(0), leave: new Spring(0), leaving: false });
|
|
38
|
+
}
|
|
39
|
+
const outline = markOutline(1.6);
|
|
40
|
+
let hover = null;
|
|
41
|
+
const tileAt = (px, py) => {
|
|
42
|
+
const [gx, gy] = cam.unproj(px, py, 0);
|
|
43
|
+
const id = `${Math.floor(gx / t)}-${Math.floor(gy / t)}`;
|
|
44
|
+
return id in HEIGHTS ? id : null;
|
|
45
|
+
};
|
|
46
|
+
ctx.onClick((x, y) => {
|
|
47
|
+
const id = tileAt(x, y);
|
|
48
|
+
if (!id)
|
|
49
|
+
return;
|
|
50
|
+
const m = modules.get(id);
|
|
51
|
+
if (on.has(id)) {
|
|
52
|
+
// Taken out: it lifts away and fades, the way a new one drops in, reversed.
|
|
53
|
+
on.delete(id);
|
|
54
|
+
m.leaving = true;
|
|
55
|
+
m.leave.x = 0;
|
|
56
|
+
m.leave.t = 1;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
on.add(id);
|
|
60
|
+
m.leaving = false;
|
|
61
|
+
m.leave.x = m.leave.t = 0;
|
|
62
|
+
m.drop.x = 1.8;
|
|
63
|
+
m.drop.t = 0;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
const draw = () => {
|
|
67
|
+
for (const [id, m] of modules) {
|
|
68
|
+
if (m.leaving && m.leave.x > 0.98)
|
|
69
|
+
m.leaving = false;
|
|
70
|
+
m.box.g.attr("opacity", m.leaving ? (1 - m.leave.x).toFixed(3) : null);
|
|
71
|
+
if (!on.has(id) && !m.leaving) {
|
|
72
|
+
m.box.solid.sil.attr("d", null);
|
|
73
|
+
m.box.solid.crease.attr("d", null);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
m.box.draw(cam, [0, 0, m.lift.x + m.drop.x + m.leave.x * 1.4]);
|
|
77
|
+
m.box.hi(!m.leaving && id === hover);
|
|
78
|
+
}
|
|
79
|
+
core.draw(cam);
|
|
80
|
+
const top = topFace(cam, 2.35, 2.35, 1.5);
|
|
81
|
+
coreMark.attr("d", outline.map((o) => line(o.map(([u, v]) => top(0.95 + u, 0.85 + v)), true)).join(""));
|
|
82
|
+
// Over an empty tile, the module that would go there waits as an outline.
|
|
83
|
+
if (hover && !on.has(hover)) {
|
|
84
|
+
const [x, y] = at(hover);
|
|
85
|
+
const [x0, y0, x1, y1, h] = [x * t + 0.45, y * t + 0.45, x * t + t - 0.45, y * t + t - 0.45, HEIGHTS[hover]];
|
|
86
|
+
ghost.attr("d", poly(cam, [[x0, y1, 0], [x1, y1, 0], [x1, y0, 0], [x1, y0, h], [x0, y0, h], [x0, y1, h], [x0, y1, 0]]) + poly(cam, [[x0, y1, h], [x1, y1, h], [x1, y0, h]]) + poly(cam, [[x1, y1, 0], [x1, y1, h]]));
|
|
87
|
+
}
|
|
88
|
+
else
|
|
89
|
+
ghost.attr("d", null);
|
|
90
|
+
core.hi(!hover);
|
|
91
|
+
};
|
|
92
|
+
ctx.loop((dt) => {
|
|
93
|
+
const p = ctx.pointer;
|
|
94
|
+
hover = null;
|
|
95
|
+
if (p.over) {
|
|
96
|
+
hover = tileAt(p.x, p.y);
|
|
97
|
+
const [gx, gy] = cam.unproj(p.x, p.y, 0);
|
|
98
|
+
for (const [id, m] of modules) {
|
|
99
|
+
const [x, y] = at(id);
|
|
100
|
+
m.lift.t = 0.5 * falloff(Math.hypot(gx - (x + 0.5) * t, gy - (y + 0.5) * t), 4.5);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else
|
|
104
|
+
for (const m of modules.values())
|
|
105
|
+
m.lift.t = 0;
|
|
106
|
+
let moving = false;
|
|
107
|
+
for (const m of modules.values())
|
|
108
|
+
for (const s of [m.lift, m.drop, m.leave])
|
|
109
|
+
if (s.step(dt, ctx.reduced))
|
|
110
|
+
moving = true;
|
|
111
|
+
draw();
|
|
112
|
+
return moving;
|
|
113
|
+
});
|
|
114
|
+
draw();
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
export default figure;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server — a rack of three units under a lid. The pointer's height picks a unit and pulls it out,
|
|
3
|
+
* its neighbours less; above the rack it lifts the lid, and the fans inside spin while it is open.
|
|
4
|
+
*/
|
|
5
|
+
import { type Figure } from "../kernel.js";
|
|
6
|
+
declare const figure: Figure;
|
|
7
|
+
export default figure;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server — a rack of three units under a lid. The pointer's height picks a unit and pulls it out,
|
|
3
|
+
* its neighbours less; above the rack it lifts the lid, and the fans inside spin while it is open.
|
|
4
|
+
*/
|
|
5
|
+
import { Spring, falloff, fit, line } from "../kernel.js";
|
|
6
|
+
import { bandIndex, faceLine, faceRect, frontFace, poly } from "../parts.js";
|
|
7
|
+
const figure = {
|
|
8
|
+
mount(ctx) {
|
|
9
|
+
const w = 5.2;
|
|
10
|
+
const d = 3.6;
|
|
11
|
+
const h = 1.05;
|
|
12
|
+
const gap = 0.16;
|
|
13
|
+
const t = 0.16;
|
|
14
|
+
const maxOut = 1.6;
|
|
15
|
+
const maxLift = 1.7;
|
|
16
|
+
const zTop = 2 * (h + gap);
|
|
17
|
+
const cam = fit([
|
|
18
|
+
[0, 0, 0],
|
|
19
|
+
[w, d + maxOut, 0],
|
|
20
|
+
[0, 0, zTop + h + maxLift],
|
|
21
|
+
[w, d + maxOut, zTop + h],
|
|
22
|
+
], 30);
|
|
23
|
+
/** A unit's front: vents, two drive bays and its status light. */
|
|
24
|
+
const frontParts = (g) => ({ detail: ctx.path("crease", g), led: ctx.path("led", g) });
|
|
25
|
+
const drawFront = (p, y, z) => {
|
|
26
|
+
const f = frontFace(cam, 0, y, z);
|
|
27
|
+
const vents = Array.from({ length: 6 }, (_, k) => faceLine(f, [0.5 + k * 0.26, 0.32], [0.5 + k * 0.26, h - 0.32])).join("");
|
|
28
|
+
p.detail.attr("d", vents + faceRect(f, 2.55, 0.28, 0.95, h - 0.56) + faceRect(f, 3.6, 0.28, 0.95, h - 0.56));
|
|
29
|
+
p.led.attr("d", faceLine(f, [4.68, h / 2], [4.96, h / 2]));
|
|
30
|
+
};
|
|
31
|
+
const units = [];
|
|
32
|
+
for (let i = 0; i < 2; i++) {
|
|
33
|
+
const box = ctx.box(0, 0, w, d, i * (h + gap), i * (h + gap) + h, { r: 0.35, b: 0.2 });
|
|
34
|
+
units.push({ box, front: frontParts(box.g) });
|
|
35
|
+
}
|
|
36
|
+
// The top unit is a tray: walls, a floor and parts inside, under a lid.
|
|
37
|
+
const tray = ctx.g();
|
|
38
|
+
const back = ctx.box(0, 0, w, t, zTop, zTop + h - 0.1, { r: 0.08, b: 0, parent: tray });
|
|
39
|
+
const leftWall = ctx.box(0, t, t, d - t, zTop, zTop + h - 0.1, { r: 0.04, b: 0, parent: tray });
|
|
40
|
+
const floor = ctx.box(t, t, w - t, d - t, zTop, zTop + 0.08, { r: 0.04, b: 0, parent: tray });
|
|
41
|
+
const inside = ctx.path("crease", tray);
|
|
42
|
+
const fanRings = ctx.path("mid", tray);
|
|
43
|
+
const blades = ctx.path("crease", tray);
|
|
44
|
+
const rams = [0, 1, 2, 3].map((k) => ctx.box(4.0 + k * 0.22, 0.5, 4.1 + k * 0.22, 2.5, zTop + 0.08, zTop + 0.62, { r: 0.03, b: 0, parent: tray }));
|
|
45
|
+
const rightWall = ctx.box(w - t, t, w, d - t, zTop, zTop + h - 0.1, { r: 0.04, b: 0, parent: tray });
|
|
46
|
+
const panel = ctx.box(0, d - t, w, d, zTop, zTop + h, { r: 0.08, b: 0, parent: tray });
|
|
47
|
+
const topFront = frontParts(panel.g);
|
|
48
|
+
const lid = ctx.box(0, 0, w, d - t, zTop + h - 0.1, zTop + h, { r: 0.3, b: 0.25 });
|
|
49
|
+
// Springs: each unit's pull, the lid's lift, the fans' angle.
|
|
50
|
+
const out = [new Spring(0), new Spring(0.45), new Spring(0)];
|
|
51
|
+
const lift = new Spring(0);
|
|
52
|
+
let angle = 0;
|
|
53
|
+
// Rest bands (rule 01): each unit's front centre, and the lid's top centre, in frame y.
|
|
54
|
+
const bands = [0, 1, 2].map((i) => cam.P(w / 2, d, i * (h + gap) + h / 2)[1]).concat(cam.P(w / 2, d / 2, zTop + h)[1]);
|
|
55
|
+
const draw = () => {
|
|
56
|
+
units.forEach((u, i) => {
|
|
57
|
+
const o = out[i].x;
|
|
58
|
+
u.box.draw(cam, [0, o, 0]);
|
|
59
|
+
drawFront(u.front, d + o, i * (h + gap));
|
|
60
|
+
});
|
|
61
|
+
const o = out[2].x;
|
|
62
|
+
const dd = [0, o, 0];
|
|
63
|
+
back.draw(cam, dd);
|
|
64
|
+
leftWall.draw(cam, dd);
|
|
65
|
+
floor.draw(cam, dd);
|
|
66
|
+
const z0 = zTop + 0.08;
|
|
67
|
+
inside.attr("d", poly(cam, [[0.35, 0.35 + o, z0], [w - 0.35, 0.35 + o, z0], [w - 0.35, d - 0.4 + o, z0], [0.35, d - 0.4 + o, z0]], true));
|
|
68
|
+
const fans = [1.05, 2.4].map((cx) => [cx, 1.35 + o]);
|
|
69
|
+
fanRings.attr("d", fans.map(([cx, cy]) => line(Array.from({ length: 24 }, (_, k) => cam.P(cx + 0.55 * Math.cos((k / 24) * 6.283), cy + 0.55 * Math.sin((k / 24) * 6.283), z0)), true)).join(""));
|
|
70
|
+
blades.attr("d", fans
|
|
71
|
+
.map(([cx, cy]) => [0, 1, 2, 3, 4]
|
|
72
|
+
.map((k) => {
|
|
73
|
+
const a = angle + (k / 5) * 6.283;
|
|
74
|
+
return poly(cam, [[cx + 0.1 * Math.cos(a), cy + 0.1 * Math.sin(a), z0], [cx + 0.48 * Math.cos(a + 0.5), cy + 0.48 * Math.sin(a + 0.5), z0]]);
|
|
75
|
+
})
|
|
76
|
+
.join(""))
|
|
77
|
+
.join(""));
|
|
78
|
+
for (const r of rams)
|
|
79
|
+
r.draw(cam, dd);
|
|
80
|
+
rightWall.draw(cam, dd);
|
|
81
|
+
panel.draw(cam, dd);
|
|
82
|
+
drawFront(topFront, d + o, zTop);
|
|
83
|
+
lid.draw(cam, [0, o, lift.x]);
|
|
84
|
+
};
|
|
85
|
+
ctx.loop((dt) => {
|
|
86
|
+
const p = ctx.pointer;
|
|
87
|
+
let pick = -1;
|
|
88
|
+
if (p.over) {
|
|
89
|
+
const f = bandIndex(p.y, bands);
|
|
90
|
+
out.forEach((s, i) => (s.t = maxOut * falloff(Math.abs(i - f), 1.6)));
|
|
91
|
+
lift.t = maxLift * falloff(Math.abs(3 - f), 1.1);
|
|
92
|
+
pick = Math.round(f);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
out.forEach((s, i) => (s.t = i === 1 ? 0.45 : 0));
|
|
96
|
+
lift.t = 0;
|
|
97
|
+
}
|
|
98
|
+
// The light of the chosen unit is the one bright mark; at rest, the unit that stands out.
|
|
99
|
+
[units[0].front, units[1].front, topFront].forEach((fr, i) => fr.led.cls("hi", pick < 0 ? i === 1 : i === pick));
|
|
100
|
+
let moving = false;
|
|
101
|
+
for (const s of [...out, lift])
|
|
102
|
+
if (s.step(dt, ctx.reduced))
|
|
103
|
+
moving = true;
|
|
104
|
+
if (lift.x > 0.05 && !ctx.reduced) {
|
|
105
|
+
angle += dt * 9 * Math.min(1, lift.x / maxLift);
|
|
106
|
+
moving = true;
|
|
107
|
+
}
|
|
108
|
+
draw();
|
|
109
|
+
return moving;
|
|
110
|
+
});
|
|
111
|
+
units[1].front.led.cls("hi", true);
|
|
112
|
+
draw();
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
export default figure;
|
|
@@ -0,0 +1,7 @@
|
|
|
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 { type Figure } from "../kernel.js";
|
|
6
|
+
declare const figure: Figure;
|
|
7
|
+
export default figure;
|
|
@@ -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;
|