@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,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Envelope — its flap hinged at the back edge. The pointer's height opens the flap; past upright it
|
|
3
|
+
* folds back onto the desk and the letter slides out over it, carrying the mark.
|
|
4
|
+
*/
|
|
5
|
+
import { Spring, clamp, fit, line, lerp, rrect } from "../kernel.js";
|
|
6
|
+
import { faceLine, markOutline, topFace } from "../parts.js";
|
|
7
|
+
const figure = {
|
|
8
|
+
mount(ctx) {
|
|
9
|
+
const w = 6;
|
|
10
|
+
const d = 3.9;
|
|
11
|
+
const eh = 0.24;
|
|
12
|
+
const lw = 5.2;
|
|
13
|
+
const ld = 3.3;
|
|
14
|
+
const fd = d * 0.55;
|
|
15
|
+
const rest = 28;
|
|
16
|
+
const cam = fit([
|
|
17
|
+
[0, -fd - 0.4, 0],
|
|
18
|
+
[w, d, 0],
|
|
19
|
+
[0, -ld - 0.8, 0.6],
|
|
20
|
+
[w, 0, fd + 0.3],
|
|
21
|
+
], 30);
|
|
22
|
+
const flapBackG = ctx.g();
|
|
23
|
+
const flapBack = ctx.solid(flapBackG);
|
|
24
|
+
const letterG = ctx.g();
|
|
25
|
+
const letter = ctx.solid(letterG);
|
|
26
|
+
const letterMark = ctx.path("mid", letterG);
|
|
27
|
+
const envG = ctx.g();
|
|
28
|
+
ctx.box(0, 0, w, d, 0, eh, { r: 0.3, b: 0.2, parent: envG }).draw(cam);
|
|
29
|
+
const seams = ctx.path("crease", envG);
|
|
30
|
+
const top = topFace(cam, 0, 0, eh);
|
|
31
|
+
seams.attr("d", faceLine(top, [0.2, d - 0.15], [w / 2, d * 0.45]) + faceLine(top, [w / 2, d * 0.45], [w - 0.2, d - 0.15]));
|
|
32
|
+
const flapFrontG = ctx.g();
|
|
33
|
+
const flapFront = ctx.solid(flapFrontG);
|
|
34
|
+
const angle = new Spring(rest);
|
|
35
|
+
const out = new Spring(0);
|
|
36
|
+
const mark = markOutline(0.9);
|
|
37
|
+
// The flap's outline in its own plane: u across, v away from the hinge, its point softened.
|
|
38
|
+
const flapShape = [
|
|
39
|
+
[0.15, 0],
|
|
40
|
+
[w - 0.15, 0],
|
|
41
|
+
[w / 2 + 0.32, fd - 0.22],
|
|
42
|
+
[w / 2, fd],
|
|
43
|
+
[w / 2 - 0.32, fd - 0.22],
|
|
44
|
+
];
|
|
45
|
+
const draw = () => {
|
|
46
|
+
const phi = (angle.x * Math.PI) / 180;
|
|
47
|
+
// Closed (0°) the flap lies forward over the top; open (180°) it lies back on the desk.
|
|
48
|
+
const [c, sn] = [Math.cos(phi), Math.sin(phi)];
|
|
49
|
+
const face = (off) => flapShape.map(([u, v]) => cam.P(u, v * c - off * sn, eh + v * sn + off * c));
|
|
50
|
+
const a = face(0);
|
|
51
|
+
const b = face(0.04);
|
|
52
|
+
const flap = angle.x > 90 ? flapBack : flapFront;
|
|
53
|
+
const other = angle.x > 90 ? flapFront : flapBack;
|
|
54
|
+
flap.drawFaces(a, b, null);
|
|
55
|
+
flap.hi(out.x < 0.2);
|
|
56
|
+
other.sil.attr("d", null);
|
|
57
|
+
other.crease.attr("d", null);
|
|
58
|
+
// The letter: inside the envelope, then out over the open flap.
|
|
59
|
+
const s = out.x;
|
|
60
|
+
const ly = 0.3 - s * (ld + 0.6);
|
|
61
|
+
const lz = 0.06 + s * 0.28;
|
|
62
|
+
const ring = rrect((w - lw) / 2, ly, (w + lw) / 2, ly + ld, 0.15, 3);
|
|
63
|
+
letter.draw(cam, ring, null, lz, lz + 0.05);
|
|
64
|
+
letter.hi(s > 0.5);
|
|
65
|
+
const lt = topFace(cam, (w - lw) / 2, ly, lz + 0.05);
|
|
66
|
+
letterMark.attr("d", mark.map((m) => line(m.map(([u, v]) => lt(0.5 + u, 0.45 + v)), true)).join("") +
|
|
67
|
+
[1.6, 2.0, 2.4].map((v, k) => faceLine(lt, [0.5, v], [k === 2 ? 2.8 : 4.4, v])).join(""));
|
|
68
|
+
// Past upright the flap lies behind the letter; before it, over the envelope (rule 06).
|
|
69
|
+
ctx.root.order(angle.x > 90 ? [flapBackG, letterG, envG, flapFrontG] : [letterG, envG, flapFrontG, flapBackG]);
|
|
70
|
+
};
|
|
71
|
+
ctx.loop((dt) => {
|
|
72
|
+
const p = ctx.pointer;
|
|
73
|
+
if (p.over) {
|
|
74
|
+
const k = clamp((250 - p.y) / 170, 0, 1);
|
|
75
|
+
angle.t = lerp(20, 178, k);
|
|
76
|
+
out.t = clamp((k - 0.7) / 0.3, 0, 1);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
angle.t = rest;
|
|
80
|
+
out.t = 0;
|
|
81
|
+
}
|
|
82
|
+
let moving = false;
|
|
83
|
+
for (const s of [angle, out])
|
|
84
|
+
if (s.step(dt, ctx.reduced))
|
|
85
|
+
moving = true;
|
|
86
|
+
draw();
|
|
87
|
+
return moving;
|
|
88
|
+
});
|
|
89
|
+
draw();
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
export default figure;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Laptop — open on its hinge. The pointer's height sets the lid, which follows on a spring; the
|
|
3
|
+
* screen's frame is the bright line while it faces you.
|
|
4
|
+
*/
|
|
5
|
+
import { Spring, clamp, fit, line, lerp, rrect } from "../kernel.js";
|
|
6
|
+
import { faceRect, topFace } from "../parts.js";
|
|
7
|
+
const figure = {
|
|
8
|
+
mount(ctx) {
|
|
9
|
+
const w = 6.4;
|
|
10
|
+
const d = 4.4;
|
|
11
|
+
const bh = 0.32;
|
|
12
|
+
const lw = 4.2;
|
|
13
|
+
const lt = 0.16;
|
|
14
|
+
const rest = 104;
|
|
15
|
+
const cam = fit([
|
|
16
|
+
[0, -lw * 0.4, 0],
|
|
17
|
+
[w, d, 0],
|
|
18
|
+
[0, 0, bh + lw],
|
|
19
|
+
[w, 0, bh + lw],
|
|
20
|
+
], 30);
|
|
21
|
+
const lidG = ctx.g();
|
|
22
|
+
const lid = ctx.solid(lidG);
|
|
23
|
+
const screen = ctx.path("crease", lidG);
|
|
24
|
+
const frame = ctx.path("sil", lidG);
|
|
25
|
+
const baseG = ctx.g();
|
|
26
|
+
ctx.box(0, 0, w, d, 0, bh, { r: 0.45, b: 0.3, parent: baseG }).draw(cam);
|
|
27
|
+
const keys = ctx.path("crease", baseG);
|
|
28
|
+
const deck = topFace(cam, 0, 0, bh);
|
|
29
|
+
const rows = [];
|
|
30
|
+
for (let r = 0; r < 4; r++)
|
|
31
|
+
for (let c = 0; c < 10; c++)
|
|
32
|
+
rows.push(faceRect(deck, 0.6 + c * 0.53, 0.55 + r * 0.53, 0.44, 0.44, 0.08));
|
|
33
|
+
keys.attr("d", rows.join("") + faceRect(deck, 2.3, 2.95, 1.8, 1.05, 0.15));
|
|
34
|
+
const angle = new Spring(rest);
|
|
35
|
+
const hy = 0.08;
|
|
36
|
+
const draw = () => {
|
|
37
|
+
const phi = (angle.x * Math.PI) / 180;
|
|
38
|
+
const dir = [0, Math.cos(phi), Math.sin(phi)];
|
|
39
|
+
// The screen's normal; the back faces the other way.
|
|
40
|
+
const n = [0, Math.sin(phi), -Math.cos(phi)];
|
|
41
|
+
const at = (u, v, off) => cam.P(u, hy + v * dir[1] - n[1] * off, bh + v * dir[2] - n[2] * off);
|
|
42
|
+
const outline = rrect(0, 0, w, lw, 0.35, 4);
|
|
43
|
+
const inner = outline.map(([u, v]) => at(u, v, 0));
|
|
44
|
+
const outer = outline.map(([u, v]) => at(u, v, lt));
|
|
45
|
+
// The screen faces you while its normal points towards the camera.
|
|
46
|
+
const facing = n[1] * 0.61 + n[2] * 0.5 > 0;
|
|
47
|
+
lid.drawFaces(inner, outer, null);
|
|
48
|
+
const scr = rrect(0.35, 0.35, w - 0.35, lw - 0.55, 0.15, 3).map(([u, v]) => at(u, v, -0.001));
|
|
49
|
+
frame.attr("d", facing ? line(scr, true) : null);
|
|
50
|
+
screen.attr("d", facing
|
|
51
|
+
? [0.9, 1.55, 2.2].map((v) => line([at(0.8, lw - 0.55 - v, 0), at(v === 2.2 ? 3.4 : 4.9, lw - 0.55 - v, 0)])).join("")
|
|
52
|
+
: null);
|
|
53
|
+
// Past upright the lid stands behind the deck; before it, over it.
|
|
54
|
+
ctx.root.order(angle.x > 90 ? [lidG, baseG] : [baseG, lidG]);
|
|
55
|
+
};
|
|
56
|
+
frame.cls("hi", true);
|
|
57
|
+
ctx.loop((dt) => {
|
|
58
|
+
const p = ctx.pointer;
|
|
59
|
+
angle.t = p.over ? lerp(124, 68, clamp((p.y - 70) / 190, 0, 1)) : rest;
|
|
60
|
+
const moving = angle.step(dt, ctx.reduced);
|
|
61
|
+
draw();
|
|
62
|
+
return moving;
|
|
63
|
+
});
|
|
64
|
+
draw();
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
export default figure;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Monitor — a line chart on a screen. The pointer reads it: a cursor follows across the chart and
|
|
3
|
+
* stands on the line at that point; at rest it marks the latest value.
|
|
4
|
+
*/
|
|
5
|
+
import { type Figure } from "../kernel.js";
|
|
6
|
+
declare const figure: Figure;
|
|
7
|
+
export default figure;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Monitor — a line chart on a screen. The pointer reads it: a cursor follows across the chart and
|
|
3
|
+
* stands on the line at that point; at rest it marks the latest value.
|
|
4
|
+
*/
|
|
5
|
+
import { Spring, clamp, fit, lerp } from "../kernel.js";
|
|
6
|
+
import { faceLine, faceRect, frontFace } from "../parts.js";
|
|
7
|
+
const VALUES = [0.55, 0.9, 0.7, 1.3, 1.15, 1.75, 1.5, 2.1, 2.35];
|
|
8
|
+
const figure = {
|
|
9
|
+
mount(ctx) {
|
|
10
|
+
const sw = 6.6;
|
|
11
|
+
const sh = 4.2;
|
|
12
|
+
const y = 1.15;
|
|
13
|
+
const z0 = 1.15;
|
|
14
|
+
const cam = fit([
|
|
15
|
+
[0, 0.3, 0],
|
|
16
|
+
[sw, 2.7, 0],
|
|
17
|
+
[0, y, z0 + sh],
|
|
18
|
+
[sw, y, z0 + sh],
|
|
19
|
+
], 30);
|
|
20
|
+
ctx.box(1.6, 0.3, 5.0, 2.7, 0, 0.2, { r: 0.5, b: 0.3 }).draw(cam);
|
|
21
|
+
ctx.box(3.0, 0.45, 3.6, 0.85, 0.2, z0 + 0.6, { r: 0.15, b: 0 }).draw(cam);
|
|
22
|
+
ctx.box(0, 0.85, sw, y, z0, z0 + sh, { r: 0.35, b: 0.15 }).draw(cam);
|
|
23
|
+
const face = frontFace(cam, 0, y, z0);
|
|
24
|
+
const chrome = ctx.path("crease");
|
|
25
|
+
chrome.attr("d", faceRect(face, 0.3, 0.3, sw - 0.6, sh - 0.6, 0.18) + faceLine(face, [0.9, 0.85], [sw - 0.9, 0.85]));
|
|
26
|
+
// The chart: u from 0.9 to 5.7, v from 0.85 up.
|
|
27
|
+
const [u0, u1] = [0.9, sw - 0.9];
|
|
28
|
+
const ux = (i) => lerp(u0, u1, i / (VALUES.length - 1));
|
|
29
|
+
const vAt = (t) => {
|
|
30
|
+
const k = clamp(t, 0, 1) * (VALUES.length - 1);
|
|
31
|
+
const i = Math.min(VALUES.length - 2, Math.floor(k));
|
|
32
|
+
return 0.85 + lerp(VALUES[i], VALUES[i + 1], k - i);
|
|
33
|
+
};
|
|
34
|
+
const chart = ctx.path("mid");
|
|
35
|
+
chart.attr("d", `M${VALUES.map((v, i) => face(ux(i), 0.85 + v).join(" ")).join("L")}`);
|
|
36
|
+
const cursor = ctx.path("hi");
|
|
37
|
+
const t = new Spring(1);
|
|
38
|
+
const draw = () => {
|
|
39
|
+
const u = lerp(u0, u1, t.x);
|
|
40
|
+
const v = vAt(t.x);
|
|
41
|
+
cursor.attr("d", faceLine(face, [u, 0.85], [u, sh - 0.55]) + faceLine(face, [u - 0.22, v], [u + 0.22, v]));
|
|
42
|
+
};
|
|
43
|
+
ctx.loop((dt) => {
|
|
44
|
+
const p = ctx.pointer;
|
|
45
|
+
if (p.over) {
|
|
46
|
+
// On the screen's plane, frame x maps straight to u.
|
|
47
|
+
const x = (p.x - cam.ox) / (cam.S * Math.SQRT1_2) + y;
|
|
48
|
+
t.t = clamp((x - u0) / (u1 - u0), 0, 1);
|
|
49
|
+
}
|
|
50
|
+
else
|
|
51
|
+
t.t = 1;
|
|
52
|
+
const moving = t.step(dt, ctx.reduced);
|
|
53
|
+
draw();
|
|
54
|
+
return moving;
|
|
55
|
+
});
|
|
56
|
+
draw();
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
export default figure;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data pipeline — on one platform: sources feed an intake, a belt carries records under a scanner,
|
|
3
|
+
* where raw blocks come out as flat processed tiles, past a processor into a warehouse that feeds a
|
|
4
|
+
* dashboard. It runs on its own; the scanner is the one bright line.
|
|
5
|
+
*/
|
|
6
|
+
import { type Figure } from "../kernel.js";
|
|
7
|
+
declare const figure: Figure;
|
|
8
|
+
export default figure;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data pipeline — on one platform: sources feed an intake, a belt carries records under a scanner,
|
|
3
|
+
* where raw blocks come out as flat processed tiles, past a processor into a warehouse that feeds a
|
|
4
|
+
* dashboard. It runs on its own; the scanner is the one bright line.
|
|
5
|
+
*/
|
|
6
|
+
import { circle, fit, rrect } from "../kernel.js";
|
|
7
|
+
import { along, faceLine, frontFace, poly } from "../parts.js";
|
|
8
|
+
const figure = {
|
|
9
|
+
mount(ctx) {
|
|
10
|
+
const PW = 30;
|
|
11
|
+
const PD = 12;
|
|
12
|
+
const zr = 0.85;
|
|
13
|
+
const cam = fit([
|
|
14
|
+
[0, 0, -0.4],
|
|
15
|
+
[PW, PD, -0.4],
|
|
16
|
+
[0, 0, 3.2],
|
|
17
|
+
[PW, 0, 3],
|
|
18
|
+
], 16);
|
|
19
|
+
ctx.box(0, 0, PW, PD, -0.4, 0, { r: 0.8, b: 0.5 }).draw(cam);
|
|
20
|
+
// Feeds from the sources to the intake, painted on the platform.
|
|
21
|
+
const feeds = [
|
|
22
|
+
[[3.4, 2.3, 0.02], [5.4, 2.3, 0.02], [5.4, 6, 0.02], [7, 6, 0.02]],
|
|
23
|
+
[[3.4, 6, 0.02], [7, 6, 0.02]],
|
|
24
|
+
[[3.4, 9.4, 0.02], [5.4, 9.4, 0.02], [5.4, 6, 0.02], [7, 6, 0.02]],
|
|
25
|
+
];
|
|
26
|
+
ctx.path("guide").attr("d", feeds.map((f) => poly(cam, f)).join(""));
|
|
27
|
+
const stages = [];
|
|
28
|
+
const stage = (boxes) => {
|
|
29
|
+
stages.push(boxes);
|
|
30
|
+
return boxes;
|
|
31
|
+
};
|
|
32
|
+
stage([ctx.box(1, 1.3, 3.4, 3.3, 0, 2.4, { r: 0.3, b: 0.2 }), ctx.box(1, 5, 3.4, 7, 0, 0.6, { r: 0.25, b: 0.15 }), ctx.box(1, 8.5, 3.4, 10.4, 0, 0.3, { r: 0.2, b: 0.12 })]);
|
|
33
|
+
// The processor behind the belt.
|
|
34
|
+
const proc = ctx.solid();
|
|
35
|
+
const procTop = ctx.path("crease");
|
|
36
|
+
// The belt on its legs, the scanner's back posts.
|
|
37
|
+
for (const x of [10.5, 14.5, 18.5])
|
|
38
|
+
ctx.box(x, 5.35, x + 0.3, 5.65, 0, 0.5, { r: 0.06, b: 0 }).draw(cam);
|
|
39
|
+
ctx.box(9.8, 5.2, 20.6, 6.8, 0.5, zr, { r: 0.35, b: 0.2 }).draw(cam);
|
|
40
|
+
for (const x of [10.5, 14.5, 18.5])
|
|
41
|
+
ctx.box(x, 6.35, x + 0.3, 6.65, 0, 0.5, { r: 0.06, b: 0 }).draw(cam);
|
|
42
|
+
ctx.box(14.1, 4.4, 14.6, 4.9, 0, 2.6, { r: 0.1, b: 0 }).draw(cam);
|
|
43
|
+
// Blocks on the feeds and the belt.
|
|
44
|
+
const blocks = [];
|
|
45
|
+
feeds.forEach((route, i) => {
|
|
46
|
+
for (let k = 0; k < 2; k++) {
|
|
47
|
+
const g = ctx.g();
|
|
48
|
+
blocks.push({ g, solid: ctx.solid(g), route, k: k + i * 0.33, n: 2, speed: 0.22, belt: false });
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const belt = [
|
|
52
|
+
[9.6, 6, zr],
|
|
53
|
+
[21.2, 6, zr],
|
|
54
|
+
];
|
|
55
|
+
for (let k = 0; k < 5; k++) {
|
|
56
|
+
const g = ctx.g();
|
|
57
|
+
blocks.push({ g, solid: ctx.solid(g), route: belt, k, n: 5, speed: 0.12, belt: true });
|
|
58
|
+
}
|
|
59
|
+
stage([ctx.box(7, 4.8, 9.6, 7.2, 0, 1.6, { r: 0.3, b: 0.2 }), ctx.box(6.8, 4.6, 9.8, 7.4, 1.6, 2.2, { r: 0.35, b: 0.25 })]);
|
|
60
|
+
stage([ctx.box(14.1, 7.1, 14.6, 7.6, 0, 2.6, { r: 0.1, b: 0 }), ctx.box(13.95, 4.4, 14.75, 7.6, 2.6, 3.0, { r: 0.15, b: 0.1 })]);
|
|
61
|
+
const beam = ctx.path("crease");
|
|
62
|
+
const ware = [];
|
|
63
|
+
const wareRing = circle(22.6, 6, 1.7, 36);
|
|
64
|
+
const wareInner = circle(22.6, 6, 1.42, 36);
|
|
65
|
+
const wareSolids = [0, 1, 2].map(() => ctx.solid());
|
|
66
|
+
stage(ware);
|
|
67
|
+
stage([ctx.box(26.2, 4.2, 29.4, 7.8, 0, 0.35, { r: 0.3, b: 0.2 }), ctx.box(26.5, 4.9, 29.1, 5.2, 0.35, 2.7, { r: 0.2, b: 0.1 })]);
|
|
68
|
+
const chart = ctx.path("mid");
|
|
69
|
+
let clock = 0;
|
|
70
|
+
const vals = [0.4, 0.7, 0.55, 0.95, 0.8, 1.3, 1.5];
|
|
71
|
+
const draw = () => {
|
|
72
|
+
// The scanner's bar is the one bright line.
|
|
73
|
+
stages.forEach((s, i) => {
|
|
74
|
+
s.forEach((b) => b.draw(cam).hi(i === 2 && b === s[s.length - 1]));
|
|
75
|
+
if (i === 3) {
|
|
76
|
+
wareSolids.forEach((sol, k) => sol.draw(cam, wareRing, wareInner, k * 0.95, k * 0.95 + 0.8));
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
proc.draw(cam, circle(16.5, 2.4, 1.2, 32), circle(16.5, 2.4, 0.95, 32), 0, 2.6);
|
|
80
|
+
const a = clock * 1.4;
|
|
81
|
+
procTop.attr("d", poly(cam, [[16.5 - 0.8 * Math.cos(a), 2.4 - 0.8 * Math.sin(a), 2.6], [16.5 + 0.8 * Math.cos(a), 2.4 + 0.8 * Math.sin(a), 2.6]]));
|
|
82
|
+
beam.attr("d", [5.3, 6, 6.7].map((y) => poly(cam, [[14.35, y, 2.6], [14.35, y, zr + 0.5]])).join(""));
|
|
83
|
+
// Blocks: raw cubes before the scanner, flat tiles after; cut where they enter a machine (rule 06).
|
|
84
|
+
for (const b of blocks) {
|
|
85
|
+
const t = (clock * b.speed + b.k / b.n) % 1;
|
|
86
|
+
const [x, y, z] = along(b.route, t);
|
|
87
|
+
const done = b.belt && x > 14.35;
|
|
88
|
+
const s = done ? 0.36 : 0.26;
|
|
89
|
+
const x0 = Math.max(x - s, b.belt ? 9.6 : 3.4);
|
|
90
|
+
const x1 = Math.min(x + s, b.belt ? 20.9 : 7);
|
|
91
|
+
if (x1 - x0 < 0.05) {
|
|
92
|
+
b.solid.sil.attr("d", null);
|
|
93
|
+
b.solid.crease.attr("d", null);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
b.solid.draw(cam, rrect(x0, y - s, x1, y + s, 0.08, 2), null, z, z + (done ? 0.12 : 0.5));
|
|
97
|
+
}
|
|
98
|
+
const f = frontFace(cam, 26.5, 5.2, 0.35);
|
|
99
|
+
chart.attr("d", vals.map((v, i) => `${i ? "L" : "M"}${f(0.35 + i * 0.32, 0.4 + v).join(" ")}`).join("") + faceLine(f, [0.3, 0.35], [2.3, 0.35]));
|
|
100
|
+
};
|
|
101
|
+
let next = 0;
|
|
102
|
+
ctx.loop((dt) => {
|
|
103
|
+
if (!ctx.reduced)
|
|
104
|
+
clock += dt;
|
|
105
|
+
// The dashboard takes a new reading every so often.
|
|
106
|
+
if (clock > next) {
|
|
107
|
+
next = clock + 1.6;
|
|
108
|
+
vals.shift();
|
|
109
|
+
vals.push(0.3 + ((clock * 37) % 1) * 1.2);
|
|
110
|
+
}
|
|
111
|
+
draw();
|
|
112
|
+
return true;
|
|
113
|
+
});
|
|
114
|
+
draw();
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
export default figure;
|
|
@@ -0,0 +1,7 @@
|
|
|
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 { type Figure } from "../kernel.js";
|
|
6
|
+
declare const figure: Figure;
|
|
7
|
+
export default figure;
|
|
@@ -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;
|