@zyro-sec/ui 1.0.2 → 1.0.3
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/AGENTS.md +29 -29
- package/LICENSE +21 -21
- package/bunfig.toml +2 -2
- package/package.json +2 -2
- package/perf/motion.bench.ts +14 -14
- package/perf/motion.ts +16 -16
- package/script/build-oc2-v2-overrides.ts +38 -38
- package/script/colors.txt +288 -288
- package/script/generate-spinner.ts +121 -121
- package/script/pack.ts +5 -5
- package/script/tailwind.ts +24 -24
- package/src/actions/button/button.css +346 -346
- package/src/actions/button/button.stories.tsx +158 -158
- package/src/actions/button/button.tsx +56 -56
- package/src/actions/icon-button/icon-button.css +128 -128
- package/src/actions/icon-button/icon-button.stories.tsx +122 -122
- package/src/actions/icon-button/icon-button.tsx +46 -46
- package/src/actions/split-button/split-button.css +99 -99
- package/src/actions/split-button/split-button.stories.tsx +59 -59
- package/src/actions/split-button/split-button.tsx +51 -51
- package/src/actions/submit.css +81 -81
- package/src/assets/favicon/favicon-v3.svg +6 -6
- package/src/assets/favicon/favicon.svg +6 -6
- package/src/assets/favicon/site.webmanifest +24 -24
- package/src/assets/icons/app/android-studio.svg +369 -369
- package/src/assets/icons/app/antigravity.svg +97 -97
- package/src/assets/icons/app/cursor.svg +16 -16
- package/src/assets/icons/app/file-explorer.svg +20 -20
- package/src/assets/icons/app/ghostty.svg +13 -13
- package/src/assets/icons/app/iterm2.svg +13 -13
- package/src/assets/icons/app/powershell.svg +14 -14
- package/src/assets/icons/app/sublimetext.svg +17 -17
- package/src/assets/icons/app/vscode.svg +39 -39
- package/src/assets/icons/app/windows-terminal.svg +6 -6
- package/src/assets/icons/app/zed-dark.svg +15 -15
- package/src/assets/icons/app/zed.svg +15 -15
- package/src/assets/icons/file-types/auto_light.svg +12 -12
- package/src/assets/icons/file-types/cursor.svg +1 -1
- package/src/assets/icons/file-types/cursor_light.svg +1 -1
- package/src/assets/icons/file-types/drone_light.svg +4 -4
- package/src/assets/icons/file-types/folder-admin-open.svg +6 -6
- package/src/assets/icons/file-types/folder-admin.svg +6 -6
- package/src/assets/icons/file-types/folder-circleci-open.svg +7 -7
- package/src/assets/icons/file-types/folder-circleci.svg +7 -7
- package/src/assets/icons/file-types/folder-flow-open.svg +6 -6
- package/src/assets/icons/file-types/folder-flow.svg +6 -6
- package/src/assets/icons/file-types/folder-gh-workflows-open.svg +6 -6
- package/src/assets/icons/file-types/folder-gh-workflows.svg +6 -6
- package/src/assets/icons/file-types/folder-github-open.svg +6 -6
- package/src/assets/icons/file-types/folder-github.svg +6 -6
- package/src/assets/icons/file-types/folder-intellij-open.svg +39 -39
- package/src/assets/icons/file-types/folder-intellij.svg +39 -39
- package/src/assets/icons/file-types/folder-macos-open.svg +6 -6
- package/src/assets/icons/file-types/folder-macos.svg +6 -6
- package/src/assets/icons/file-types/folder-next-open.svg +6 -6
- package/src/assets/icons/file-types/folder-next.svg +6 -6
- package/src/assets/icons/file-types/folder-nuxt-open.svg +6 -6
- package/src/assets/icons/file-types/folder-nuxt.svg +6 -6
- package/src/assets/icons/file-types/folder-open.svg +5 -5
- package/src/assets/icons/file-types/folder-scripts-open.svg +6 -6
- package/src/assets/icons/file-types/folder-scripts.svg +6 -6
- package/src/assets/icons/file-types/folder-target-open.svg +10 -10
- package/src/assets/icons/file-types/folder-target.svg +10 -10
- package/src/assets/icons/file-types/folder-turborepo-open.svg +15 -15
- package/src/assets/icons/file-types/folder-turborepo.svg +15 -15
- package/src/assets/icons/file-types/folder-vercel-open.svg +5 -5
- package/src/assets/icons/file-types/folder-vercel.svg +5 -5
- package/src/assets/icons/file-types/folder.svg +5 -5
- package/src/assets/icons/file-types/go_gopher.svg +35 -35
- package/src/assets/icons/file-types/nano-staged_light.svg +4 -4
- package/src/assets/icons/file-types/opa.svg +9 -9
- package/src/assets/icons/file-types/quarto.svg +5 -5
- package/src/assets/icons/file-types/rome.svg +6 -6
- package/src/assets/icons/file-types/stitches_light.svg +10 -10
- package/src/assets/icons/file-types/stylelint_light.svg +13 -13
- package/src/assets/icons/file-types/unocss.svg +5 -5
- package/src/assets/icons/file-types/vlang.svg +6 -6
- package/src/assets/icons/provider/302ai.svg +6 -6
- package/src/assets/icons/provider/abacus.svg +14 -14
- package/src/assets/icons/provider/aihubmix.svg +3 -3
- package/src/assets/icons/provider/alibaba-cn.svg +3 -3
- package/src/assets/icons/provider/alibaba-coding-plan-cn.svg +3 -3
- package/src/assets/icons/provider/alibaba-coding-plan.svg +3 -3
- package/src/assets/icons/provider/alibaba.svg +3 -3
- package/src/assets/icons/provider/amazon-bedrock.svg +3 -3
- package/src/assets/icons/provider/anthropic.svg +2 -2
- package/src/assets/icons/provider/azure-cognitive-services.svg +24 -24
- package/src/assets/icons/provider/azure.svg +3 -3
- package/src/assets/icons/provider/bailing.svg +3 -3
- package/src/assets/icons/provider/baseten.svg +3 -3
- package/src/assets/icons/provider/berget.svg +2 -2
- package/src/assets/icons/provider/cerebras.svg +4 -4
- package/src/assets/icons/provider/chutes.svg +24 -24
- package/src/assets/icons/provider/clarifai.svg +24 -24
- package/src/assets/icons/provider/claude-agent.svg +3 -3
- package/src/assets/icons/provider/cloudferro-sherlock.svg +4 -4
- package/src/assets/icons/provider/cloudflare-ai-gateway.svg +4 -4
- package/src/assets/icons/provider/cloudflare-workers-ai.svg +4 -4
- package/src/assets/icons/provider/cohere.svg +5 -5
- package/src/assets/icons/provider/cortecs.svg +24 -24
- package/src/assets/icons/provider/deepinfra.svg +4 -4
- package/src/assets/icons/provider/deepseek.svg +3 -3
- package/src/assets/icons/provider/digitalocean.svg +6 -6
- package/src/assets/icons/provider/dinference.svg +1 -1
- package/src/assets/icons/provider/drun.svg +8 -8
- package/src/assets/icons/provider/evroc.svg +2 -2
- package/src/assets/icons/provider/fastrouter.svg +3 -3
- package/src/assets/icons/provider/fireworks-ai.svg +3 -3
- package/src/assets/icons/provider/firmware.svg +18 -18
- package/src/assets/icons/provider/friendli.svg +3 -3
- package/src/assets/icons/provider/github-copilot.svg +3 -3
- package/src/assets/icons/provider/github-models.svg +3 -3
- package/src/assets/icons/provider/gitlab.svg +3 -3
- package/src/assets/icons/provider/google-vertex-anthropic.svg +24 -24
- package/src/assets/icons/provider/google-vertex.svg +10 -10
- package/src/assets/icons/provider/google.svg +3 -3
- package/src/assets/icons/provider/groq.svg +3 -3
- package/src/assets/icons/provider/helicone.svg +6 -6
- package/src/assets/icons/provider/huggingface.svg +3 -3
- package/src/assets/icons/provider/iflowcn.svg +3 -3
- package/src/assets/icons/provider/inception.svg +4 -4
- package/src/assets/icons/provider/inference.svg +3 -3
- package/src/assets/icons/provider/io-net.svg +5 -5
- package/src/assets/icons/provider/jiekou.svg +4 -4
- package/src/assets/icons/provider/kilo.svg +4 -4
- package/src/assets/icons/provider/kimi-for-coding.svg +3 -3
- package/src/assets/icons/provider/kuae-cloud-coding-plan.svg +3 -3
- package/src/assets/icons/provider/llama.svg +3 -3
- package/src/assets/icons/provider/lmstudio.svg +24 -24
- package/src/assets/icons/provider/lucidquery.svg +3 -3
- package/src/assets/icons/provider/meganova.svg +3 -3
- package/src/assets/icons/provider/meituan.svg +6 -6
- package/src/assets/icons/provider/meta.svg +3 -3
- package/src/assets/icons/provider/minimax-cn-coding-plan.svg +24 -24
- package/src/assets/icons/provider/minimax-cn.svg +3 -3
- package/src/assets/icons/provider/minimax-coding-plan.svg +24 -24
- package/src/assets/icons/provider/minimax.svg +3 -3
- package/src/assets/icons/provider/mistral.svg +3 -3
- package/src/assets/icons/provider/moark.svg +3 -3
- package/src/assets/icons/provider/modelscope.svg +5 -5
- package/src/assets/icons/provider/moonshotai-cn.svg +3 -3
- package/src/assets/icons/provider/moonshotai.svg +3 -3
- package/src/assets/icons/provider/morph.svg +24 -24
- package/src/assets/icons/provider/nano-gpt.svg +2 -2
- package/src/assets/icons/provider/nebius.svg +4 -4
- package/src/assets/icons/provider/nova.svg +3 -3
- package/src/assets/icons/provider/novita-ai.svg +10 -10
- package/src/assets/icons/provider/nvidia.svg +3 -3
- package/src/assets/icons/provider/ollama-cloud.svg +7 -7
- package/src/assets/icons/provider/openai.svg +3 -3
- package/src/assets/icons/provider/opencode-go.svg +3 -3
- package/src/assets/icons/provider/opencode.svg +3 -3
- package/src/assets/icons/provider/openrouter.svg +3 -3
- package/src/assets/icons/provider/ovhcloud.svg +3 -3
- package/src/assets/icons/provider/perplexity-agent.svg +3 -3
- package/src/assets/icons/provider/perplexity.svg +3 -3
- package/src/assets/icons/provider/poe.svg +7 -7
- package/src/assets/icons/provider/privatemode-ai.svg +4 -4
- package/src/assets/icons/provider/qihang-ai.svg +8 -8
- package/src/assets/icons/provider/qiniu-ai.svg +7 -7
- package/src/assets/icons/provider/reflection.svg +3 -3
- package/src/assets/icons/provider/requesty.svg +24 -24
- package/src/assets/icons/provider/sap-ai-core.svg +24 -24
- package/src/assets/icons/provider/scaleway.svg +5 -5
- package/src/assets/icons/provider/siliconflow-cn.svg +3 -3
- package/src/assets/icons/provider/siliconflow.svg +3 -3
- package/src/assets/icons/provider/stackit.svg +4 -4
- package/src/assets/icons/provider/stepfun.svg +16 -16
- package/src/assets/icons/provider/submodel.svg +3 -3
- package/src/assets/icons/provider/synthetic.svg +24 -24
- package/src/assets/icons/provider/tencent-coding-plan.svg +5 -5
- package/src/assets/icons/provider/tencent.svg +3 -3
- package/src/assets/icons/provider/thinkingmachines.svg +3 -3
- package/src/assets/icons/provider/togetherai.svg +4 -4
- package/src/assets/icons/provider/upstage.svg +24 -24
- package/src/assets/icons/provider/v0.svg +3 -3
- package/src/assets/icons/provider/venice.svg +4 -4
- package/src/assets/icons/provider/vercel.svg +3 -3
- package/src/assets/icons/provider/vivgrid.svg +4 -4
- package/src/assets/icons/provider/vultr.svg +6 -6
- package/src/assets/icons/provider/wandb.svg +24 -24
- package/src/assets/icons/provider/xai.svg +3 -3
- package/src/assets/icons/provider/xiaomi.svg +3 -3
- package/src/assets/icons/provider/zai-coding-plan.svg +3 -3
- package/src/assets/icons/provider/zai.svg +3 -3
- package/src/assets/icons/provider/zenmux.svg +4 -4
- package/src/assets/icons/provider/zhipuai-coding-plan.svg +3 -3
- package/src/assets/icons/provider/zhipuai.svg +3 -3
- package/src/components/animated-number-machine.ts +214 -214
- package/src/components/animated-number.css +110 -110
- package/src/components/animated-number.stories.tsx +35 -35
- package/src/components/animated-number.tsx +202 -202
- package/src/components/app-icon.css +5 -5
- package/src/components/app-icon.stories.tsx +73 -73
- package/src/components/app-icon.tsx +89 -89
- package/src/components/app-icons/sprite.svg +114 -114
- package/src/components/app-icons/types.ts +22 -22
- package/src/components/card.css +94 -94
- package/src/components/card.stories.tsx +101 -101
- package/src/components/card.tsx +145 -145
- package/src/components/collapsible.css +139 -139
- package/src/components/collapsible.stories.tsx +76 -76
- package/src/components/collapsible.tsx +62 -62
- package/src/components/context-menu.css +134 -134
- package/src/components/context-menu.stories.tsx +150 -150
- package/src/components/context-menu.tsx +342 -342
- package/src/components/diagram-preview.css +95 -95
- package/src/components/diagram-preview.stories.tsx +62 -62
- package/src/components/diagram-preview.tsx +332 -332
- package/src/components/dock-surface.css +30 -30
- package/src/components/dock-surface.stories.tsx +26 -26
- package/src/components/dock-surface.tsx +40 -40
- package/src/components/document-surface.css +37 -37
- package/src/components/document-surface.stories.tsx +42 -42
- package/src/components/document-surface.tsx +6 -6
- package/src/components/error-details.css +41 -41
- package/src/components/error-details.stories.tsx +72 -72
- package/src/components/error-details.tsx +13 -13
- package/src/components/favicon.stories.tsx +49 -49
- package/src/components/favicon.tsx +13 -13
- package/src/components/file-icon-machine.ts +78 -78
- package/src/components/file-icon.css +6 -6
- package/src/components/file-icon.stories.tsx +93 -93
- package/src/components/file-icon.tsx +186 -186
- package/src/components/file-icons/choose-icon-name.ts +574 -574
- package/src/components/file-icons/sprite.svg +11707 -11707
- package/src/components/file-icons/types.ts +1095 -1095
- package/src/components/font.stories.tsx +48 -48
- package/src/components/font.tsx +1 -1
- package/src/components/hover-card.css +61 -61
- package/src/components/hover-card.stories.tsx +79 -79
- package/src/components/hover-card.tsx +32 -32
- package/src/components/image-flight-machine.ts +247 -247
- package/src/components/image-flight.ts +161 -161
- package/src/components/image-preview.css +202 -202
- package/src/components/image-preview.stories.tsx +392 -392
- package/src/components/image-preview.tsx +908 -908
- package/src/components/image-zoom-machine.ts +191 -191
- package/src/components/image-zoom.ts +124 -124
- package/src/components/list.css +331 -331
- package/src/components/list.stories.tsx +221 -221
- package/src/components/list.tsx +322 -322
- package/src/components/logo.css +4 -4
- package/src/components/logo.stories.tsx +62 -62
- package/src/components/logo.tsx +62 -62
- package/src/components/menu-scroll.css +70 -70
- package/src/components/menu-scroll.stories.tsx +73 -73
- package/src/components/menu-scroll.tsx +202 -202
- package/src/components/motion-spring.tsx +65 -65
- package/src/components/popover-machine.ts +198 -198
- package/src/components/popover.css +66 -66
- package/src/components/popover.stories.tsx +84 -84
- package/src/components/popover.tsx +234 -234
- package/src/components/preview-controls.css +28 -28
- package/src/components/preview-controls.stories.tsx +40 -40
- package/src/components/preview-controls.tsx +53 -53
- package/src/components/progress.css +63 -63
- package/src/components/progress.stories.tsx +69 -69
- package/src/components/progress.tsx +39 -39
- package/src/components/provider-icon.css +5 -5
- package/src/components/provider-icon.stories.tsx +75 -75
- package/src/components/provider-icon.tsx +31 -31
- package/src/components/provider-icons/sprite.svg +1131 -1131
- package/src/components/provider-icons/types.ts +111 -111
- package/src/components/resize-handle-machine.ts +174 -174
- package/src/components/resize-handle.css +81 -81
- package/src/components/resize-handle.stories.tsx +81 -81
- package/src/components/resize-handle.tsx +164 -164
- package/src/components/rolling-number.css +24 -24
- package/src/components/rolling-number.stories.tsx +23 -23
- package/src/components/rolling-number.tsx +135 -135
- package/src/components/scroll-view-machine.ts +244 -244
- package/src/components/scroll-view.css +99 -99
- package/src/components/scroll-view.stories.tsx +68 -68
- package/src/components/scroll-view.tsx +653 -653
- package/src/components/spinner-frames.css +6 -6
- package/src/components/spinner-radar.ts +150 -150
- package/src/components/spinner.css +38 -38
- package/src/components/spinner.stories.tsx +40 -40
- package/src/components/spinner.tsx +43 -43
- package/src/components/sticky-accordion-header.css +11 -11
- package/src/components/sticky-accordion-header.stories.tsx +64 -64
- package/src/components/sticky-accordion-header.tsx +18 -18
- package/src/components/text-field-machine.ts +102 -102
- package/src/components/text-field.css +134 -134
- package/src/components/text-field.stories.tsx +132 -132
- package/src/components/text-field.tsx +196 -196
- package/src/components/text-reveal-machine.ts +184 -184
- package/src/components/text-reveal.css +150 -150
- package/src/components/text-reveal.stories.tsx +363 -363
- package/src/components/text-reveal.tsx +165 -165
- package/src/components/text-strikethrough.css +27 -27
- package/src/components/text-strikethrough.stories.tsx +296 -296
- package/src/components/text-strikethrough.tsx +92 -92
- package/src/components/thinking-heading.stories.tsx +900 -900
- package/src/components/truncated-text.css +25 -25
- package/src/components/truncated-text.stories.tsx +37 -37
- package/src/components/truncated-text.tsx +30 -30
- package/src/components/typewriter-machine.ts +134 -134
- package/src/components/typewriter.css +14 -14
- package/src/components/typewriter.stories.tsx +51 -51
- package/src/components/typewriter.tsx +70 -70
- package/src/context/dialog-machine.ts +281 -281
- package/src/context/dialog.tsx +376 -376
- package/src/context/file.tsx +11 -11
- package/src/context/focus-rescue.tsx +230 -230
- package/src/context/helper.tsx +43 -43
- package/src/context/highlight-theme.tsx +66 -66
- package/src/context/i18n.tsx +144 -144
- package/src/context/index.ts +7 -7
- package/src/context/marked-base.tsx +67 -67
- package/src/context/marked-parser.tsx +154 -154
- package/src/context/overlay-focus.tsx +90 -90
- package/src/custom-elements.d.ts +17 -17
- package/src/data-display/accordion/accordion.css +130 -130
- package/src/data-display/accordion/accordion.stories.tsx +76 -76
- package/src/data-display/accordion/accordion.tsx +106 -106
- package/src/data-display/avatar/avatar.css +70 -70
- package/src/data-display/avatar/avatar.stories.tsx +48 -48
- package/src/data-display/avatar/avatar.tsx +63 -63
- package/src/data-display/badge/badge.css +63 -63
- package/src/data-display/badge/badge.stories.tsx +75 -75
- package/src/data-display/badge/badge.tsx +26 -26
- package/src/data-display/diff-changes/diff-changes.css +47 -47
- package/src/data-display/diff-changes/diff-changes.stories.tsx +63 -63
- package/src/data-display/diff-changes/diff-changes.tsx +43 -43
- package/src/data-display/keybind/keybind.css +84 -84
- package/src/data-display/keybind/keybind.stories.tsx +77 -77
- package/src/data-display/keybind/keybind.tsx +31 -31
- package/src/data-display/line-comment/line-comment.css +341 -341
- package/src/data-display/line-comment/line-comment.stories.tsx +288 -288
- package/src/data-display/line-comment/line-comment.tsx +554 -554
- package/src/data-display/line-comment/machine.ts +400 -400
- package/src/data-display/line-comment/quote-check.svg +3 -3
- package/src/data-display/project-avatar/animation-machine.ts +182 -182
- package/src/data-display/project-avatar/animation.ts +133 -133
- package/src/data-display/project-avatar/generated.ts +225 -225
- package/src/data-display/project-avatar/procedural-craft.ts +1079 -1079
- package/src/data-display/project-avatar/procedural-kit.ts +244 -244
- package/src/data-display/project-avatar/procedural-machine.ts +924 -924
- package/src/data-display/project-avatar/procedural-world.ts +1542 -1542
- package/src/data-display/project-avatar/procedural.ts +1563 -1563
- package/src/data-display/project-avatar/project-avatar.css +189 -189
- package/src/data-display/project-avatar/project-avatar.stories.tsx +102 -102
- package/src/data-display/project-avatar/project-avatar.tsx +246 -246
- package/src/data-display/project-avatar/project-icon-styles.stories.tsx +772 -772
- package/src/feedback/activity-ring/activity-ring.css +5 -5
- package/src/feedback/activity-ring/activity-ring.stories.tsx +20 -20
- package/src/feedback/activity-ring/activity-ring.tsx +15 -15
- package/src/feedback/loader/loader.css +32 -32
- package/src/feedback/loader/loader.stories.tsx +44 -44
- package/src/feedback/loader/loader.tsx +34 -34
- package/src/feedback/progress-circle/progress-circle.css +28 -28
- package/src/feedback/progress-circle/progress-circle.stories.tsx +56 -56
- package/src/feedback/progress-circle/progress-circle.tsx +64 -64
- package/src/feedback/toast/description.ts +10 -10
- package/src/feedback/toast/machine.ts +115 -115
- package/src/feedback/toast/toast.css +234 -234
- package/src/feedback/toast/toast.stories.tsx +186 -186
- package/src/feedback/toast/toast.tsx +317 -317
- package/src/forms/checkbox/checkbox-compact.css +170 -170
- package/src/forms/checkbox/checkbox.css +125 -125
- package/src/forms/checkbox/checkbox.stories.tsx +104 -104
- package/src/forms/checkbox/checkbox.tsx +119 -119
- package/src/forms/field/field.css +94 -94
- package/src/forms/field/field.stories.tsx +129 -129
- package/src/forms/field/field.tsx +271 -271
- package/src/forms/inline-input/inline-input.css +16 -16
- package/src/forms/inline-input/inline-input.stories.tsx +37 -37
- package/src/forms/inline-input/inline-input.tsx +26 -26
- package/src/forms/radio/radio.css +218 -218
- package/src/forms/radio/radio.stories.tsx +145 -145
- package/src/forms/radio/radio.tsx +95 -95
- package/src/forms/redirect-paste/redirect-paste.stories.tsx +101 -101
- package/src/forms/redirect-paste/redirect-paste.tsx +92 -92
- package/src/forms/search-list/navigation.ts +54 -54
- package/src/forms/search-list/search-list.css +249 -249
- package/src/forms/search-list/search-list.stories.tsx +108 -108
- package/src/forms/search-list/search-list.tsx +463 -463
- package/src/forms/select/machine.ts +81 -81
- package/src/forms/select/select.css +312 -312
- package/src/forms/select/select.stories.tsx +208 -208
- package/src/forms/select/select.tsx +281 -281
- package/src/forms/switch/switch.css +281 -281
- package/src/forms/switch/switch.stories.tsx +97 -97
- package/src/forms/switch/switch.tsx +35 -35
- package/src/forms/text-input/text-input.css +229 -229
- package/src/forms/text-input/text-input.stories.tsx +220 -220
- package/src/forms/text-input/text-input.tsx +115 -115
- package/src/forms/textarea/textarea.css +103 -103
- package/src/forms/textarea/textarea.stories.tsx +137 -137
- package/src/forms/textarea/textarea.tsx +33 -33
- package/src/forms/typeahead/controller.ts +59 -59
- package/src/forms/typeahead/machine.ts +253 -253
- package/src/forms/typeahead/typeahead.stories.tsx +113 -113
- package/src/forms/typeahead/typeahead.tsx +239 -239
- package/src/hooks/auto-scroll-machine.ts +261 -261
- package/src/hooks/create-auto-scroll.tsx +196 -196
- package/src/hooks/index.ts +5 -5
- package/src/hooks/list-machine.ts +359 -359
- package/src/hooks/spin-phase.ts +116 -116
- package/src/hooks/use-filtered-list.tsx +132 -132
- package/src/i18n/am.ts +384 -384
- package/src/i18n/ar.ts +547 -547
- package/src/i18n/az.ts +386 -386
- package/src/i18n/bg.ts +386 -386
- package/src/i18n/bn.ts +393 -393
- package/src/i18n/br.ts +444 -444
- package/src/i18n/bs.ts +445 -445
- package/src/i18n/ca.ts +423 -423
- package/src/i18n/cs.ts +457 -457
- package/src/i18n/da.ts +407 -407
- package/src/i18n/de.ts +414 -414
- package/src/i18n/dv.ts +395 -395
- package/src/i18n/dz.ts +393 -393
- package/src/i18n/el.ts +388 -388
- package/src/i18n/en.ts +433 -433
- package/src/i18n/es.ts +443 -443
- package/src/i18n/et.ts +386 -386
- package/src/i18n/fa.ts +388 -388
- package/src/i18n/fi.ts +388 -388
- package/src/i18n/fo.ts +388 -388
- package/src/i18n/fr.ts +447 -447
- package/src/i18n/he.ts +422 -422
- package/src/i18n/hi.ts +392 -392
- package/src/i18n/hr.ts +422 -422
- package/src/i18n/hu.ts +388 -388
- package/src/i18n/hy.ts +389 -389
- package/src/i18n/id.ts +411 -411
- package/src/i18n/is.ts +388 -388
- package/src/i18n/it.ts +425 -425
- package/src/i18n/ja.ts +406 -406
- package/src/i18n/ka.ts +388 -388
- package/src/i18n/km.ts +389 -389
- package/src/i18n/ko.ts +408 -408
- package/src/i18n/lo.ts +387 -387
- package/src/i18n/lt.ts +457 -457
- package/src/i18n/lv.ts +421 -421
- package/src/i18n/mk.ts +387 -387
- package/src/i18n/mn.ts +386 -386
- package/src/i18n/ms.ts +389 -389
- package/src/i18n/my.ts +389 -389
- package/src/i18n/ne.ts +393 -393
- package/src/i18n/nl.ts +388 -388
- package/src/i18n/no.ts +413 -413
- package/src/i18n/pa.ts +394 -394
- package/src/i18n/pl.ts +476 -476
- package/src/i18n/ro.ts +423 -423
- package/src/i18n/ru.ts +475 -475
- package/src/i18n/si.ts +390 -390
- package/src/i18n/sk.ts +457 -457
- package/src/i18n/sl.ts +457 -457
- package/src/i18n/sq.ts +387 -387
- package/src/i18n/sr.ts +422 -422
- package/src/i18n/sv.ts +388 -388
- package/src/i18n/tg.ts +390 -390
- package/src/i18n/th.ts +407 -407
- package/src/i18n/tk.ts +386 -386
- package/src/i18n/tr.ts +412 -412
- package/src/i18n/uk.ts +480 -480
- package/src/i18n/ur.ts +394 -394
- package/src/i18n/uz.ts +390 -390
- package/src/i18n/vi.ts +387 -387
- package/src/i18n/zh.ts +408 -408
- package/src/i18n/zht.ts +408 -408
- package/src/icons/catalog.ts +638 -638
- package/src/icons/icon/icon.css +3 -3
- package/src/icons/icon/icon.stories.tsx +131 -131
- package/src/icons/icon/icon.tsx +106 -106
- package/src/icons/registry.ts +217 -217
- package/src/layout/divider/divider.css +11 -11
- package/src/layout/divider/divider.stories.tsx +38 -38
- package/src/layout/divider/divider.tsx +21 -21
- package/src/motion/README.md +113 -113
- package/src/motion/index.ts +13 -13
- package/src/motion/loop.ts +139 -139
- package/src/motion/reduced.ts +66 -66
- package/src/motion/slider.ts +45 -45
- package/src/motion/solid.ts +309 -309
- package/src/motion/spring.ts +125 -125
- package/src/motion/velocity.ts +46 -46
- package/src/motion/waapi.ts +89 -89
- package/src/motion-tuning-features.ts +161 -161
- package/src/motion-tuning-fields.ts +42 -42
- package/src/motion-tuning.ts +323 -323
- package/src/navigation/menu/machine.ts +109 -109
- package/src/navigation/menu/menu.css +313 -313
- package/src/navigation/menu/menu.stories.tsx +328 -328
- package/src/navigation/menu/menu.tsx +600 -600
- package/src/navigation/menu/submenu-machine.ts +67 -67
- package/src/navigation/segmented-control/machine.ts +72 -72
- package/src/navigation/segmented-control/segmented-control.css +113 -113
- package/src/navigation/segmented-control/segmented-control.stories.tsx +115 -115
- package/src/navigation/segmented-control/segmented-control.tsx +396 -396
- package/src/navigation/tab-state-indicator.stories.tsx +24 -24
- package/src/navigation/tab-state-indicator.tsx +38 -38
- package/src/navigation/tabs/tabs-current.css +244 -244
- package/src/navigation/tabs/tabs.css +676 -676
- package/src/navigation/tabs/tabs.stories.tsx +193 -193
- package/src/navigation/tabs/tabs.tsx +212 -212
- package/src/overlays/dialog/dialog.css +194 -194
- package/src/overlays/dialog/dialog.stories.tsx +365 -365
- package/src/overlays/dialog/dialog.tsx +192 -192
- package/src/overlays/mcp-sign-in/machine.ts +343 -343
- package/src/overlays/mcp-sign-in/mcp-sign-in.ts +159 -159
- package/src/overlays/tooltip/machine.ts +312 -312
- package/src/overlays/tooltip/tooltip.css +102 -102
- package/src/overlays/tooltip/tooltip.stories.tsx +155 -155
- package/src/overlays/tooltip/tooltip.tsx +290 -290
- package/src/storybook/fixtures.ts +51 -51
- package/src/storybook/scaffold.tsx +65 -65
- package/src/styles/animations.css +13 -13
- package/src/styles/base.css +441 -441
- package/src/styles/blue-tokens.stories.tsx +215 -215
- package/src/styles/colors.css +772 -772
- package/src/styles/file-tree.css +285 -285
- package/src/styles/index.css +42 -42
- package/src/styles/scrollbar.css +79 -79
- package/src/styles/tailwind/colors.css +288 -288
- package/src/styles/tailwind/index.css +113 -113
- package/src/styles/tailwind/utilities.css +17 -17
- package/src/styles/theme.css +640 -640
- package/src/styles/tokens/colors.css +172 -172
- package/src/styles/tokens/index.css +2 -2
- package/src/styles/tokens/theme.css +522 -522
- package/src/styles/utilities.css +93 -93
- package/src/theme/color.ts +290 -290
- package/src/theme/context.tsx +361 -361
- package/src/theme/desktop-theme.schema.json +168 -168
- package/src/theme/index.ts +35 -35
- package/src/theme/machine.ts +508 -508
- package/src/theme/resolve.ts +561 -561
- package/src/theme/themes/amoled.json +49 -49
- package/src/theme/themes/aura.json +51 -51
- package/src/theme/themes/ayu.json +51 -51
- package/src/theme/themes/carbonfox.json +53 -53
- package/src/theme/themes/catppuccin-frappe.json +65 -65
- package/src/theme/themes/catppuccin-macchiato.json +65 -65
- package/src/theme/themes/catppuccin.json +45 -45
- package/src/theme/themes/cobalt2.json +87 -87
- package/src/theme/themes/cursor.json +91 -91
- package/src/theme/themes/dracula.json +49 -49
- package/src/theme/themes/everforest.json +89 -89
- package/src/theme/themes/flexoki.json +86 -86
- package/src/theme/themes/github.json +85 -85
- package/src/theme/themes/gruvbox.json +45 -45
- package/src/theme/themes/kanagawa.json +89 -89
- package/src/theme/themes/lucent-orng.json +87 -87
- package/src/theme/themes/material.json +87 -87
- package/src/theme/themes/matrix.json +113 -113
- package/src/theme/themes/mercury.json +86 -86
- package/src/theme/themes/monokai.json +49 -49
- package/src/theme/themes/nightowl.json +46 -46
- package/src/theme/themes/nord.json +46 -46
- package/src/theme/themes/oc-2.json +509 -509
- package/src/theme/themes/one-dark.json +89 -89
- package/src/theme/themes/onedarkpro.json +45 -45
- package/src/theme/themes/orng.json +87 -87
- package/src/theme/themes/osaka-jade.json +88 -88
- package/src/theme/themes/palenight.json +85 -85
- package/src/theme/themes/rosepine.json +85 -85
- package/src/theme/themes/shadesofpurple.json +51 -51
- package/src/theme/themes/solarized.json +49 -49
- package/src/theme/themes/synthwave84.json +87 -87
- package/src/theme/themes/tokyonight.json +47 -47
- package/src/theme/themes/vercel.json +90 -90
- package/src/theme/themes/vesper.json +51 -51
- package/src/theme/themes/zenburn.json +87 -87
- package/src/theme/types.ts +75 -75
- package/src/theme/v2/avatar.ts +48 -48
- package/src/theme/v2/default-primitives.ts +114 -114
- package/src/theme/v2/foreground.ts +69 -69
- package/src/theme/v2/mapping.ts +180 -180
- package/src/theme/v2/resolve.ts +163 -163
- package/src/typography/slash/slash.css +14 -14
- package/src/typography/slash/slash.stories.tsx +26 -26
- package/src/typography/slash/slash.tsx +16 -16
- package/src/typography/text-shimmer/machine.ts +90 -90
- package/src/typography/text-shimmer/text-shimmer.css +152 -152
- package/src/typography/text-shimmer/text-shimmer.stories.tsx +64 -64
- package/src/typography/text-shimmer/text-shimmer.tsx +81 -81
- package/src/typography/wordmark/wordmark.stories.tsx +19 -19
- package/src/typography/wordmark/wordmark.tsx +73 -73
- package/test/solid-jsx.ts +20 -20
- package/tsconfig.build.json +14 -14
- package/tsconfig.json +23 -23
- package/vite.config.ts +61 -61
- package/src/components/animated-number-machine.test.ts +0 -140
- package/src/components/file-icon-machine.test.ts +0 -52
- package/src/components/image-flight-machine.test.ts +0 -184
- package/src/components/image-flight.test.ts +0 -173
- package/src/components/image-zoom-machine.test.ts +0 -154
- package/src/components/image-zoom.test.ts +0 -96
- package/src/components/popover-machine.test.ts +0 -150
- package/src/components/resize-handle-machine.test.ts +0 -164
- package/src/components/scroll-view-machine.test.ts +0 -141
- package/src/components/scroll-view.test.ts +0 -114
- package/src/components/spinner-radar.test.ts +0 -61
- package/src/components/text-field-machine.test.ts +0 -99
- package/src/components/text-reveal-machine.test.ts +0 -157
- package/src/components/typewriter-machine.test.ts +0 -177
- package/src/context/dialog-machine.test.ts +0 -295
- package/src/context/i18n.test.ts +0 -89
- package/src/context/marked-base.test.ts +0 -75
- package/src/context/marked-parser.test.ts +0 -167
- package/src/context/marked-regression.test.ts +0 -12
- package/src/data-display/line-comment/machine.test.ts +0 -385
- package/src/data-display/project-avatar/animation-machine.test.ts +0 -134
- package/src/data-display/project-avatar/generated.test.ts +0 -50
- package/src/data-display/project-avatar/procedural.test.ts +0 -16
- package/src/data-display/project-avatar/project-avatar.test.ts +0 -21
- package/src/feedback/toast/description.test.ts +0 -20
- package/src/feedback/toast/machine.test.ts +0 -106
- package/src/forms/search-list/navigation.test.ts +0 -40
- package/src/forms/select/machine.test.ts +0 -105
- package/src/forms/typeahead/machine.test.ts +0 -143
- package/src/hooks/auto-scroll-machine.test.ts +0 -212
- package/src/hooks/list-machine.test.ts +0 -263
- package/src/hooks/spin-phase.test.ts +0 -32
- package/src/hooks/use-filtered-list.test.ts +0 -41
- package/src/motion/core.test.ts +0 -328
- package/src/motion-tuning-features.test.ts +0 -129
- package/src/motion-tuning.test.ts +0 -68
- package/src/navigation/menu/machine.test.ts +0 -85
- package/src/navigation/menu/submenu-machine.test.ts +0 -71
- package/src/navigation/segmented-control/segmented-control.test.ts +0 -123
- package/src/overlays/mcp-sign-in/machine.test.ts +0 -215
- package/src/overlays/tooltip/machine.test.ts +0 -214
- package/src/theme/machine.test.ts +0 -498
- package/src/theme/v2/resolve.test.ts +0 -120
- package/src/typography/text-shimmer/machine.test.ts +0 -117
|
@@ -1,1542 +1,1542 @@
|
|
|
1
|
-
// Project icon styles of the world: landscapes and materials, creatures, small objects and emblems. See procedural.ts
|
|
2
|
-
// for the contract.
|
|
3
|
-
|
|
4
|
-
import { mulberry32 } from "./generated"
|
|
5
|
-
import {
|
|
6
|
-
clamp01,
|
|
7
|
-
colors,
|
|
8
|
-
css,
|
|
9
|
-
dither,
|
|
10
|
-
fbm,
|
|
11
|
-
grain,
|
|
12
|
-
int,
|
|
13
|
-
legible,
|
|
14
|
-
luma,
|
|
15
|
-
mix,
|
|
16
|
-
palette,
|
|
17
|
-
pick,
|
|
18
|
-
Pixels,
|
|
19
|
-
prefixed,
|
|
20
|
-
range,
|
|
21
|
-
retry,
|
|
22
|
-
seed,
|
|
23
|
-
shade,
|
|
24
|
-
smoothstep,
|
|
25
|
-
stars,
|
|
26
|
-
tint,
|
|
27
|
-
type Definition,
|
|
28
|
-
} from "./procedural-kit"
|
|
29
|
-
|
|
30
|
-
// Sky top, sky bottom, sun, far, mid, near, snow.
|
|
31
|
-
const RANGES = [
|
|
32
|
-
[0x3b2c5a, 0xf2a7a0, 0xfff1c9, 0x9b7fa6, 0x6a5482, 0x3b2f52, 0xfde6e0],
|
|
33
|
-
[0x4b9be0, 0xcde9f7, 0xfffbe0, 0x8fb3cf, 0x5d7f9b, 0x34505f, 0xffffff],
|
|
34
|
-
[0x1f1d3d, 0xe2725b, 0xffd27a, 0x8a4a62, 0x55304f, 0x2a1b33, 0xf3d2c8],
|
|
35
|
-
[0x0a1028, 0x24305e, 0xeeeedd, 0x2c3a66, 0x1d2850, 0x111833, 0xc9d3ea],
|
|
36
|
-
[0x6fb7e9, 0xe3f3fb, 0xffffff, 0xa4c3d6, 0x5f8f74, 0x2f5a41, 0xffffff],
|
|
37
|
-
[0xe9b872, 0xfbe3b8, 0xfff7e0, 0xd08c5b, 0xa65f3d, 0x6e3b2a, 0xf7d9b0],
|
|
38
|
-
]
|
|
39
|
-
|
|
40
|
-
// Sky, deep, mid, light, foam, sun.
|
|
41
|
-
const SEAS = [
|
|
42
|
-
[0xf6e7c8, 0x0b3954, 0x087e8b, 0x5fb4c8, 0xf4f1ea, 0xe63946],
|
|
43
|
-
[0x9aa5ad, 0x1f2d3a, 0x3d5566, 0x7d94a3, 0xe8eef2, 0xd9dde0],
|
|
44
|
-
[0x9be3f0, 0x006d77, 0x1aa6b7, 0x83e3dc, 0xffffff, 0xffd166],
|
|
45
|
-
[0x0b1030, 0x0a1a3a, 0x16336b, 0x3a62a8, 0xd6e4ff, 0xf0f0d0],
|
|
46
|
-
[0xf6a26b, 0x2d1e4f, 0x5b4b8a, 0xb07cc6, 0xffe0c2, 0xffd166],
|
|
47
|
-
]
|
|
48
|
-
|
|
49
|
-
// Low edge, high edge of the curtains.
|
|
50
|
-
const AURORAS = [
|
|
51
|
-
[0x5cffb0, 0xd36bff],
|
|
52
|
-
[0x6dffa8, 0x3ad6ff],
|
|
53
|
-
[0x7dff8a, 0xff5f8f],
|
|
54
|
-
[0x6fe3ff, 0x8a7dff],
|
|
55
|
-
[0xb6ff6e, 0x5cffd0],
|
|
56
|
-
]
|
|
57
|
-
|
|
58
|
-
const NIGHTS = [0x070b1c, 0x0b1026, 0x0d0a1f, 0x06141a]
|
|
59
|
-
|
|
60
|
-
// Base, vein, clouding.
|
|
61
|
-
const MARBLES = [
|
|
62
|
-
[0xeceae6, 0x7d838b, 0xd2d4d8],
|
|
63
|
-
[0x16171a, 0xe8e6e1, 0x34353a],
|
|
64
|
-
[0x1f4a3a, 0xe3efe6, 0x2f6b55],
|
|
65
|
-
[0x8c2a24, 0xf0d9c8, 0xa8473d],
|
|
66
|
-
[0xf3efe6, 0xb08d57, 0xddd2bd],
|
|
67
|
-
[0x24476b, 0xdbe7f2, 0x3d6a94],
|
|
68
|
-
[0xe8c4c0, 0x7a4a4a, 0xd4a5a0],
|
|
69
|
-
]
|
|
70
|
-
|
|
71
|
-
// Early wood, late wood.
|
|
72
|
-
const WOODS = [
|
|
73
|
-
[0xc89f6b, 0x8f6638],
|
|
74
|
-
[0x6b4a32, 0x3a2618],
|
|
75
|
-
[0xb8643f, 0x82391f],
|
|
76
|
-
[0xe8cfa0, 0xc4a06a],
|
|
77
|
-
[0x3a2e27, 0x14100c],
|
|
78
|
-
[0xe6c48d, 0xb07e42],
|
|
79
|
-
[0xbdb3a3, 0x7f7464],
|
|
80
|
-
]
|
|
81
|
-
|
|
82
|
-
// Liquid top, liquid bottom, wax.
|
|
83
|
-
const LAMPS = [
|
|
84
|
-
[0x3a0ca3, 0xff006e, 0xffbe0b],
|
|
85
|
-
[0x0b3954, 0x087e8b, 0xff5a5f],
|
|
86
|
-
[0x10451d, 0x4c956c, 0xf77f00],
|
|
87
|
-
[0x1d1d3a, 0x5b4b8a, 0x5cffb0],
|
|
88
|
-
[0x5f0f40, 0x9a031e, 0xfff3b0],
|
|
89
|
-
[0x111111, 0x3a3a3a, 0xff3b3b],
|
|
90
|
-
[0x14213d, 0x2a9d8f, 0xffd6e0],
|
|
91
|
-
]
|
|
92
|
-
|
|
93
|
-
const METALS = [0xb8c2cc, 0x8f9ba8, 0xd9a441, 0x6c9ab8, 0xe07a5f, 0x81b29a, 0xf2cc8f]
|
|
94
|
-
|
|
95
|
-
const GLOWS = [0x6fe3ff, 0xff5f5f, 0x39ff7a, 0xffd166, 0xff6fd8]
|
|
96
|
-
|
|
97
|
-
const SLIMES = [0x7bd389, 0x5fa8ff, 0xff7eb6, 0xffd166, 0xb388ff, 0xff8a5c, 0x5ce1e6]
|
|
98
|
-
|
|
99
|
-
const PASTELS = [0xf6efe4, 0xe8f1f2, 0xf3e8f5, 0xfdf1d8, 0xe6f2e1, 0x2b2738, 0x1f2a36]
|
|
100
|
-
|
|
101
|
-
const SHEETS = [0xf4f4f8, 0xdff4ff, 0xffe3f1, 0xe8ffe0, 0xfff3c4]
|
|
102
|
-
|
|
103
|
-
const HAUNTS = [0x1b1830, 0x0f1b2d, 0x2a1b3d, 0x14231c, 0x241a14]
|
|
104
|
-
|
|
105
|
-
const FURS = [0xe8964a, 0x8d929b, 0x2b2b30, 0xf0e2c4, 0x8a5a3b, 0xf4f1ea, 0xc9a06a]
|
|
106
|
-
|
|
107
|
-
const IRISES = [0x8bc34a, 0xffc93c, 0x6fb7ff, 0xf28c28, 0x5ce1e6]
|
|
108
|
-
|
|
109
|
-
const POTIONS = [0xff4d6d, 0x5cffb0, 0x6fa8ff, 0xb388ff, 0xffd166, 0xff8c42, 0x5ce1e6]
|
|
110
|
-
|
|
111
|
-
const GEMS = [0xe0115f, 0x2457c5, 0x13a35a, 0x9b5de5, 0xffb627, 0x5ce1e6, 0xdfe9f5, 0xff6f91]
|
|
112
|
-
|
|
113
|
-
const VELVETS = [0x1a1a2e, 0x2a0f1a, 0x0f2a24, 0x241b0f, 0xf3eee6]
|
|
114
|
-
|
|
115
|
-
// Sky top, sky bottom, ground, light.
|
|
116
|
-
const DAYS = [
|
|
117
|
-
[0x7ec8f2, 0xd9f1ff, 0x6aa84f, 0xfff3b0],
|
|
118
|
-
[0x2b1b4a, 0xf28c5a, 0x3a5a40, 0xffe08a],
|
|
119
|
-
[0x0b1030, 0x2a3a7a, 0x1e3a2b, 0xf0f0d0],
|
|
120
|
-
[0xb8d8e8, 0xeef6fa, 0xf4f8fb, 0xffffff],
|
|
121
|
-
[0xf2c6a0, 0xfde9d2, 0xd9b26f, 0xfff4dc],
|
|
122
|
-
]
|
|
123
|
-
|
|
124
|
-
const WALLS = [0xf4efe6, 0xe9c46a, 0xe07a5f, 0x81b29a, 0x9ec1e0, 0xc9ada7, 0xffffff, 0x3d405b]
|
|
125
|
-
|
|
126
|
-
const ROOFS = [0xb23a48, 0x3d405b, 0x6b4423, 0x264653, 0x2f2f2f, 0x8a3324, 0x2a9d8f]
|
|
127
|
-
|
|
128
|
-
// Pips on a 3 × 3 lattice for faces one to six.
|
|
129
|
-
const PIPS = [
|
|
130
|
-
[4],
|
|
131
|
-
[0, 8],
|
|
132
|
-
[0, 4, 8],
|
|
133
|
-
[0, 2, 6, 8],
|
|
134
|
-
[0, 2, 4, 6, 8],
|
|
135
|
-
[0, 2, 3, 5, 6, 8],
|
|
136
|
-
]
|
|
137
|
-
|
|
138
|
-
// Body, pip.
|
|
139
|
-
const DICE = [
|
|
140
|
-
[0xf6f3ec, 0x1a1a1a],
|
|
141
|
-
[0xc8102e, 0xffffff],
|
|
142
|
-
[0x1a1a1a, 0xf6f3ec],
|
|
143
|
-
[0x1d5fbf, 0xffffff],
|
|
144
|
-
[0xf2e3c4, 0x8a1c1c],
|
|
145
|
-
[0x2a9d8f, 0xffffff],
|
|
146
|
-
]
|
|
147
|
-
|
|
148
|
-
const FELTS = [0x1f6b45, 0x7a4a2a, 0x1d2b4f, 0x5c1f2b, 0x2b2b2b]
|
|
149
|
-
|
|
150
|
-
const METAL_TINCTURES = [0xf2c230, 0xeeeeee]
|
|
151
|
-
|
|
152
|
-
const COLOUR_TINCTURES = [0xc8102e, 0x1f4fa0, 0x1e7a46, 0x1a1a1a, 0x6b3fa0]
|
|
153
|
-
|
|
154
|
-
// Sky top, sky bottom, line, star.
|
|
155
|
-
const CHARTS = [
|
|
156
|
-
[0x0b1030, 0x1f2a5a, 0x9fb3ff, 0xfff6e0],
|
|
157
|
-
[0x10061f, 0x3a1550, 0xd5a6ff, 0xffffff],
|
|
158
|
-
[0x04141c, 0x0d3b4a, 0x7fe0d6, 0xeaffff],
|
|
159
|
-
[0xf1e6cc, 0xe3d3ad, 0x8a5a2b, 0x3a2410],
|
|
160
|
-
]
|
|
161
|
-
|
|
162
|
-
// Ground, dark half, light half, accent.
|
|
163
|
-
const ROSES = [
|
|
164
|
-
[0xf1e6cc, 0x1d3557, 0xf4efe6, 0xc8102e],
|
|
165
|
-
[0x14213d, 0xb08d57, 0xf2d9a0, 0xe63946],
|
|
166
|
-
[0xf5f5f0, 0x1a1a1a, 0xffffff, 0x1a1a1a],
|
|
167
|
-
[0x0f3d3e, 0x2a9d8f, 0xe9f5f2, 0xf4a261],
|
|
168
|
-
[0x3d2b1f, 0x8a5a2b, 0xe9d3a8, 0xf2c230],
|
|
169
|
-
]
|
|
170
|
-
|
|
171
|
-
// Stone, mark, glows.
|
|
172
|
-
const TABLETS = [
|
|
173
|
-
[0x3b4048, 0x1e2126, 0],
|
|
174
|
-
[0xc2a27a, 0x6e5434, 0],
|
|
175
|
-
[0x6b4a32, 0x2e1d12, 0],
|
|
176
|
-
[0xe9dcc0, 0x8a3324, 0],
|
|
177
|
-
[0x101420, 0x6fe3ff, 1],
|
|
178
|
-
[0x1a1010, 0xff8c42, 1],
|
|
179
|
-
]
|
|
180
|
-
|
|
181
|
-
const NATURE: Definition[] = [
|
|
182
|
-
{
|
|
183
|
-
id: "mountains",
|
|
184
|
-
name: "Mountains",
|
|
185
|
-
family: "Nature and materials",
|
|
186
|
-
label: "Three ranges of jagged peaks with snowcaps, a sun or moon, and sometimes a lake",
|
|
187
|
-
resolve: (random) => {
|
|
188
|
-
const r = random("mountains")
|
|
189
|
-
|
|
190
|
-
const peaks = (prefix: string, count: number, low: number, high: number, slope: number) =>
|
|
191
|
-
Object.fromEntries(
|
|
192
|
-
Array.from({ length: count }, (_, i) => [
|
|
193
|
-
[`${prefix}x${i}`, range(r, -2, 18)],
|
|
194
|
-
[`${prefix}h${i}`, range(r, low, high)],
|
|
195
|
-
[`${prefix}s${i}`, slope * range(r, 0.8, 1.3)],
|
|
196
|
-
]).flat(),
|
|
197
|
-
)
|
|
198
|
-
|
|
199
|
-
return {
|
|
200
|
-
grid: 16,
|
|
201
|
-
...prefixed("m", pick(r, RANGES)),
|
|
202
|
-
sunX: range(r, 2, 14),
|
|
203
|
-
sunY: range(r, 2, 6),
|
|
204
|
-
lake: r() < 0.35 ? 1 : 0,
|
|
205
|
-
...peaks("a", 3, 9, 14, 1.2),
|
|
206
|
-
...peaks("b", 3, 6, 9, 0.9),
|
|
207
|
-
...peaks("c", 2, 3, 5, 0.55),
|
|
208
|
-
}
|
|
209
|
-
},
|
|
210
|
-
paint: (pixels, p) => {
|
|
211
|
-
const [top, bottom, sun, far, middle, near, snow] = colors(p, "m", 7)
|
|
212
|
-
const sky = [top, mix(top, bottom, 0.5), bottom]
|
|
213
|
-
const base = p.lake ? 13 : 16
|
|
214
|
-
|
|
215
|
-
const ridge = (prefix: string, count: number, x: number) =>
|
|
216
|
-
Math.max(
|
|
217
|
-
...Array.from({ length: count }, (_, i) => p[`${prefix}h${i}`] - Math.abs(x + 0.5 - p[`${prefix}x${i}`]) * p[`${prefix}s${i}`]),
|
|
218
|
-
) - (16 - base)
|
|
219
|
-
|
|
220
|
-
const scene = (x: number, y: number) => {
|
|
221
|
-
const height = base - y
|
|
222
|
-
const c = ridge("c", 2, x)
|
|
223
|
-
|
|
224
|
-
if (height <= c) return near
|
|
225
|
-
const b = ridge("b", 3, x)
|
|
226
|
-
|
|
227
|
-
if (height <= b) return b - height < 1 ? tint(middle, 0.12) : middle
|
|
228
|
-
const a = ridge("a", 3, x)
|
|
229
|
-
|
|
230
|
-
if (height <= a) return a - height < 1.6 + ((x * 7) % 3) * 0.4 && a > 7 ? snow : far
|
|
231
|
-
|
|
232
|
-
if (Math.hypot(x + 0.5 - p.sunX, y + 0.5 - p.sunY) < 2.1) return sun
|
|
233
|
-
|
|
234
|
-
return sky[dither(y / 10, 3, x, y)]
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
pixels.each((x, y) => {
|
|
238
|
-
if (y < base) return scene(x, y)
|
|
239
|
-
const mirrored = scene(x, base * 2 - y - 1)
|
|
240
|
-
|
|
241
|
-
return y % 2 && x % 4 === y % 4 ? tint(mirrored, 0.25) : shade(mix(mirrored, bottom, 0.25), 0.82)
|
|
242
|
-
})
|
|
243
|
-
},
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
id: "waves",
|
|
247
|
-
name: "Waves",
|
|
248
|
-
family: "Nature and materials",
|
|
249
|
-
label: "Stacked ocean swells with foam crests under a strip of sky; they roll on hover",
|
|
250
|
-
animated: true,
|
|
251
|
-
resolve: (random) => {
|
|
252
|
-
const r = random("waves")
|
|
253
|
-
|
|
254
|
-
return {
|
|
255
|
-
grid: 16,
|
|
256
|
-
...prefixed("w", pick(r, SEAS)),
|
|
257
|
-
horizon: int(r, 3, 6),
|
|
258
|
-
bands: int(r, 3, 4),
|
|
259
|
-
amplitude: range(r, 0.8, 2),
|
|
260
|
-
frequency: range(r, 0.45, 0.9),
|
|
261
|
-
phase: r() * 6.28,
|
|
262
|
-
sun: r() < 0.6 ? 1 : 0,
|
|
263
|
-
sunX: range(r, 3, 13),
|
|
264
|
-
}
|
|
265
|
-
},
|
|
266
|
-
paint: (pixels, p, t) => {
|
|
267
|
-
const [sky, deep, middle, light, foam, sun] = colors(p, "w", 6)
|
|
268
|
-
const tones = [light, middle, mix(middle, deep, 0.5), deep]
|
|
269
|
-
|
|
270
|
-
pixels.each((x, y) => {
|
|
271
|
-
const crests = Array.from({ length: p.bands }, (_, k) => {
|
|
272
|
-
const spacing = (16 - p.horizon) / p.bands
|
|
273
|
-
const swell = p.amplitude * (0.6 + k * 0.25)
|
|
274
|
-
const curve = p.horizon + k * spacing + swell * Math.sin(x * p.frequency + p.phase + k * 1.9 + t * (1.5 + k * 0.4))
|
|
275
|
-
|
|
276
|
-
return curve
|
|
277
|
-
})
|
|
278
|
-
const band = crests.findLastIndex((curve) => y + 0.5 >= curve)
|
|
279
|
-
|
|
280
|
-
if (band < 0) {
|
|
281
|
-
if (p.sun && Math.hypot(x + 0.5 - p.sunX, y + 0.5 - (p.horizon - 0.5)) < 2.4) return sun
|
|
282
|
-
|
|
283
|
-
return y === p.horizon - 1 ? mix(sky, light, 0.4) : sky
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (y + 0.5 - crests[band] < 1) return foam
|
|
287
|
-
|
|
288
|
-
if (y + 0.5 - crests[band] < 2 && (x + band) % 3 === 0) return mix(foam, tones[band], 0.5)
|
|
289
|
-
|
|
290
|
-
return tones[Math.min(3, band + (4 - p.bands))]
|
|
291
|
-
})
|
|
292
|
-
},
|
|
293
|
-
},
|
|
294
|
-
{
|
|
295
|
-
id: "aurora",
|
|
296
|
-
name: "Aurora",
|
|
297
|
-
family: "Nature and materials",
|
|
298
|
-
label: "Rayed aurora curtains over pines, snowy hills or a still lake; they ripple on hover",
|
|
299
|
-
animated: true,
|
|
300
|
-
resolve: (random) => {
|
|
301
|
-
const r = random("aurora")
|
|
302
|
-
const [low, high] = pick(r, AURORAS)
|
|
303
|
-
|
|
304
|
-
return {
|
|
305
|
-
grid: 16,
|
|
306
|
-
seed: seed(r),
|
|
307
|
-
night: pick(r, NIGHTS),
|
|
308
|
-
low,
|
|
309
|
-
high,
|
|
310
|
-
ribbons: r() < 0.4 ? 2 : 1,
|
|
311
|
-
base: range(r, 7, 10),
|
|
312
|
-
amplitude: range(r, 1, 3),
|
|
313
|
-
frequency: range(r, 0.25, 0.6),
|
|
314
|
-
phase: r() * 6.28,
|
|
315
|
-
length: range(r, 4, 7),
|
|
316
|
-
ground: int(r, 0, 2),
|
|
317
|
-
}
|
|
318
|
-
},
|
|
319
|
-
paint: (pixels, p, t) => {
|
|
320
|
-
pixels.fill(p.night)
|
|
321
|
-
stars(pixels, mulberry32(p.seed), p.night, 6)
|
|
322
|
-
const rand = mulberry32(p.seed + 1)
|
|
323
|
-
const pines = Array.from({ length: 5 }, () => ({ x: rand() * 16, h: 3 + rand() * 3 }))
|
|
324
|
-
|
|
325
|
-
const glow = (x: number, y: number) =>
|
|
326
|
-
Math.max(
|
|
327
|
-
...Array.from({ length: p.ribbons }, (_, k) => {
|
|
328
|
-
const edge =
|
|
329
|
-
p.base - k * 3 + p.amplitude * Math.sin(x * p.frequency + p.phase + k * 2.1 + t * 1.3)
|
|
330
|
-
const above = edge - (y + 0.5)
|
|
331
|
-
|
|
332
|
-
if (above < -0.5 || above > p.length) return 0
|
|
333
|
-
const rays = 0.65 + 0.35 * Math.sin(x * 2.3 + p.phase * 3 + k + t * 4)
|
|
334
|
-
|
|
335
|
-
return (1 - above / p.length) * rays
|
|
336
|
-
}),
|
|
337
|
-
)
|
|
338
|
-
|
|
339
|
-
pixels.each((x, y) => {
|
|
340
|
-
const ground = [
|
|
341
|
-
() => pines.some((pine) => 13 - y < pine.h - Math.abs(x + 0.5 - pine.x) * 1.6) || y >= 14,
|
|
342
|
-
() => y >= 13 - Math.sin(x * 0.5 + p.phase) * 1.2,
|
|
343
|
-
() => y >= 13,
|
|
344
|
-
][p.ground]()
|
|
345
|
-
|
|
346
|
-
if (ground && p.ground === 2) return mix(p.night, mix(p.low, p.high, 0.3), glow(x, 26 - y) * 0.35)
|
|
347
|
-
|
|
348
|
-
if (ground) return p.ground === 1 ? mix(0xdfe9f5, p.night, 0.55) : mix(p.night, 0x000000, 0.4)
|
|
349
|
-
const k = glow(x, y)
|
|
350
|
-
|
|
351
|
-
if (k <= 0) return undefined
|
|
352
|
-
const level = dither(k * 1.35, 4, x, y)
|
|
353
|
-
|
|
354
|
-
return level ? mix(p.night, mix(p.low, p.high, clamp01((p.base - y) / p.length)), level / 3) : undefined
|
|
355
|
-
})
|
|
356
|
-
},
|
|
357
|
-
},
|
|
358
|
-
{
|
|
359
|
-
id: "marble",
|
|
360
|
-
name: "Marble",
|
|
361
|
-
family: "Nature and materials",
|
|
362
|
-
label: "Domain-warped veins through Carrara, Nero, Verde, Rosso, Calacatta and other stones",
|
|
363
|
-
resolve: (random) => {
|
|
364
|
-
const r = random("marble")
|
|
365
|
-
|
|
366
|
-
return {
|
|
367
|
-
grid: 32,
|
|
368
|
-
...prefixed("m", pick(r, MARBLES)),
|
|
369
|
-
angle: r() * Math.PI,
|
|
370
|
-
frequency: range(r, 0.15, 0.32),
|
|
371
|
-
warp: range(r, 2.5, 5.5),
|
|
372
|
-
width: range(r, 0.06, 0.16),
|
|
373
|
-
seedX: r() * 40,
|
|
374
|
-
seedY: r() * 40,
|
|
375
|
-
}
|
|
376
|
-
},
|
|
377
|
-
paint: (pixels, p) => {
|
|
378
|
-
const [base, vein, cloud] = colors(p, "m", 3)
|
|
379
|
-
|
|
380
|
-
pixels.each((x, y) => {
|
|
381
|
-
const qx = fbm(x * 0.07 + p.seedX, y * 0.07 + p.seedY)
|
|
382
|
-
const qy = fbm(x * 0.07 + p.seedY + 3.1, y * 0.07 + p.seedX + 1.7)
|
|
383
|
-
const w = fbm(x * 0.06 + qx * 2.5 + p.seedX, y * 0.06 + qy * 2.5 + p.seedY)
|
|
384
|
-
const along = (x * Math.cos(p.angle) + y * Math.sin(p.angle)) * p.frequency
|
|
385
|
-
const main = Math.abs(Math.sin(along + w * p.warp))
|
|
386
|
-
const fine = Math.abs(Math.sin(along * 2.7 + w * p.warp * 1.8 + 1.3))
|
|
387
|
-
const stone = mix(base, cloud, smoothstep(0.35, 0.75, qx))
|
|
388
|
-
const veined = mix(stone, vein, 1 - smoothstep(0, p.width, main))
|
|
389
|
-
|
|
390
|
-
return mix(veined, vein, (1 - smoothstep(0, p.width * 0.35, fine)) * 0.45)
|
|
391
|
-
})
|
|
392
|
-
},
|
|
393
|
-
},
|
|
394
|
-
{
|
|
395
|
-
id: "wood",
|
|
396
|
-
name: "Wood grain",
|
|
397
|
-
family: "Nature and materials",
|
|
398
|
-
label: "End grain, flat-sawn cathedrals or quartersawn stripes in oak, walnut, cherry and more",
|
|
399
|
-
resolve: (random) => {
|
|
400
|
-
const r = random("wood")
|
|
401
|
-
|
|
402
|
-
return {
|
|
403
|
-
grid: 32,
|
|
404
|
-
...prefixed("w", pick(r, WOODS)),
|
|
405
|
-
cut: int(r, 0, 2),
|
|
406
|
-
cx: range(r, -8, 40),
|
|
407
|
-
cy: range(r, -8, 40),
|
|
408
|
-
density: range(r, 0.18, 0.4),
|
|
409
|
-
knot: r() < 0.4 ? 1 : 0,
|
|
410
|
-
kx: range(r, 8, 24),
|
|
411
|
-
ky: range(r, 8, 24),
|
|
412
|
-
seedX: r() * 40,
|
|
413
|
-
seedY: r() * 40,
|
|
414
|
-
}
|
|
415
|
-
},
|
|
416
|
-
paint: (pixels, p) => {
|
|
417
|
-
const [early, late] = colors(p, "w", 2)
|
|
418
|
-
|
|
419
|
-
pixels.each((x, y) => {
|
|
420
|
-
const n = fbm(x * 0.08 + p.seedX, y * 0.08 + p.seedY)
|
|
421
|
-
const knot = p.knot && p.cut === 1 ? 6 / (1 + Math.hypot(x - p.kx, (y - p.ky) * 0.6)) : 0
|
|
422
|
-
|
|
423
|
-
const distance = [
|
|
424
|
-
Math.hypot(x - p.cx, y - p.cy),
|
|
425
|
-
Math.hypot((x - 16) * 0.22, y - p.cy - 40) + knot * 3,
|
|
426
|
-
x + n * 4,
|
|
427
|
-
][p.cut]
|
|
428
|
-
|
|
429
|
-
const ring = (((distance * p.density + n * 0.9) % 1) + 1) % 1
|
|
430
|
-
const wood = mix(early, late, smoothstep(0.55, 0.95, ring))
|
|
431
|
-
const ray = p.cut === 2 && grain(Math.floor(x / 3), y, 3) > 0.93 ? 0.35 : 0
|
|
432
|
-
const check = p.cut === 0 && Math.abs(Math.sin(Math.atan2(y - p.cy, x - p.cx) * 3 + p.seedX)) < 0.03
|
|
433
|
-
|
|
434
|
-
return check ? shade(late, 0.6) : shade(mix(wood, tint(early, 0.3), ray), grain(x, y, 1) < 0.15 ? 0.92 : 1)
|
|
435
|
-
})
|
|
436
|
-
},
|
|
437
|
-
},
|
|
438
|
-
{
|
|
439
|
-
id: "lava",
|
|
440
|
-
name: "Lava lamp",
|
|
441
|
-
family: "Nature and materials",
|
|
442
|
-
label: "A tapered lamp of metaball wax in a dithered liquid, on a chrome, brass or black base; the wax rises on hover",
|
|
443
|
-
animated: true,
|
|
444
|
-
resolve: (random) => {
|
|
445
|
-
const r = random("lava")
|
|
446
|
-
const all = colors(palette(random("palette")))
|
|
447
|
-
|
|
448
|
-
return {
|
|
449
|
-
grid: 16,
|
|
450
|
-
seed: seed(r),
|
|
451
|
-
count: int(r, 3, 4),
|
|
452
|
-
...prefixed("l", pick(r, LAMPS)),
|
|
453
|
-
metal: pick(r, [0xb8bec6, 0xd4af37, 0x2e2e33, 0xc8743a]),
|
|
454
|
-
ground: r() < 0.65 ? pick(r, [0x14121f, 0x0f1418, 0x1c1414, 0x101a1a]) : all[0],
|
|
455
|
-
belly: range(r, 3.2, 4.2),
|
|
456
|
-
}
|
|
457
|
-
},
|
|
458
|
-
paint: (pixels, p, t) => {
|
|
459
|
-
const [top, bottom, wax] = colors(p, "l", 3)
|
|
460
|
-
const rand = mulberry32(p.seed)
|
|
461
|
-
const half = (y: number) => (y < 2 || y > 11 ? 0 : 1.2 + (p.belly - 1.2) * Math.sin((Math.PI * (y - 1.5)) / 11) ** 0.8)
|
|
462
|
-
const glass = (x: number, y: number) => Math.abs(x + 0.5 - 8) < half(y)
|
|
463
|
-
const dark = luma(p.ground) < 0.3
|
|
464
|
-
|
|
465
|
-
const blobs = Array.from({ length: p.count }, () => {
|
|
466
|
-
const speed = 0.6 + rand() * 1
|
|
467
|
-
const phase = rand() * 6.28
|
|
468
|
-
|
|
469
|
-
return { x: 7 + rand() * 2, y: 7 + Math.sin(phase + t * speed) * 3.5, r: 0.9 + rand() * 0.8 }
|
|
470
|
-
})
|
|
471
|
-
|
|
472
|
-
pixels.each((x, y) => {
|
|
473
|
-
if (glass(x, y)) {
|
|
474
|
-
const field = blobs.reduce((sum, blob) => sum + (blob.r * blob.r) / ((x + 0.5 - blob.x) ** 2 + (y + 0.5 - blob.y) ** 2 + 0.01), 0)
|
|
475
|
-
|
|
476
|
-
if (field > 1) return field > 3 ? tint(wax, 0.3) : wax
|
|
477
|
-
|
|
478
|
-
return [top, mix(top, bottom, 0.5), bottom][dither((y - 2) / 9, 3, x, y)]
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
if (y <= 1 && y >= 0 && Math.abs(x + 0.5 - 8) < 1.6 + y * 0.4) return y === 0 ? shade(p.metal, 0.8) : p.metal
|
|
482
|
-
|
|
483
|
-
if (y >= 12 && y <= 14 && Math.abs(x + 0.5 - 8) < 1.6 + (y - 12) * 0.9) return y === 12 ? tint(p.metal, 0.25) : y === 14 ? shade(p.metal, 0.7) : p.metal
|
|
484
|
-
|
|
485
|
-
const near = [-1, 1].some((d) => glass(x + d, y) || glass(x + d * 2, y))
|
|
486
|
-
|
|
487
|
-
return dark && near ? mix(p.ground, wax, 0.18) : p.ground
|
|
488
|
-
})
|
|
489
|
-
},
|
|
490
|
-
},
|
|
491
|
-
]
|
|
492
|
-
|
|
493
|
-
const CREATURES: Definition[] = [
|
|
494
|
-
{
|
|
495
|
-
id: "robot",
|
|
496
|
-
name: "Robot",
|
|
497
|
-
family: "Creatures",
|
|
498
|
-
label: "A boxy robot head with its own eyes, mouth and antenna; it blinks and beeps on hover",
|
|
499
|
-
animated: true,
|
|
500
|
-
resolve: (random) => {
|
|
501
|
-
const r = random("robot")
|
|
502
|
-
const all = colors(palette(random("palette")))
|
|
503
|
-
const body = r() < 0.6 ? pick(r, METALS) : pick(r, all.slice(1))
|
|
504
|
-
|
|
505
|
-
return {
|
|
506
|
-
grid: 16,
|
|
507
|
-
body,
|
|
508
|
-
ground: luma(body) > 0.5 ? mix(0x1a1c22, body, 0.12) : mix(all[0], body, 0.1),
|
|
509
|
-
glow: pick(r, GLOWS),
|
|
510
|
-
width: pick(r, [8, 10, 10, 12]),
|
|
511
|
-
height: int(r, 6, 8),
|
|
512
|
-
round: r() < 0.5 ? 1 : 0,
|
|
513
|
-
eyes: int(r, 0, 3),
|
|
514
|
-
mouth: int(r, 0, 3),
|
|
515
|
-
antenna: int(r, 0, 3),
|
|
516
|
-
ears: r() < 0.5 ? 1 : 0,
|
|
517
|
-
}
|
|
518
|
-
},
|
|
519
|
-
paint: (pixels, p, t) => {
|
|
520
|
-
const x0 = (16 - p.width) / 2
|
|
521
|
-
const y0 = 13 - p.height - 2
|
|
522
|
-
const dark = shade(p.body, 0.55)
|
|
523
|
-
const blink = t % 1.8 > 1.6
|
|
524
|
-
const beep = t > 0 && Math.floor(t * 3) % 2 === 0
|
|
525
|
-
pixels.fill(p.ground)
|
|
526
|
-
pixels.rect(5, y0 + p.height, 6, 1, dark)
|
|
527
|
-
pixels.rect(2, y0 + p.height + 1, 12, 4, shade(p.body, 0.8))
|
|
528
|
-
pixels.rect(2, y0 + p.height + 1, 12, 1, p.body)
|
|
529
|
-
pixels.rect(x0, y0, p.width, p.height, p.body)
|
|
530
|
-
pixels.rect(x0, y0 + p.height - 1, p.width, 1, shade(p.body, 0.8))
|
|
531
|
-
pixels.rect(x0, y0, p.width, 1, tint(p.body, 0.3))
|
|
532
|
-
|
|
533
|
-
if (p.round) {
|
|
534
|
-
;[
|
|
535
|
-
[x0, y0],
|
|
536
|
-
[x0 + p.width - 1, y0],
|
|
537
|
-
[x0, y0 + p.height - 1],
|
|
538
|
-
[x0 + p.width - 1, y0 + p.height - 1],
|
|
539
|
-
].forEach(([x, y]) => pixels.set(x, y, p.ground))
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
if (p.ears) {
|
|
543
|
-
pixels.rect(x0 - 1, y0 + 2, 1, 2, dark)
|
|
544
|
-
pixels.rect(x0 + p.width, y0 + 2, 1, 2, dark)
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
const eye = blink ? dark : p.glow
|
|
548
|
-
const eyeY = y0 + 2
|
|
549
|
-
const eyes = [
|
|
550
|
-
() => {
|
|
551
|
-
pixels.rect(x0 + 1, eyeY, 2, 2, eye)
|
|
552
|
-
pixels.rect(x0 + p.width - 3, eyeY, 2, 2, eye)
|
|
553
|
-
},
|
|
554
|
-
() => {
|
|
555
|
-
pixels.rect(x0 + 1, eyeY, p.width - 2, 2, shade(p.body, 0.3))
|
|
556
|
-
pixels.rect(x0 + 2 + (beep ? 1 : 0), eyeY, 2, 1, eye)
|
|
557
|
-
pixels.rect(x0 + p.width - 4 - (beep ? 1 : 0), eyeY, 2, 1, eye)
|
|
558
|
-
},
|
|
559
|
-
() => {
|
|
560
|
-
pixels.rect(7, eyeY - 1, 2, 3, eye)
|
|
561
|
-
pixels.rect(6, eyeY, 4, 1, eye)
|
|
562
|
-
},
|
|
563
|
-
() => {
|
|
564
|
-
pixels.set(x0 + 2, eyeY, eye)
|
|
565
|
-
pixels.set(x0 + p.width - 3, eyeY, eye)
|
|
566
|
-
pixels.set(x0 + 1, eyeY + 1, eye)
|
|
567
|
-
pixels.set(x0 + 3, eyeY + 1, eye)
|
|
568
|
-
pixels.set(x0 + p.width - 4, eyeY + 1, eye)
|
|
569
|
-
pixels.set(x0 + p.width - 2, eyeY + 1, eye)
|
|
570
|
-
},
|
|
571
|
-
]
|
|
572
|
-
|
|
573
|
-
eyes[p.eyes]()
|
|
574
|
-
const mouthY = y0 + p.height - 2
|
|
575
|
-
const mouths = [
|
|
576
|
-
() => Array.from({ length: p.width - 4 }, (_, i) => i % 2 === 0 && pixels.set(x0 + 2 + i, mouthY, dark)),
|
|
577
|
-
() => pixels.rect(x0 + 3, mouthY, p.width - 6, 1, dark),
|
|
578
|
-
() => {
|
|
579
|
-
pixels.rect(x0 + 2, mouthY, p.width - 4, 1, 0xf4f1ea)
|
|
580
|
-
Array.from({ length: p.width - 4 }, (_, i) => i % 2 && pixels.set(x0 + 2 + i, mouthY, dark))
|
|
581
|
-
},
|
|
582
|
-
() => pixels.rect(7, mouthY, 2, 1, beep ? p.glow : dark),
|
|
583
|
-
]
|
|
584
|
-
|
|
585
|
-
mouths[p.mouth]()
|
|
586
|
-
const tip = beep ? tint(p.glow, 0.5) : p.glow
|
|
587
|
-
const antennas = [
|
|
588
|
-
() => pixels.rect(x0 + 1, y0 - 1, p.width - 2, 1, dark),
|
|
589
|
-
() => {
|
|
590
|
-
pixels.rect(7, y0 - 2, 1, 2, dark)
|
|
591
|
-
pixels.rect(7, y0 - 3, 2, 1, tip)
|
|
592
|
-
},
|
|
593
|
-
() => {
|
|
594
|
-
pixels.rect(x0 + 1, y0 - 2, 1, 2, dark)
|
|
595
|
-
pixels.rect(x0 + p.width - 2, y0 - 2, 1, 2, dark)
|
|
596
|
-
pixels.set(x0 + 1, y0 - 3, tip)
|
|
597
|
-
pixels.set(x0 + p.width - 2, y0 - 3, tip)
|
|
598
|
-
},
|
|
599
|
-
() => {
|
|
600
|
-
pixels.set(8, y0 - 1, dark)
|
|
601
|
-
pixels.set(7, y0 - 2, dark)
|
|
602
|
-
pixels.set(8, y0 - 3, tip)
|
|
603
|
-
},
|
|
604
|
-
]
|
|
605
|
-
|
|
606
|
-
antennas[p.antenna]()
|
|
607
|
-
},
|
|
608
|
-
},
|
|
609
|
-
{
|
|
610
|
-
id: "slime",
|
|
611
|
-
name: "Slime",
|
|
612
|
-
family: "Creatures",
|
|
613
|
-
label: "A glossy dome of slime with a face and a sprout, crown or bubble; it squashes on hover",
|
|
614
|
-
animated: true,
|
|
615
|
-
resolve: (random) => {
|
|
616
|
-
const r = random("slime")
|
|
617
|
-
|
|
618
|
-
return {
|
|
619
|
-
grid: 16,
|
|
620
|
-
body: pick(r, SLIMES),
|
|
621
|
-
ground: pick(r, PASTELS),
|
|
622
|
-
width: range(r, 10, 14),
|
|
623
|
-
height: range(r, 7, 10),
|
|
624
|
-
eyes: int(r, 0, 2),
|
|
625
|
-
mouth: int(r, 0, 2),
|
|
626
|
-
hat: int(r, 0, 3),
|
|
627
|
-
drip: int(r, 3, 12),
|
|
628
|
-
}
|
|
629
|
-
},
|
|
630
|
-
paint: (pixels, p, t) => {
|
|
631
|
-
const squash = Math.sin(t * 6) * 0.12 * Math.min(1, t * 3)
|
|
632
|
-
const w = p.width * (1 + squash) * 0.5
|
|
633
|
-
const h = p.height * (1 - squash)
|
|
634
|
-
const base = 13
|
|
635
|
-
const top = Math.round(base - h)
|
|
636
|
-
const inside = (x: number, y: number) => y < base && ((x + 0.5 - 8) / w) ** 2 + ((y + 0.5 - base) / h) ** 2 < 1
|
|
637
|
-
const outline = shade(p.body, 0.6)
|
|
638
|
-
pixels.fill(p.ground)
|
|
639
|
-
pixels.rect(Math.round(8 - w), base, Math.round(w * 2), 1, mix(p.ground, 0x000000, 0.18))
|
|
640
|
-
pixels.each((x, y) => {
|
|
641
|
-
if (inside(x, y)) return inside(x - 1, y) && inside(x + 1, y) && inside(x, y - 1) ? p.body : outline
|
|
642
|
-
|
|
643
|
-
return undefined
|
|
644
|
-
})
|
|
645
|
-
pixels.set(p.drip, base, outline)
|
|
646
|
-
pixels.set(Math.round(8 - w * 0.55), top + 2, tint(p.body, 0.75))
|
|
647
|
-
pixels.set(Math.round(8 - w * 0.55) + 1, top + 1, tint(p.body, 0.6))
|
|
648
|
-
const eyeY = Math.round(base - h * 0.45)
|
|
649
|
-
const ink = 0x1a1a24
|
|
650
|
-
const faces = [
|
|
651
|
-
() => {
|
|
652
|
-
pixels.rect(5, eyeY, 1, 2, ink)
|
|
653
|
-
pixels.rect(10, eyeY, 1, 2, ink)
|
|
654
|
-
},
|
|
655
|
-
() => {
|
|
656
|
-
pixels.rect(4, eyeY, 2, 2, ink)
|
|
657
|
-
pixels.rect(10, eyeY, 2, 2, ink)
|
|
658
|
-
pixels.set(4, eyeY, 0xffffff)
|
|
659
|
-
pixels.set(10, eyeY, 0xffffff)
|
|
660
|
-
},
|
|
661
|
-
() => {
|
|
662
|
-
;[4, 10].forEach((x) => {
|
|
663
|
-
pixels.set(x, eyeY + 1, ink)
|
|
664
|
-
pixels.set(x + 1, eyeY, ink)
|
|
665
|
-
pixels.set(x + 2, eyeY + 1, ink)
|
|
666
|
-
})
|
|
667
|
-
},
|
|
668
|
-
]
|
|
669
|
-
|
|
670
|
-
faces[p.eyes]()
|
|
671
|
-
const mouths = [
|
|
672
|
-
() => {
|
|
673
|
-
pixels.set(7, eyeY + 2, ink)
|
|
674
|
-
pixels.set(8, eyeY + 2, ink)
|
|
675
|
-
},
|
|
676
|
-
() => {
|
|
677
|
-
pixels.set(6, eyeY + 2, ink)
|
|
678
|
-
pixels.set(7, eyeY + 3, ink)
|
|
679
|
-
pixels.set(8, eyeY + 2, ink)
|
|
680
|
-
pixels.set(9, eyeY + 3, ink)
|
|
681
|
-
},
|
|
682
|
-
() => {
|
|
683
|
-
pixels.set(3, eyeY + 2, 0xff8fab)
|
|
684
|
-
pixels.set(12, eyeY + 2, 0xff8fab)
|
|
685
|
-
},
|
|
686
|
-
]
|
|
687
|
-
|
|
688
|
-
mouths[p.mouth]()
|
|
689
|
-
const hats = [
|
|
690
|
-
() => undefined,
|
|
691
|
-
() => {
|
|
692
|
-
pixels.set(8, top - 1, 0x4c956c)
|
|
693
|
-
pixels.set(9, top - 2, 0x6fcf6f)
|
|
694
|
-
pixels.set(7, top - 2, 0x6fcf6f)
|
|
695
|
-
},
|
|
696
|
-
() => {
|
|
697
|
-
pixels.rect(6, top - 1, 4, 1, 0xf2c230)
|
|
698
|
-
pixels.set(6, top - 2, 0xf2c230)
|
|
699
|
-
pixels.set(8, top - 2, 0xf2c230)
|
|
700
|
-
pixels.set(9, top - 2, 0xf2c230)
|
|
701
|
-
},
|
|
702
|
-
() => {
|
|
703
|
-
pixels.set(11, base - 3, tint(p.body, 0.5))
|
|
704
|
-
pixels.set(10, base - 2, tint(p.body, 0.3))
|
|
705
|
-
},
|
|
706
|
-
]
|
|
707
|
-
|
|
708
|
-
hats[p.hat]()
|
|
709
|
-
},
|
|
710
|
-
},
|
|
711
|
-
{
|
|
712
|
-
id: "ghost",
|
|
713
|
-
name: "Ghost",
|
|
714
|
-
family: "Creatures",
|
|
715
|
-
label: "A sheet ghost with a wavy hem and a mood of its own; it floats on hover",
|
|
716
|
-
animated: true,
|
|
717
|
-
resolve: (random) => {
|
|
718
|
-
const r = random("ghost")
|
|
719
|
-
|
|
720
|
-
return {
|
|
721
|
-
grid: 16,
|
|
722
|
-
sheet: pick(r, SHEETS),
|
|
723
|
-
ground: pick(r, HAUNTS),
|
|
724
|
-
width: pick(r, [5, 5.5, 6]),
|
|
725
|
-
period: pick(r, [3, 4]),
|
|
726
|
-
eyes: int(r, 0, 3),
|
|
727
|
-
mouth: int(r, 0, 2),
|
|
728
|
-
arms: r() < 0.5 ? 1 : 0,
|
|
729
|
-
lean: range(r, -0.15, 0.15),
|
|
730
|
-
blush: r() < 0.4 ? 1 : 0,
|
|
731
|
-
}
|
|
732
|
-
},
|
|
733
|
-
paint: (pixels, p, t) => {
|
|
734
|
-
const bob = Math.round(Math.sin(t * 3) * 1)
|
|
735
|
-
const cy = 6.5 + bob
|
|
736
|
-
const hem = 13 + bob
|
|
737
|
-
const shadowed = shade(p.sheet, 0.78)
|
|
738
|
-
|
|
739
|
-
const inside = (x: number, y: number) => {
|
|
740
|
-
const X = x + 0.5 - 8 - (y - 8) * p.lean
|
|
741
|
-
const Y = y + 0.5
|
|
742
|
-
const wave = Math.abs((((x + Math.floor(t * 6)) % p.period) + p.period) % p.period - p.period / 2) * 0.8
|
|
743
|
-
|
|
744
|
-
if (Y < cy) return Math.hypot(X, Y - cy) < p.width
|
|
745
|
-
|
|
746
|
-
return Math.abs(X) < p.width && Y < hem + 1 - wave
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
pixels.fill(p.ground)
|
|
750
|
-
pixels.each((x, y) => {
|
|
751
|
-
if (y === 14 && Math.abs(x + 0.5 - 8) < p.width - 1) return mix(p.ground, 0x000000, 0.3)
|
|
752
|
-
|
|
753
|
-
if (!inside(x, y)) return undefined
|
|
754
|
-
|
|
755
|
-
return inside(x + 1, y) ? p.sheet : shadowed
|
|
756
|
-
})
|
|
757
|
-
|
|
758
|
-
if (p.arms) {
|
|
759
|
-
pixels.set(Math.round(8 - p.width) - 1, 9 + bob, p.sheet)
|
|
760
|
-
pixels.set(Math.round(8 + p.width), 9 + bob, shadowed)
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
const ink = 0x1a1626
|
|
764
|
-
const ey = 5 + bob
|
|
765
|
-
const eyes = [
|
|
766
|
-
() => {
|
|
767
|
-
pixels.rect(5, ey, 2, 3, ink)
|
|
768
|
-
pixels.rect(9, ey, 2, 3, ink)
|
|
769
|
-
},
|
|
770
|
-
() => {
|
|
771
|
-
pixels.set(6, ey + 1, ink)
|
|
772
|
-
pixels.set(9, ey + 1, ink)
|
|
773
|
-
},
|
|
774
|
-
() => {
|
|
775
|
-
;[5, 9].forEach((x) => {
|
|
776
|
-
pixels.set(x, ey + 1, ink)
|
|
777
|
-
pixels.set(x + 1, ey, ink)
|
|
778
|
-
pixels.set(x + 2, ey + 1, ink)
|
|
779
|
-
})
|
|
780
|
-
},
|
|
781
|
-
() => {
|
|
782
|
-
pixels.rect(5, ey, 2, 2, p.ground)
|
|
783
|
-
pixels.rect(9, ey, 2, 2, p.ground)
|
|
784
|
-
},
|
|
785
|
-
]
|
|
786
|
-
|
|
787
|
-
eyes[p.eyes]()
|
|
788
|
-
const mouths = [
|
|
789
|
-
() => undefined,
|
|
790
|
-
() => pixels.rect(7, ey + 4, 2, 2, ink),
|
|
791
|
-
() => {
|
|
792
|
-
pixels.set(6, ey + 4, ink)
|
|
793
|
-
pixels.set(7, ey + 5, ink)
|
|
794
|
-
pixels.set(8, ey + 4, ink)
|
|
795
|
-
pixels.set(9, ey + 5, ink)
|
|
796
|
-
},
|
|
797
|
-
]
|
|
798
|
-
|
|
799
|
-
mouths[p.mouth]()
|
|
800
|
-
|
|
801
|
-
if (p.blush) {
|
|
802
|
-
pixels.set(4, ey + 3, 0xff9eb5)
|
|
803
|
-
pixels.set(11, ey + 3, 0xff9eb5)
|
|
804
|
-
}
|
|
805
|
-
},
|
|
806
|
-
},
|
|
807
|
-
{
|
|
808
|
-
id: "cat",
|
|
809
|
-
name: "Cat",
|
|
810
|
-
family: "Creatures",
|
|
811
|
-
label: "A cat's face in solid, tabby, tuxedo, calico or point coats, with slit eyes; it blinks on hover",
|
|
812
|
-
animated: true,
|
|
813
|
-
resolve: (random) => {
|
|
814
|
-
const r = random("cat")
|
|
815
|
-
const all = colors(palette(random("palette")))
|
|
816
|
-
const fur = pick(r, FURS)
|
|
817
|
-
|
|
818
|
-
return {
|
|
819
|
-
grid: 16,
|
|
820
|
-
fur,
|
|
821
|
-
ground: legible(r, all, fur),
|
|
822
|
-
coat: int(r, 0, 4),
|
|
823
|
-
iris: pick(r, IRISES),
|
|
824
|
-
ears: int(r, 3, 4),
|
|
825
|
-
width: pick(r, [6, 6.5, 7]),
|
|
826
|
-
}
|
|
827
|
-
},
|
|
828
|
-
paint: (pixels, p, t) => {
|
|
829
|
-
const dark = luma(p.fur) < 0.25 ? tint(p.fur, 0.25) : shade(p.fur, 0.62)
|
|
830
|
-
const white = 0xf6f3ec
|
|
831
|
-
const blink = t % 2.4 > 2.2
|
|
832
|
-
const inHead = (x: number, y: number) => ((x + 0.5 - 8) / p.width) ** 2 + ((y + 0.5 - 10) / 5) ** 2 < 1
|
|
833
|
-
|
|
834
|
-
const inEar = (x: number, y: number) =>
|
|
835
|
-
[3.5, 12.5].some((ex) => y >= 6 - p.ears && y <= 6 && Math.abs(x + 0.5 - ex) <= ((y - (6 - p.ears)) / p.ears) * 2.2)
|
|
836
|
-
|
|
837
|
-
const coat = (x: number, y: number) => {
|
|
838
|
-
const coats = [
|
|
839
|
-
() => p.fur,
|
|
840
|
-
() => ((y === 6 || y === 8) && x >= 6 && x <= 9 && x % 2 === 0) || ((x <= 3 || x >= 12) && y % 2 === 1) ? dark : p.fur,
|
|
841
|
-
() => (y >= 11 && x >= 5 && x <= 10) || (y >= 9 && x >= 7 && x <= 8) ? white : p.fur,
|
|
842
|
-
() => (x < 7 && y < 9 ? 0xe8964a : x > 9 && y > 9 ? 0x2b2b30 : white),
|
|
843
|
-
() => (Math.hypot(x + 0.5 - 8, y + 0.5 - 11) < 3 ? shade(0x5a4030, 1) : 0xf0e2c4),
|
|
844
|
-
]
|
|
845
|
-
|
|
846
|
-
return coats[p.coat]()
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
pixels.fill(p.ground)
|
|
850
|
-
pixels.each((x, y) => {
|
|
851
|
-
if (inEar(x, y)) {
|
|
852
|
-
const pink = Math.abs(x + 0.5 - (x < 8 ? 3.5 : 12.5)) < 0.8 && y > 6 - p.ears + 1
|
|
853
|
-
|
|
854
|
-
return pink ? 0xf2a7b8 : p.coat === 4 ? 0x5a4030 : coat(x, 7)
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
return inHead(x, y) ? coat(x, y) : undefined
|
|
858
|
-
})
|
|
859
|
-
|
|
860
|
-
const eyeY = 9
|
|
861
|
-
;[5, 9].forEach((x) => {
|
|
862
|
-
if (blink) return pixels.rect(x, eyeY + 1, 2, 1, shade(p.fur, 0.4))
|
|
863
|
-
pixels.rect(x, eyeY, 2, 2, p.iris)
|
|
864
|
-
pixels.rect(x + (x < 8 ? 1 : 0), eyeY, 1, 2, 0x161616)
|
|
865
|
-
})
|
|
866
|
-
pixels.rect(7, 12, 2, 1, 0xf28fa3)
|
|
867
|
-
pixels.set(7, 13, shade(coat(7, 13), 0.6))
|
|
868
|
-
pixels.set(8, 13, shade(coat(8, 13), 0.6))
|
|
869
|
-
const whisker = luma(p.ground) > 0.5 ? shade(p.ground, 0.55) : tint(p.ground, 0.55)
|
|
870
|
-
;[0, 1, 14, 15].forEach((x) => {
|
|
871
|
-
if (!inHead(x, 12)) pixels.set(x, 12, whisker)
|
|
872
|
-
|
|
873
|
-
if (!inHead(x, 13) && (x === 1 || x === 14)) pixels.set(x, 13, whisker)
|
|
874
|
-
})
|
|
875
|
-
},
|
|
876
|
-
},
|
|
877
|
-
]
|
|
878
|
-
|
|
879
|
-
const OBJECTS: Definition[] = [
|
|
880
|
-
{
|
|
881
|
-
id: "potion",
|
|
882
|
-
name: "Potion",
|
|
883
|
-
family: "Objects",
|
|
884
|
-
label: "A round, conical, vial or square flask of glowing liquid with a cork; it bubbles on hover",
|
|
885
|
-
animated: true,
|
|
886
|
-
resolve: (random) => {
|
|
887
|
-
const r = random("potion")
|
|
888
|
-
const all = colors(palette(random("palette")))
|
|
889
|
-
|
|
890
|
-
return {
|
|
891
|
-
grid: 16,
|
|
892
|
-
flask: int(r, 0, 3),
|
|
893
|
-
liquid: pick(r, POTIONS),
|
|
894
|
-
level: range(r, 0.35, 0.8),
|
|
895
|
-
ground: r() < 0.6 ? pick(r, [0x1a1626, 0x14231f, 0x231a14, 0x161c2a]) : all[0],
|
|
896
|
-
seed: seed(r),
|
|
897
|
-
}
|
|
898
|
-
},
|
|
899
|
-
paint: (pixels, p, t) => {
|
|
900
|
-
const flasks = [
|
|
901
|
-
(x: number, y: number) => Math.hypot(x + 0.5 - 8, y + 0.5 - 10) < 4.6 || (y >= 2 && y <= 6 && x >= 7 && x <= 8),
|
|
902
|
-
(x: number, y: number) => (y >= 2 && y <= 6 && x >= 7 && x <= 8) || (y > 6 && y <= 13 && Math.abs(x + 0.5 - 8) < 1 + (y - 6) * 0.75),
|
|
903
|
-
(x: number, y: number) => y >= 2 && y <= 13 && x >= 6 && x <= 9 && !(y === 13 && (x === 6 || x === 9)),
|
|
904
|
-
(x: number, y: number) =>
|
|
905
|
-
(y >= 2 && y <= 4 && x >= 7 && x <= 8) || (y === 5 && x >= 5 && x <= 10) || (y >= 6 && y <= 13 && x >= 4 && x <= 11),
|
|
906
|
-
]
|
|
907
|
-
|
|
908
|
-
const inside = flasks[p.flask]
|
|
909
|
-
const rows = Array.from({ length: 16 }, (_, y) => y).filter((y) => Array.from({ length: 16 }, (_, x) => x).some((x) => inside(x, y)))
|
|
910
|
-
const top = rows[0]
|
|
911
|
-
const bottom = rows[rows.length - 1]
|
|
912
|
-
const surface = Math.round(bottom - (bottom - top - 2) * p.level)
|
|
913
|
-
const dark = luma(p.ground) < 0.3
|
|
914
|
-
const glass = dark ? mix(p.ground, 0xffffff, 0.16) : mix(p.ground, 0x6a7a8a, 0.18)
|
|
915
|
-
const rim = dark ? mix(p.ground, 0xffffff, 0.5) : shade(p.ground, 0.45)
|
|
916
|
-
|
|
917
|
-
pixels.each((x, y) => {
|
|
918
|
-
if (inside(x, y)) {
|
|
919
|
-
if (y <= top) return 0x9c6b3e
|
|
920
|
-
|
|
921
|
-
if (y < surface) return x === 6 || x === 7 ? mix(glass, 0xffffff, 0.2) : glass
|
|
922
|
-
|
|
923
|
-
return y === surface ? tint(p.liquid, 0.35) : x <= 6 && y === surface + 1 ? tint(p.liquid, 0.2) : p.liquid
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
const edge = inside(x - 1, y) || inside(x + 1, y) || inside(x, y + 1)
|
|
927
|
-
|
|
928
|
-
if (edge) return rim
|
|
929
|
-
|
|
930
|
-
const near = [-2, -1, 1, 2].some((d) => inside(x + d, y) || inside(x, y + d))
|
|
931
|
-
|
|
932
|
-
return dark && near && dither(0.4, 2, x, y) ? mix(p.ground, p.liquid, 0.22) : p.ground
|
|
933
|
-
})
|
|
934
|
-
|
|
935
|
-
const rand = mulberry32(p.seed)
|
|
936
|
-
Array.from({ length: 3 }, () => {
|
|
937
|
-
const x = 6 + Math.floor(rand() * 4)
|
|
938
|
-
const span = bottom - surface - 1
|
|
939
|
-
const y = bottom - 1 - Math.floor(((rand() * span + t * 6) % Math.max(1, span)))
|
|
940
|
-
|
|
941
|
-
if (inside(x, y) && y > surface) pixels.set(x, y, tint(p.liquid, 0.6))
|
|
942
|
-
})
|
|
943
|
-
},
|
|
944
|
-
},
|
|
945
|
-
{
|
|
946
|
-
id: "gem",
|
|
947
|
-
name: "Gem",
|
|
948
|
-
family: "Objects",
|
|
949
|
-
label: "A faceted brilliant, emerald, cushion, trillion or marquise cut, lit from the top left",
|
|
950
|
-
animated: true,
|
|
951
|
-
resolve: (random) => {
|
|
952
|
-
const r = random("gem")
|
|
953
|
-
|
|
954
|
-
return {
|
|
955
|
-
grid: 16,
|
|
956
|
-
cut: int(r, 0, 4),
|
|
957
|
-
stone: pick(r, GEMS),
|
|
958
|
-
ground: pick(r, VELVETS),
|
|
959
|
-
facets: pick(r, [6, 8, 8, 10]),
|
|
960
|
-
turn: r() * Math.PI,
|
|
961
|
-
}
|
|
962
|
-
},
|
|
963
|
-
paint: (pixels, p, t) => {
|
|
964
|
-
const cuts = [
|
|
965
|
-
(dx: number, dy: number) => Math.max(Math.abs(dx), Math.abs(dy), (Math.abs(dx) + Math.abs(dy)) / 1.35) < 6,
|
|
966
|
-
(dx: number, dy: number) => Math.abs(dx) < 6.2 && Math.abs(dy) < 4.6 && Math.abs(dx) + Math.abs(dy) < 9,
|
|
967
|
-
(dx: number, dy: number) => (dx / 6) ** 4 + (dy / 6) ** 4 < 1,
|
|
968
|
-
(dx: number, dy: number) => dy > -4.5 && dy < 6 - Math.abs(dx) * 1.7 - 0.5 && Math.abs(dx) < 6.5,
|
|
969
|
-
(dx: number, dy: number) => Math.hypot(dx - 4.5, dy) < 7.8 && Math.hypot(dx + 4.5, dy) < 7.8 && Math.abs(dy) < 6.4,
|
|
970
|
-
]
|
|
971
|
-
|
|
972
|
-
const cut = cuts[p.cut]
|
|
973
|
-
const flip = p.cut === 3 ? -1 : 1
|
|
974
|
-
const [lx, ly] = [-0.6, -0.8]
|
|
975
|
-
const dark = luma(p.ground) < 0.4
|
|
976
|
-
|
|
977
|
-
pixels.each((x, y) => {
|
|
978
|
-
const dx = x + 0.5 - 8
|
|
979
|
-
const dy = (y + 0.5 - 8) * flip
|
|
980
|
-
const rotated = p.cut === 4 ? [dx * Math.cos(p.turn * 0.3) - dy * Math.sin(p.turn * 0.3), dx * Math.sin(p.turn * 0.3) + dy * Math.cos(p.turn * 0.3)] : [dx, dy]
|
|
981
|
-
|
|
982
|
-
if (!cut(rotated[0], rotated[1])) {
|
|
983
|
-
const halo = dark && cut(rotated[0] * 0.8, rotated[1] * 0.8)
|
|
984
|
-
|
|
985
|
-
return halo ? mix(p.ground, p.stone, 0.15) : p.ground
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
if (!cut(rotated[0] * 1.2, rotated[1] * 1.2)) return shade(p.stone, 0.45)
|
|
989
|
-
|
|
990
|
-
if (cut(rotated[0] * 2.1, rotated[1] * 2.1)) return dx + dy < -1 ? tint(p.stone, 0.45) : tint(p.stone, 0.22)
|
|
991
|
-
const sector = Math.floor(((Math.atan2(dy, dx) + Math.PI) / (Math.PI * 2)) * p.facets)
|
|
992
|
-
const middle = ((sector + 0.5) / p.facets) * Math.PI * 2 - Math.PI
|
|
993
|
-
const lit = Math.cos(middle) * lx + Math.sin(middle) * ly
|
|
994
|
-
|
|
995
|
-
return lit > 0.35 ? tint(p.stone, 0.3) : lit > -0.3 ? p.stone : shade(p.stone, 0.68)
|
|
996
|
-
})
|
|
997
|
-
|
|
998
|
-
const glint = Math.floor(t * 2.5) % 3
|
|
999
|
-
const spots = [
|
|
1000
|
-
[5, 5],
|
|
1001
|
-
[10, 6],
|
|
1002
|
-
[6, 10],
|
|
1003
|
-
]
|
|
1004
|
-
const [sx, sy] = spots[t > 0 ? glint : 0]
|
|
1005
|
-
pixels.set(sx, sy, 0xffffff)
|
|
1006
|
-
pixels.set(sx - 1, sy, tint(p.stone, 0.7))
|
|
1007
|
-
pixels.set(sx + 1, sy, tint(p.stone, 0.7))
|
|
1008
|
-
pixels.set(sx, sy - 1, tint(p.stone, 0.7))
|
|
1009
|
-
pixels.set(sx, sy + 1, tint(p.stone, 0.7))
|
|
1010
|
-
},
|
|
1011
|
-
},
|
|
1012
|
-
{
|
|
1013
|
-
id: "house",
|
|
1014
|
-
name: "Tiny house",
|
|
1015
|
-
family: "Objects",
|
|
1016
|
-
label: "A little house with a gable, A-frame, flat, mansard or dome roof; its chimney smokes on hover",
|
|
1017
|
-
animated: true,
|
|
1018
|
-
resolve: (random) => {
|
|
1019
|
-
const r = random("house")
|
|
1020
|
-
const wall = pick(r, WALLS)
|
|
1021
|
-
|
|
1022
|
-
return {
|
|
1023
|
-
grid: 16,
|
|
1024
|
-
...prefixed("d", pick(r, DAYS)),
|
|
1025
|
-
wall,
|
|
1026
|
-
roofColor: pick(
|
|
1027
|
-
r,
|
|
1028
|
-
ROOFS.filter((roof) => Math.abs(luma(roof) - luma(wall)) > 0.15),
|
|
1029
|
-
),
|
|
1030
|
-
width: pick(r, [8, 9, 10, 11]),
|
|
1031
|
-
height: int(r, 4, 5),
|
|
1032
|
-
x: int(r, 2, 4),
|
|
1033
|
-
roof: int(r, 0, 4),
|
|
1034
|
-
door: r(),
|
|
1035
|
-
chimney: r() < 0.6 ? 1 : 0,
|
|
1036
|
-
tree: r() < 0.5 ? 1 : 0,
|
|
1037
|
-
moonX: int(r, 2, 13),
|
|
1038
|
-
}
|
|
1039
|
-
},
|
|
1040
|
-
paint: (pixels, p, t) => {
|
|
1041
|
-
const [top, bottom, ground, light] = colors(p, "d", 4)
|
|
1042
|
-
const night = luma(top) < 0.2
|
|
1043
|
-
const sky = [top, mix(top, bottom, 0.5), bottom]
|
|
1044
|
-
const base = 13
|
|
1045
|
-
const x0 = Math.min(p.x, 15 - p.width)
|
|
1046
|
-
const x1 = x0 + p.width - 1
|
|
1047
|
-
const y0 = base - p.height
|
|
1048
|
-
const center = (x0 + x1) / 2
|
|
1049
|
-
const roofShade = shade(p.roofColor, 0.75)
|
|
1050
|
-
|
|
1051
|
-
pixels.each((x, y) => (y >= base ? (y === base ? tint(ground, 0.12) : ground) : sky[dither(y / 12, 3, x, y)]))
|
|
1052
|
-
pixels.disc(p.moonX + 0.5, 2.5, 1.5, light)
|
|
1053
|
-
|
|
1054
|
-
if (p.tree) {
|
|
1055
|
-
const tx = x1 + 2 < 15 ? x1 + 2 : x0 - 2
|
|
1056
|
-
pixels.rect(tx, base - 2, 1, 2, 0x6b4423)
|
|
1057
|
-
pixels.disc(tx + 0.5, base - 3.5, 1.8, night ? 0x1f3b2c : 0x3f7d3a)
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
const roofs = [
|
|
1061
|
-
() => {
|
|
1062
|
-
const peak = Math.ceil(p.width / 2)
|
|
1063
|
-
Array.from({ length: peak }, (_, k) => pixels.rect(x0 - 1 + k, y0 - 1 - k, p.width + 2 - k * 2, 1, k % 2 ? roofShade : p.roofColor))
|
|
1064
|
-
|
|
1065
|
-
return y0 - peak
|
|
1066
|
-
},
|
|
1067
|
-
() => {
|
|
1068
|
-
pixels.each((x, y) => (y < base && y >= base - p.height - 5 && Math.abs(x + 0.5 - (center + 0.5)) < (y - (base - p.height - 6)) * 0.62 ? p.roofColor : undefined))
|
|
1069
|
-
|
|
1070
|
-
return base - p.height - 5
|
|
1071
|
-
},
|
|
1072
|
-
() => {
|
|
1073
|
-
pixels.rect(x0 - 1, y0 - 1, p.width + 2, 1, p.roofColor)
|
|
1074
|
-
pixels.rect(x0, y0 - 2, 1, 1, p.roofColor)
|
|
1075
|
-
pixels.rect(x1, y0 - 2, 1, 1, p.roofColor)
|
|
1076
|
-
|
|
1077
|
-
return y0 - 2
|
|
1078
|
-
},
|
|
1079
|
-
() => {
|
|
1080
|
-
pixels.rect(x0 - 1, y0 - 1, p.width + 2, 1, roofShade)
|
|
1081
|
-
pixels.rect(x0, y0 - 2, p.width, 1, p.roofColor)
|
|
1082
|
-
pixels.rect(x0 + 1, y0 - 3, p.width - 2, 1, p.roofColor)
|
|
1083
|
-
|
|
1084
|
-
return y0 - 3
|
|
1085
|
-
},
|
|
1086
|
-
() => {
|
|
1087
|
-
pixels.disc(center + 0.5, y0, p.width / 2, p.roofColor)
|
|
1088
|
-
|
|
1089
|
-
return y0 - Math.floor(p.width / 2)
|
|
1090
|
-
},
|
|
1091
|
-
]
|
|
1092
|
-
|
|
1093
|
-
if (p.roof !== 1) pixels.rect(x0, y0, p.width, p.height, p.wall)
|
|
1094
|
-
const roofTop = roofs[p.roof]()
|
|
1095
|
-
|
|
1096
|
-
if (p.roof === 1) pixels.rect(Math.round(center) - 1, base - 3, 3, 3, p.wall)
|
|
1097
|
-
|
|
1098
|
-
const window = night ? light : mix(top, 0xffffff, 0.5)
|
|
1099
|
-
const doorX = p.roof === 1 ? Math.round(center) : x0 + 1 + Math.floor(p.door * (p.width - 3))
|
|
1100
|
-
pixels.rect(doorX, base - 3, p.roof === 1 ? 1 : 2, 3, shade(p.roofColor, 0.6))
|
|
1101
|
-
|
|
1102
|
-
if (p.roof !== 1) {
|
|
1103
|
-
;[x0 + 1, x1 - 2].forEach((wx) => {
|
|
1104
|
-
if (Math.abs(wx - doorX) < 3) return
|
|
1105
|
-
pixels.rect(wx, y0 + 1, 2, 2, window)
|
|
1106
|
-
})
|
|
1107
|
-
}
|
|
1108
|
-
|
|
1109
|
-
if (!p.chimney || p.roof === 1 || p.roof === 4) return
|
|
1110
|
-
const cx = x1 - 2
|
|
1111
|
-
pixels.rect(cx, roofTop, 1, Math.max(1, y0 - roofTop), shade(p.roofColor, 0.55))
|
|
1112
|
-
const puff = Math.floor(t * 3)
|
|
1113
|
-
;[0, 1, 2].forEach((k) => pixels.set(cx + ((k + puff) % 2), roofTop - 1 - k - (t > 0 ? puff % 2 : 0), mix(sky[0], 0xffffff, 0.6 - k * 0.15)))
|
|
1114
|
-
},
|
|
1115
|
-
},
|
|
1116
|
-
{
|
|
1117
|
-
id: "lighthouse",
|
|
1118
|
-
name: "Lighthouse",
|
|
1119
|
-
family: "Objects",
|
|
1120
|
-
label: "A banded or spiral tower on a rock in the sea, by day or with a beam at night; the beam turns on hover",
|
|
1121
|
-
animated: true,
|
|
1122
|
-
resolve: (random) => {
|
|
1123
|
-
const r = random("lighthouse")
|
|
1124
|
-
|
|
1125
|
-
return {
|
|
1126
|
-
grid: 16,
|
|
1127
|
-
...prefixed("s", pick(r, SEAS)),
|
|
1128
|
-
x: int(r, 5, 10),
|
|
1129
|
-
bands: int(r, 0, 3),
|
|
1130
|
-
tower: pick(r, [0xc8102e, 0x1a1a1a, 0x1f4fa0, 0x2a9d8f]),
|
|
1131
|
-
beam: r() < 0.5 ? 1 : -1,
|
|
1132
|
-
rock: pick(r, [0x5c5c66, 0x6b4a32, 0x3d3d48]),
|
|
1133
|
-
birds: r() < 0.4 ? 1 : 0,
|
|
1134
|
-
}
|
|
1135
|
-
},
|
|
1136
|
-
paint: (pixels, p, t) => {
|
|
1137
|
-
const [sky, deep, middle, light, foam, sun] = colors(p, "s", 6)
|
|
1138
|
-
const night = luma(sky) < 0.25
|
|
1139
|
-
const white = 0xf4f1ea
|
|
1140
|
-
const lamp = 3
|
|
1141
|
-
|
|
1142
|
-
pixels.each((x, y) => {
|
|
1143
|
-
if (y >= 12) return (x + y * 3) % 7 === 0 ? foam : y === 12 ? light : y > 13 ? deep : middle
|
|
1144
|
-
|
|
1145
|
-
return sky
|
|
1146
|
-
})
|
|
1147
|
-
|
|
1148
|
-
const sweep = Math.sin(t * 1.6) * 0.5
|
|
1149
|
-
const reach = p.beam + (t > 0 ? sweep : 0)
|
|
1150
|
-
|
|
1151
|
-
if (night || t > 0) {
|
|
1152
|
-
pixels.each((x, y) => {
|
|
1153
|
-
const dx = (x + 0.5 - (p.x + 0.5)) * Math.sign(reach)
|
|
1154
|
-
|
|
1155
|
-
if (dx < 1 || y >= 12) return undefined
|
|
1156
|
-
const spread = Math.abs(y + 0.5 - (lamp + 0.5)) / dx
|
|
1157
|
-
|
|
1158
|
-
return spread < 0.28 ? mix(pixels.get(x, y), sun, 0.55 * (1 - dx / 16) * Math.min(1, Math.abs(reach))) : undefined
|
|
1159
|
-
})
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
pixels.each((x, y) => (y >= 11 && y <= 13 && Math.abs(x + 0.5 - (p.x + 0.5)) < 4 - (y - 11) * -0.6 - (y === 11 ? 1.4 : 0) ? p.rock : undefined))
|
|
1163
|
-
|
|
1164
|
-
for (let y = 4; y <= 10; y++) {
|
|
1165
|
-
const half = 1 + (y >= 8 ? 1 : 0)
|
|
1166
|
-
|
|
1167
|
-
for (let x = p.x - half + 1; x <= p.x + half; x++) {
|
|
1168
|
-
const stripes = [y % 4 < 2, (x + y) % 4 < 2, y >= 8 || y === 4, Math.floor((y - 4) / 3) % 2 === 0]
|
|
1169
|
-
pixels.set(x, y, stripes[p.bands] ? p.tower : white)
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
|
|
1173
|
-
pixels.rect(p.x - 1, 3, 3, 1, 0x2b2b2b)
|
|
1174
|
-
pixels.rect(p.x, 2, 2, 2, sun)
|
|
1175
|
-
pixels.rect(p.x, lamp, 1, 1, tint(sun, 0.5))
|
|
1176
|
-
pixels.rect(p.x - 1, 1, 4, 1, shade(p.tower, 0.7))
|
|
1177
|
-
|
|
1178
|
-
if (p.birds && !night) {
|
|
1179
|
-
;[
|
|
1180
|
-
[3, 3],
|
|
1181
|
-
[12, 2],
|
|
1182
|
-
].forEach(([bx, by]) => {
|
|
1183
|
-
pixels.set(bx, by, shade(sky, 0.4))
|
|
1184
|
-
pixels.set(bx + 2, by, shade(sky, 0.4))
|
|
1185
|
-
pixels.set(bx + 1, by + 1, shade(sky, 0.4))
|
|
1186
|
-
})
|
|
1187
|
-
}
|
|
1188
|
-
},
|
|
1189
|
-
},
|
|
1190
|
-
{
|
|
1191
|
-
id: "dice",
|
|
1192
|
-
name: "Dice",
|
|
1193
|
-
family: "Objects",
|
|
1194
|
-
label: "One big die or an overlapping pair in six finishes on felt, wood or leather; they roll on hover",
|
|
1195
|
-
animated: true,
|
|
1196
|
-
resolve: (random) => {
|
|
1197
|
-
const r = random("dice")
|
|
1198
|
-
const [body, pip] = pick(r, DICE)
|
|
1199
|
-
|
|
1200
|
-
return {
|
|
1201
|
-
grid: 16,
|
|
1202
|
-
layout: int(r, 0, 1),
|
|
1203
|
-
body,
|
|
1204
|
-
pip,
|
|
1205
|
-
felt: pick(r, FELTS),
|
|
1206
|
-
a: int(r, 1, 6),
|
|
1207
|
-
b: int(r, 1, 6),
|
|
1208
|
-
}
|
|
1209
|
-
},
|
|
1210
|
-
paint: (pixels, p, t) => {
|
|
1211
|
-
const roll = Math.floor(t * 6)
|
|
1212
|
-
const face = (n: number) => ((n - 1 + roll) % 6) + 1
|
|
1213
|
-
pixels.fill(p.felt)
|
|
1214
|
-
pixels.each((x, y) => (grain(x, y, 2) < 0.12 ? shade(p.felt, 0.88) : undefined))
|
|
1215
|
-
|
|
1216
|
-
const die = (x0: number, y0: number, size: number, value: number, pipSize: number) => {
|
|
1217
|
-
pixels.rect(x0 + 1, y0 + size, size, 1, shade(p.felt, 0.6))
|
|
1218
|
-
pixels.rect(x0 + size, y0 + 1, 1, size, shade(p.felt, 0.6))
|
|
1219
|
-
pixels.rect(x0, y0, size, size, p.body)
|
|
1220
|
-
pixels.rect(x0, y0 + size - 1, size, 1, shade(p.body, 0.8))
|
|
1221
|
-
pixels.rect(x0 + size - 1, y0, 1, size, shade(p.body, 0.8))
|
|
1222
|
-
pixels.set(x0, y0, p.felt)
|
|
1223
|
-
pixels.set(x0 + size - 1, y0, p.felt)
|
|
1224
|
-
pixels.set(x0, y0 + size - 1, p.felt)
|
|
1225
|
-
pixels.set(x0 + size - 1, y0 + size - 1, p.felt)
|
|
1226
|
-
const step = (size - pipSize) / 2
|
|
1227
|
-
PIPS[value - 1].forEach((spot) => {
|
|
1228
|
-
const color = value === 1 && p.pip === 0x1a1a1a ? 0xc8102e : p.pip
|
|
1229
|
-
pixels.rect(Math.round(x0 + (spot % 3) * step * 0.78 + step * 0.22), Math.round(y0 + Math.floor(spot / 3) * step * 0.78 + step * 0.22), pipSize, pipSize, color)
|
|
1230
|
-
})
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
|
-
const layouts = [
|
|
1234
|
-
() => die(2, 2, 12, face(p.a), 2),
|
|
1235
|
-
() => {
|
|
1236
|
-
die(1, 2, 8, face(p.a), 1)
|
|
1237
|
-
die(7, 6, 8, face(p.b), 1)
|
|
1238
|
-
},
|
|
1239
|
-
]
|
|
1240
|
-
|
|
1241
|
-
layouts[p.layout]()
|
|
1242
|
-
},
|
|
1243
|
-
},
|
|
1244
|
-
]
|
|
1245
|
-
|
|
1246
|
-
const EMBLEMS: Definition[] = [
|
|
1247
|
-
{
|
|
1248
|
-
id: "shield",
|
|
1249
|
-
name: "Shield",
|
|
1250
|
-
family: "Emblems",
|
|
1251
|
-
label: "A heater shield with one of thirteen heraldic divisions and ordinaries, by the rule of tincture",
|
|
1252
|
-
resolve: (random) => {
|
|
1253
|
-
const r = random("shield")
|
|
1254
|
-
const metal = pick(r, METAL_TINCTURES)
|
|
1255
|
-
const colour = pick(r, COLOUR_TINCTURES)
|
|
1256
|
-
const metalFirst = r() < 0.5
|
|
1257
|
-
const all = colors(palette(random("palette")))
|
|
1258
|
-
|
|
1259
|
-
return {
|
|
1260
|
-
grid: 16,
|
|
1261
|
-
field: metalFirst ? metal : colour,
|
|
1262
|
-
charge: metalFirst ? colour : metal,
|
|
1263
|
-
third: pick(
|
|
1264
|
-
r,
|
|
1265
|
-
[...METAL_TINCTURES, ...COLOUR_TINCTURES].filter((c) => c !== metal && c !== colour),
|
|
1266
|
-
),
|
|
1267
|
-
ordinary: int(r, 0, 12),
|
|
1268
|
-
roundel: r() < 0.4 ? 1 : 0,
|
|
1269
|
-
ground: r() < 0.5 ? all[0] : 0x1f2228,
|
|
1270
|
-
}
|
|
1271
|
-
},
|
|
1272
|
-
paint: (pixels, p) => {
|
|
1273
|
-
const inside = (x: number, y: number) => {
|
|
1274
|
-
if (y < 1 || y > 14 || x < 2 || x > 13) return false
|
|
1275
|
-
|
|
1276
|
-
if (y <= 7) return true
|
|
1277
|
-
|
|
1278
|
-
return Math.abs(x + 0.5 - 8) < 6 * Math.sqrt(Math.max(0, 1 - ((y + 0.5 - 7.5) / 7.2) ** 2))
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
const ordinaries = [
|
|
1282
|
-
(x: number) => x >= 6 && x <= 9,
|
|
1283
|
-
(_: number, y: number) => y >= 6 && y <= 9,
|
|
1284
|
-
(x: number, y: number) => Math.abs(x - y) <= 1.5,
|
|
1285
|
-
(x: number, y: number) => Math.abs(y - (12 - Math.abs(x + 0.5 - 8) * 1)) <= 1.2,
|
|
1286
|
-
(x: number, y: number) => (x >= 7 && x <= 8) || (y >= 6 && y <= 7),
|
|
1287
|
-
(x: number, y: number) => Math.abs(x - y) <= 0.8 || Math.abs(x + y - 15) <= 0.8,
|
|
1288
|
-
(_: number, y: number) => y <= 4,
|
|
1289
|
-
(x: number) => x >= 8,
|
|
1290
|
-
(x: number, y: number) => x >= 8 !== y >= 8,
|
|
1291
|
-
(x: number, y: number) => x < y,
|
|
1292
|
-
(x: number, y: number) => !inside(x - 1, y) || !inside(x + 1, y) || !inside(x, y + 1) || y <= 2,
|
|
1293
|
-
(x: number) => Math.floor((x - 2) / 2) % 2 === 1,
|
|
1294
|
-
(x: number, y: number) => (Math.floor((x - 2) / 3) + Math.floor((y - 1) / 3)) % 2 === 1,
|
|
1295
|
-
]
|
|
1296
|
-
|
|
1297
|
-
pixels.fill(p.ground)
|
|
1298
|
-
pixels.each((x, y) => {
|
|
1299
|
-
if (!inside(x, y)) return inside(x - 1, y) || inside(x + 1, y) || inside(x, y - 1) ? 0x2a2a2a : undefined
|
|
1300
|
-
|
|
1301
|
-
return ordinaries[p.ordinary](x, y) ? p.charge : p.field
|
|
1302
|
-
})
|
|
1303
|
-
|
|
1304
|
-
if (!p.roundel) return
|
|
1305
|
-
const spot = p.ordinary === 6 ? [8, 2.6] : [8, 10]
|
|
1306
|
-
pixels.disc(spot[0], spot[1], 1.6, p.third)
|
|
1307
|
-
},
|
|
1308
|
-
},
|
|
1309
|
-
{
|
|
1310
|
-
id: "constellation",
|
|
1311
|
-
name: "Constellation",
|
|
1312
|
-
family: "Emblems",
|
|
1313
|
-
label: "Four to seven stars joined by their shortest links, on a night sky or a parchment chart; they twinkle on hover",
|
|
1314
|
-
animated: true,
|
|
1315
|
-
resolve: (random) => {
|
|
1316
|
-
const r = random("constellation")
|
|
1317
|
-
const count = int(r, 4, 7)
|
|
1318
|
-
|
|
1319
|
-
const points = retry(
|
|
1320
|
-
() => Array.from({ length: count }, () => [range(r, 0.14, 0.86), range(r, 0.14, 0.86)]),
|
|
1321
|
-
(list) => list.every(([x, y], i) => list.every(([u, v], j) => i === j || Math.hypot(x - u, y - v) > 0.2)),
|
|
1322
|
-
)
|
|
1323
|
-
|
|
1324
|
-
return {
|
|
1325
|
-
count,
|
|
1326
|
-
seed: seed(r),
|
|
1327
|
-
...prefixed("k", pick(r, CHARTS)),
|
|
1328
|
-
...prefixed(
|
|
1329
|
-
"x",
|
|
1330
|
-
points.map(([x]) => x),
|
|
1331
|
-
),
|
|
1332
|
-
...prefixed(
|
|
1333
|
-
"y",
|
|
1334
|
-
points.map(([, y]) => y),
|
|
1335
|
-
),
|
|
1336
|
-
...prefixed(
|
|
1337
|
-
"m",
|
|
1338
|
-
points.map(() => r()),
|
|
1339
|
-
),
|
|
1340
|
-
}
|
|
1341
|
-
},
|
|
1342
|
-
vector: (ctx, px, p, t) => {
|
|
1343
|
-
const [top, bottom, line, star] = colors(p, "k", 4)
|
|
1344
|
-
const xs = colors(p, "x", p.count)
|
|
1345
|
-
const ys = colors(p, "y", p.count)
|
|
1346
|
-
const sizes = colors(p, "m", p.count)
|
|
1347
|
-
const gradient = ctx.createLinearGradient(0, 0, 0, px)
|
|
1348
|
-
gradient.addColorStop(0, css(top))
|
|
1349
|
-
gradient.addColorStop(1, css(bottom))
|
|
1350
|
-
ctx.fillStyle = gradient
|
|
1351
|
-
ctx.fillRect(0, 0, px, px)
|
|
1352
|
-
const rand = mulberry32(p.seed)
|
|
1353
|
-
ctx.fillStyle = css(star, 0.35)
|
|
1354
|
-
Array.from({ length: 18 }, () => ctx.fillRect(rand() * px, rand() * px, px / 64 + 0.5, px / 64 + 0.5))
|
|
1355
|
-
|
|
1356
|
-
const linked = [0]
|
|
1357
|
-
ctx.strokeStyle = css(line, 0.75)
|
|
1358
|
-
ctx.lineWidth = Math.max(1, px * 0.025)
|
|
1359
|
-
|
|
1360
|
-
while (linked.length < p.count) {
|
|
1361
|
-
const [a, b] = linked
|
|
1362
|
-
.flatMap((i) => xs.map((_, j) => [i, j]))
|
|
1363
|
-
.filter(([, j]) => !linked.includes(j))
|
|
1364
|
-
.toSorted(([i, j], [k, l]) => Math.hypot(xs[i] - xs[j], ys[i] - ys[j]) - Math.hypot(xs[k] - xs[l], ys[k] - ys[l]))[0]
|
|
1365
|
-
ctx.beginPath()
|
|
1366
|
-
ctx.moveTo(xs[a] * px, ys[a] * px)
|
|
1367
|
-
ctx.lineTo(xs[b] * px, ys[b] * px)
|
|
1368
|
-
ctx.stroke()
|
|
1369
|
-
linked.push(b)
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
xs.forEach((x, i) => {
|
|
1373
|
-
const twinkle = 1 - 0.35 * (1 - Math.cos(t * (3 + sizes[i] * 4)))
|
|
1374
|
-
const radius = px * (0.03 + sizes[i] * 0.035) * twinkle
|
|
1375
|
-
ctx.fillStyle = css(star, 0.25)
|
|
1376
|
-
ctx.beginPath()
|
|
1377
|
-
ctx.arc(x * px, ys[i] * px, radius * 2.2, 0, Math.PI * 2)
|
|
1378
|
-
ctx.fill()
|
|
1379
|
-
ctx.fillStyle = css(star)
|
|
1380
|
-
ctx.beginPath()
|
|
1381
|
-
ctx.arc(x * px, ys[i] * px, radius, 0, Math.PI * 2)
|
|
1382
|
-
ctx.fill()
|
|
1383
|
-
})
|
|
1384
|
-
},
|
|
1385
|
-
},
|
|
1386
|
-
{
|
|
1387
|
-
id: "compass",
|
|
1388
|
-
name: "Compass rose",
|
|
1389
|
-
family: "Emblems",
|
|
1390
|
-
label: "A four-, eight- or sixteen-point rose with split points, a ring and ticks; the needle swings on hover",
|
|
1391
|
-
animated: true,
|
|
1392
|
-
resolve: (random) => {
|
|
1393
|
-
const r = random("compass")
|
|
1394
|
-
|
|
1395
|
-
return {
|
|
1396
|
-
...prefixed("k", pick(r, ROSES)),
|
|
1397
|
-
points: pick(r, [4, 8, 8, 16]),
|
|
1398
|
-
ring: r() < 0.7 ? 1 : 0,
|
|
1399
|
-
ticks: pick(r, [0, 16, 32]),
|
|
1400
|
-
turn: pick(r, [0, 0, 0, Math.PI / 8, Math.PI / 4]),
|
|
1401
|
-
north: r() < 0.6 ? 1 : 0,
|
|
1402
|
-
}
|
|
1403
|
-
},
|
|
1404
|
-
vector: (ctx, px, p, t) => {
|
|
1405
|
-
const [ground, dark, light, accent] = colors(p, "k", 4)
|
|
1406
|
-
const c = px / 2
|
|
1407
|
-
ctx.fillStyle = css(ground)
|
|
1408
|
-
ctx.fillRect(0, 0, px, px)
|
|
1409
|
-
ctx.save()
|
|
1410
|
-
ctx.translate(c, c)
|
|
1411
|
-
ctx.rotate(p.turn + Math.sin(t * 3) * 0.25 * Math.exp(-t * 0.4))
|
|
1412
|
-
|
|
1413
|
-
if (p.ring) {
|
|
1414
|
-
ctx.strokeStyle = css(dark)
|
|
1415
|
-
ctx.lineWidth = px * 0.03
|
|
1416
|
-
ctx.beginPath()
|
|
1417
|
-
ctx.arc(0, 0, px * 0.36, 0, Math.PI * 2)
|
|
1418
|
-
ctx.stroke()
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1421
|
-
Array.from({ length: p.ticks }, (_, k) => {
|
|
1422
|
-
const angle = (k / p.ticks) * Math.PI * 2
|
|
1423
|
-
ctx.beginPath()
|
|
1424
|
-
ctx.moveTo(Math.cos(angle) * px * 0.4, Math.sin(angle) * px * 0.4)
|
|
1425
|
-
ctx.lineTo(Math.cos(angle) * px * 0.45, Math.sin(angle) * px * 0.45)
|
|
1426
|
-
ctx.strokeStyle = css(dark)
|
|
1427
|
-
ctx.lineWidth = px * 0.02
|
|
1428
|
-
ctx.stroke()
|
|
1429
|
-
})
|
|
1430
|
-
|
|
1431
|
-
const order = Array.from({ length: p.points }, (_, k) => k).toSorted((a, b) => (b % 2) - (a % 2) || (b % 4) - (a % 4))
|
|
1432
|
-
order.forEach((k) => {
|
|
1433
|
-
const angle = (k / p.points) * Math.PI * 2 - Math.PI / 2
|
|
1434
|
-
const level = k % 4 === 0 ? 1 : k % 2 === 0 ? 0.68 : 0.46
|
|
1435
|
-
const length = px * 0.46 * (p.points === 4 ? 1 : level)
|
|
1436
|
-
const width = px * (p.points === 4 ? 0.14 : 0.1) * (level < 1 ? 0.8 : 1)
|
|
1437
|
-
const tip = [Math.cos(angle) * length, Math.sin(angle) * length]
|
|
1438
|
-
const side = [Math.cos(angle + Math.PI / 2) * width, Math.sin(angle + Math.PI / 2) * width]
|
|
1439
|
-
;[1, -1].forEach((s) => {
|
|
1440
|
-
ctx.beginPath()
|
|
1441
|
-
ctx.moveTo(0, 0)
|
|
1442
|
-
ctx.lineTo(tip[0], tip[1])
|
|
1443
|
-
ctx.lineTo(side[0] * s, side[1] * s)
|
|
1444
|
-
ctx.closePath()
|
|
1445
|
-
ctx.fillStyle = css(k === 0 && p.north ? (s > 0 ? accent : shade(accent, 0.7)) : s > 0 ? dark : light)
|
|
1446
|
-
ctx.fill()
|
|
1447
|
-
ctx.strokeStyle = css(dark)
|
|
1448
|
-
ctx.lineWidth = px * 0.012
|
|
1449
|
-
ctx.stroke()
|
|
1450
|
-
})
|
|
1451
|
-
})
|
|
1452
|
-
ctx.fillStyle = css(light)
|
|
1453
|
-
ctx.beginPath()
|
|
1454
|
-
ctx.arc(0, 0, px * 0.035, 0, Math.PI * 2)
|
|
1455
|
-
ctx.fill()
|
|
1456
|
-
ctx.restore()
|
|
1457
|
-
},
|
|
1458
|
-
},
|
|
1459
|
-
{
|
|
1460
|
-
id: "sigil",
|
|
1461
|
-
name: "Sigil",
|
|
1462
|
-
family: "Emblems",
|
|
1463
|
-
label: "A bind-rune of staves and branches cut into slate, sandstone, wood or vellum, or glowing; the glow pulses on hover",
|
|
1464
|
-
animated: true,
|
|
1465
|
-
resolve: (random) => {
|
|
1466
|
-
const r = random("sigil")
|
|
1467
|
-
const [stone, mark, glows] = pick(r, TABLETS)
|
|
1468
|
-
const lattice = Array.from({ length: 15 }, (_, i) => i)
|
|
1469
|
-
const branches = int(r, 2, 4)
|
|
1470
|
-
|
|
1471
|
-
const segments = Array.from({ length: branches }, () => {
|
|
1472
|
-
const a = pick(r, lattice)
|
|
1473
|
-
const options = lattice.filter((b) => {
|
|
1474
|
-
const dx = Math.abs((b % 3) - (a % 3))
|
|
1475
|
-
const dy = Math.abs(Math.floor(b / 3) - Math.floor(a / 3))
|
|
1476
|
-
|
|
1477
|
-
return b !== a && dx <= 1 && dy <= 1
|
|
1478
|
-
})
|
|
1479
|
-
|
|
1480
|
-
return [a, pick(r, options)]
|
|
1481
|
-
})
|
|
1482
|
-
|
|
1483
|
-
return {
|
|
1484
|
-
grid: 16,
|
|
1485
|
-
stone,
|
|
1486
|
-
mark,
|
|
1487
|
-
glows,
|
|
1488
|
-
staves: r() < 0.7 ? 1 : 2,
|
|
1489
|
-
mirror: r() < 0.5 ? 1 : 0,
|
|
1490
|
-
branches,
|
|
1491
|
-
...prefixed(
|
|
1492
|
-
"a",
|
|
1493
|
-
segments.map(([a]) => a),
|
|
1494
|
-
),
|
|
1495
|
-
...prefixed(
|
|
1496
|
-
"b",
|
|
1497
|
-
segments.map(([, b]) => b),
|
|
1498
|
-
),
|
|
1499
|
-
salt: r() * 50,
|
|
1500
|
-
}
|
|
1501
|
-
},
|
|
1502
|
-
paint: (pixels, p, t) => {
|
|
1503
|
-
const point = (i: number) => [3 + (i % 3) * 4.5, 1.5 + Math.floor(i / 3) * 3.2].map(Math.round)
|
|
1504
|
-
const marks = new Pixels(16)
|
|
1505
|
-
marks.fill(-1)
|
|
1506
|
-
|
|
1507
|
-
const stroke = (a: number, b: number) => {
|
|
1508
|
-
const [x0, y0] = point(a)
|
|
1509
|
-
const [x1, y1] = point(b)
|
|
1510
|
-
marks.line(x0, y0, x1, y1, 1)
|
|
1511
|
-
marks.line(x0 + 1, y0, x1 + 1, y1, 1)
|
|
1512
|
-
|
|
1513
|
-
if (!p.mirror) return
|
|
1514
|
-
marks.line(15 - x0, y0, 15 - x1, y1, 1)
|
|
1515
|
-
marks.line(14 - x0, y0, 14 - x1, y1, 1)
|
|
1516
|
-
}
|
|
1517
|
-
|
|
1518
|
-
if (p.staves === 1) stroke(1, 13)
|
|
1519
|
-
|
|
1520
|
-
if (p.staves === 2) {
|
|
1521
|
-
stroke(0, 12)
|
|
1522
|
-
stroke(2, 14)
|
|
1523
|
-
}
|
|
1524
|
-
|
|
1525
|
-
Array.from({ length: p.branches }, (_, i) => stroke(p[`a${i}`], p[`b${i}`]))
|
|
1526
|
-
const pulse = p.glows ? 0.5 + 0.5 * Math.sin(t * 4) * Math.min(1, t * 2) : 0
|
|
1527
|
-
|
|
1528
|
-
pixels.each((x, y) => {
|
|
1529
|
-
const textured = shade(p.stone, 0.9 + grain(x, y, p.salt) * 0.2)
|
|
1530
|
-
|
|
1531
|
-
if (marks.cells[y * 16 + x] === 1) return p.glows ? tint(p.mark, pulse * 0.4) : p.mark
|
|
1532
|
-
|
|
1533
|
-
if (!p.glows) return marks.get(x - 1, y - 1) === 1 ? tint(p.stone, 0.2) : textured
|
|
1534
|
-
const near = [-1, 1].some((d) => marks.get(x + d, y) === 1 || marks.get(x, y + d) === 1)
|
|
1535
|
-
|
|
1536
|
-
return near ? mix(textured, p.mark, 0.3 + pulse * 0.2) : textured
|
|
1537
|
-
})
|
|
1538
|
-
},
|
|
1539
|
-
},
|
|
1540
|
-
]
|
|
1541
|
-
|
|
1542
|
-
export const WORLD: Definition[] = [...NATURE, ...CREATURES, ...OBJECTS, ...EMBLEMS]
|
|
1
|
+
// Project icon styles of the world: landscapes and materials, creatures, small objects and emblems. See procedural.ts
|
|
2
|
+
// for the contract.
|
|
3
|
+
|
|
4
|
+
import { mulberry32 } from "./generated"
|
|
5
|
+
import {
|
|
6
|
+
clamp01,
|
|
7
|
+
colors,
|
|
8
|
+
css,
|
|
9
|
+
dither,
|
|
10
|
+
fbm,
|
|
11
|
+
grain,
|
|
12
|
+
int,
|
|
13
|
+
legible,
|
|
14
|
+
luma,
|
|
15
|
+
mix,
|
|
16
|
+
palette,
|
|
17
|
+
pick,
|
|
18
|
+
Pixels,
|
|
19
|
+
prefixed,
|
|
20
|
+
range,
|
|
21
|
+
retry,
|
|
22
|
+
seed,
|
|
23
|
+
shade,
|
|
24
|
+
smoothstep,
|
|
25
|
+
stars,
|
|
26
|
+
tint,
|
|
27
|
+
type Definition,
|
|
28
|
+
} from "./procedural-kit"
|
|
29
|
+
|
|
30
|
+
// Sky top, sky bottom, sun, far, mid, near, snow.
|
|
31
|
+
const RANGES = [
|
|
32
|
+
[0x3b2c5a, 0xf2a7a0, 0xfff1c9, 0x9b7fa6, 0x6a5482, 0x3b2f52, 0xfde6e0],
|
|
33
|
+
[0x4b9be0, 0xcde9f7, 0xfffbe0, 0x8fb3cf, 0x5d7f9b, 0x34505f, 0xffffff],
|
|
34
|
+
[0x1f1d3d, 0xe2725b, 0xffd27a, 0x8a4a62, 0x55304f, 0x2a1b33, 0xf3d2c8],
|
|
35
|
+
[0x0a1028, 0x24305e, 0xeeeedd, 0x2c3a66, 0x1d2850, 0x111833, 0xc9d3ea],
|
|
36
|
+
[0x6fb7e9, 0xe3f3fb, 0xffffff, 0xa4c3d6, 0x5f8f74, 0x2f5a41, 0xffffff],
|
|
37
|
+
[0xe9b872, 0xfbe3b8, 0xfff7e0, 0xd08c5b, 0xa65f3d, 0x6e3b2a, 0xf7d9b0],
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
// Sky, deep, mid, light, foam, sun.
|
|
41
|
+
const SEAS = [
|
|
42
|
+
[0xf6e7c8, 0x0b3954, 0x087e8b, 0x5fb4c8, 0xf4f1ea, 0xe63946],
|
|
43
|
+
[0x9aa5ad, 0x1f2d3a, 0x3d5566, 0x7d94a3, 0xe8eef2, 0xd9dde0],
|
|
44
|
+
[0x9be3f0, 0x006d77, 0x1aa6b7, 0x83e3dc, 0xffffff, 0xffd166],
|
|
45
|
+
[0x0b1030, 0x0a1a3a, 0x16336b, 0x3a62a8, 0xd6e4ff, 0xf0f0d0],
|
|
46
|
+
[0xf6a26b, 0x2d1e4f, 0x5b4b8a, 0xb07cc6, 0xffe0c2, 0xffd166],
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
// Low edge, high edge of the curtains.
|
|
50
|
+
const AURORAS = [
|
|
51
|
+
[0x5cffb0, 0xd36bff],
|
|
52
|
+
[0x6dffa8, 0x3ad6ff],
|
|
53
|
+
[0x7dff8a, 0xff5f8f],
|
|
54
|
+
[0x6fe3ff, 0x8a7dff],
|
|
55
|
+
[0xb6ff6e, 0x5cffd0],
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
const NIGHTS = [0x070b1c, 0x0b1026, 0x0d0a1f, 0x06141a]
|
|
59
|
+
|
|
60
|
+
// Base, vein, clouding.
|
|
61
|
+
const MARBLES = [
|
|
62
|
+
[0xeceae6, 0x7d838b, 0xd2d4d8],
|
|
63
|
+
[0x16171a, 0xe8e6e1, 0x34353a],
|
|
64
|
+
[0x1f4a3a, 0xe3efe6, 0x2f6b55],
|
|
65
|
+
[0x8c2a24, 0xf0d9c8, 0xa8473d],
|
|
66
|
+
[0xf3efe6, 0xb08d57, 0xddd2bd],
|
|
67
|
+
[0x24476b, 0xdbe7f2, 0x3d6a94],
|
|
68
|
+
[0xe8c4c0, 0x7a4a4a, 0xd4a5a0],
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
// Early wood, late wood.
|
|
72
|
+
const WOODS = [
|
|
73
|
+
[0xc89f6b, 0x8f6638],
|
|
74
|
+
[0x6b4a32, 0x3a2618],
|
|
75
|
+
[0xb8643f, 0x82391f],
|
|
76
|
+
[0xe8cfa0, 0xc4a06a],
|
|
77
|
+
[0x3a2e27, 0x14100c],
|
|
78
|
+
[0xe6c48d, 0xb07e42],
|
|
79
|
+
[0xbdb3a3, 0x7f7464],
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
// Liquid top, liquid bottom, wax.
|
|
83
|
+
const LAMPS = [
|
|
84
|
+
[0x3a0ca3, 0xff006e, 0xffbe0b],
|
|
85
|
+
[0x0b3954, 0x087e8b, 0xff5a5f],
|
|
86
|
+
[0x10451d, 0x4c956c, 0xf77f00],
|
|
87
|
+
[0x1d1d3a, 0x5b4b8a, 0x5cffb0],
|
|
88
|
+
[0x5f0f40, 0x9a031e, 0xfff3b0],
|
|
89
|
+
[0x111111, 0x3a3a3a, 0xff3b3b],
|
|
90
|
+
[0x14213d, 0x2a9d8f, 0xffd6e0],
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
const METALS = [0xb8c2cc, 0x8f9ba8, 0xd9a441, 0x6c9ab8, 0xe07a5f, 0x81b29a, 0xf2cc8f]
|
|
94
|
+
|
|
95
|
+
const GLOWS = [0x6fe3ff, 0xff5f5f, 0x39ff7a, 0xffd166, 0xff6fd8]
|
|
96
|
+
|
|
97
|
+
const SLIMES = [0x7bd389, 0x5fa8ff, 0xff7eb6, 0xffd166, 0xb388ff, 0xff8a5c, 0x5ce1e6]
|
|
98
|
+
|
|
99
|
+
const PASTELS = [0xf6efe4, 0xe8f1f2, 0xf3e8f5, 0xfdf1d8, 0xe6f2e1, 0x2b2738, 0x1f2a36]
|
|
100
|
+
|
|
101
|
+
const SHEETS = [0xf4f4f8, 0xdff4ff, 0xffe3f1, 0xe8ffe0, 0xfff3c4]
|
|
102
|
+
|
|
103
|
+
const HAUNTS = [0x1b1830, 0x0f1b2d, 0x2a1b3d, 0x14231c, 0x241a14]
|
|
104
|
+
|
|
105
|
+
const FURS = [0xe8964a, 0x8d929b, 0x2b2b30, 0xf0e2c4, 0x8a5a3b, 0xf4f1ea, 0xc9a06a]
|
|
106
|
+
|
|
107
|
+
const IRISES = [0x8bc34a, 0xffc93c, 0x6fb7ff, 0xf28c28, 0x5ce1e6]
|
|
108
|
+
|
|
109
|
+
const POTIONS = [0xff4d6d, 0x5cffb0, 0x6fa8ff, 0xb388ff, 0xffd166, 0xff8c42, 0x5ce1e6]
|
|
110
|
+
|
|
111
|
+
const GEMS = [0xe0115f, 0x2457c5, 0x13a35a, 0x9b5de5, 0xffb627, 0x5ce1e6, 0xdfe9f5, 0xff6f91]
|
|
112
|
+
|
|
113
|
+
const VELVETS = [0x1a1a2e, 0x2a0f1a, 0x0f2a24, 0x241b0f, 0xf3eee6]
|
|
114
|
+
|
|
115
|
+
// Sky top, sky bottom, ground, light.
|
|
116
|
+
const DAYS = [
|
|
117
|
+
[0x7ec8f2, 0xd9f1ff, 0x6aa84f, 0xfff3b0],
|
|
118
|
+
[0x2b1b4a, 0xf28c5a, 0x3a5a40, 0xffe08a],
|
|
119
|
+
[0x0b1030, 0x2a3a7a, 0x1e3a2b, 0xf0f0d0],
|
|
120
|
+
[0xb8d8e8, 0xeef6fa, 0xf4f8fb, 0xffffff],
|
|
121
|
+
[0xf2c6a0, 0xfde9d2, 0xd9b26f, 0xfff4dc],
|
|
122
|
+
]
|
|
123
|
+
|
|
124
|
+
const WALLS = [0xf4efe6, 0xe9c46a, 0xe07a5f, 0x81b29a, 0x9ec1e0, 0xc9ada7, 0xffffff, 0x3d405b]
|
|
125
|
+
|
|
126
|
+
const ROOFS = [0xb23a48, 0x3d405b, 0x6b4423, 0x264653, 0x2f2f2f, 0x8a3324, 0x2a9d8f]
|
|
127
|
+
|
|
128
|
+
// Pips on a 3 × 3 lattice for faces one to six.
|
|
129
|
+
const PIPS = [
|
|
130
|
+
[4],
|
|
131
|
+
[0, 8],
|
|
132
|
+
[0, 4, 8],
|
|
133
|
+
[0, 2, 6, 8],
|
|
134
|
+
[0, 2, 4, 6, 8],
|
|
135
|
+
[0, 2, 3, 5, 6, 8],
|
|
136
|
+
]
|
|
137
|
+
|
|
138
|
+
// Body, pip.
|
|
139
|
+
const DICE = [
|
|
140
|
+
[0xf6f3ec, 0x1a1a1a],
|
|
141
|
+
[0xc8102e, 0xffffff],
|
|
142
|
+
[0x1a1a1a, 0xf6f3ec],
|
|
143
|
+
[0x1d5fbf, 0xffffff],
|
|
144
|
+
[0xf2e3c4, 0x8a1c1c],
|
|
145
|
+
[0x2a9d8f, 0xffffff],
|
|
146
|
+
]
|
|
147
|
+
|
|
148
|
+
const FELTS = [0x1f6b45, 0x7a4a2a, 0x1d2b4f, 0x5c1f2b, 0x2b2b2b]
|
|
149
|
+
|
|
150
|
+
const METAL_TINCTURES = [0xf2c230, 0xeeeeee]
|
|
151
|
+
|
|
152
|
+
const COLOUR_TINCTURES = [0xc8102e, 0x1f4fa0, 0x1e7a46, 0x1a1a1a, 0x6b3fa0]
|
|
153
|
+
|
|
154
|
+
// Sky top, sky bottom, line, star.
|
|
155
|
+
const CHARTS = [
|
|
156
|
+
[0x0b1030, 0x1f2a5a, 0x9fb3ff, 0xfff6e0],
|
|
157
|
+
[0x10061f, 0x3a1550, 0xd5a6ff, 0xffffff],
|
|
158
|
+
[0x04141c, 0x0d3b4a, 0x7fe0d6, 0xeaffff],
|
|
159
|
+
[0xf1e6cc, 0xe3d3ad, 0x8a5a2b, 0x3a2410],
|
|
160
|
+
]
|
|
161
|
+
|
|
162
|
+
// Ground, dark half, light half, accent.
|
|
163
|
+
const ROSES = [
|
|
164
|
+
[0xf1e6cc, 0x1d3557, 0xf4efe6, 0xc8102e],
|
|
165
|
+
[0x14213d, 0xb08d57, 0xf2d9a0, 0xe63946],
|
|
166
|
+
[0xf5f5f0, 0x1a1a1a, 0xffffff, 0x1a1a1a],
|
|
167
|
+
[0x0f3d3e, 0x2a9d8f, 0xe9f5f2, 0xf4a261],
|
|
168
|
+
[0x3d2b1f, 0x8a5a2b, 0xe9d3a8, 0xf2c230],
|
|
169
|
+
]
|
|
170
|
+
|
|
171
|
+
// Stone, mark, glows.
|
|
172
|
+
const TABLETS = [
|
|
173
|
+
[0x3b4048, 0x1e2126, 0],
|
|
174
|
+
[0xc2a27a, 0x6e5434, 0],
|
|
175
|
+
[0x6b4a32, 0x2e1d12, 0],
|
|
176
|
+
[0xe9dcc0, 0x8a3324, 0],
|
|
177
|
+
[0x101420, 0x6fe3ff, 1],
|
|
178
|
+
[0x1a1010, 0xff8c42, 1],
|
|
179
|
+
]
|
|
180
|
+
|
|
181
|
+
const NATURE: Definition[] = [
|
|
182
|
+
{
|
|
183
|
+
id: "mountains",
|
|
184
|
+
name: "Mountains",
|
|
185
|
+
family: "Nature and materials",
|
|
186
|
+
label: "Three ranges of jagged peaks with snowcaps, a sun or moon, and sometimes a lake",
|
|
187
|
+
resolve: (random) => {
|
|
188
|
+
const r = random("mountains")
|
|
189
|
+
|
|
190
|
+
const peaks = (prefix: string, count: number, low: number, high: number, slope: number) =>
|
|
191
|
+
Object.fromEntries(
|
|
192
|
+
Array.from({ length: count }, (_, i) => [
|
|
193
|
+
[`${prefix}x${i}`, range(r, -2, 18)],
|
|
194
|
+
[`${prefix}h${i}`, range(r, low, high)],
|
|
195
|
+
[`${prefix}s${i}`, slope * range(r, 0.8, 1.3)],
|
|
196
|
+
]).flat(),
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
return {
|
|
200
|
+
grid: 16,
|
|
201
|
+
...prefixed("m", pick(r, RANGES)),
|
|
202
|
+
sunX: range(r, 2, 14),
|
|
203
|
+
sunY: range(r, 2, 6),
|
|
204
|
+
lake: r() < 0.35 ? 1 : 0,
|
|
205
|
+
...peaks("a", 3, 9, 14, 1.2),
|
|
206
|
+
...peaks("b", 3, 6, 9, 0.9),
|
|
207
|
+
...peaks("c", 2, 3, 5, 0.55),
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
paint: (pixels, p) => {
|
|
211
|
+
const [top, bottom, sun, far, middle, near, snow] = colors(p, "m", 7)
|
|
212
|
+
const sky = [top, mix(top, bottom, 0.5), bottom]
|
|
213
|
+
const base = p.lake ? 13 : 16
|
|
214
|
+
|
|
215
|
+
const ridge = (prefix: string, count: number, x: number) =>
|
|
216
|
+
Math.max(
|
|
217
|
+
...Array.from({ length: count }, (_, i) => p[`${prefix}h${i}`] - Math.abs(x + 0.5 - p[`${prefix}x${i}`]) * p[`${prefix}s${i}`]),
|
|
218
|
+
) - (16 - base)
|
|
219
|
+
|
|
220
|
+
const scene = (x: number, y: number) => {
|
|
221
|
+
const height = base - y
|
|
222
|
+
const c = ridge("c", 2, x)
|
|
223
|
+
|
|
224
|
+
if (height <= c) return near
|
|
225
|
+
const b = ridge("b", 3, x)
|
|
226
|
+
|
|
227
|
+
if (height <= b) return b - height < 1 ? tint(middle, 0.12) : middle
|
|
228
|
+
const a = ridge("a", 3, x)
|
|
229
|
+
|
|
230
|
+
if (height <= a) return a - height < 1.6 + ((x * 7) % 3) * 0.4 && a > 7 ? snow : far
|
|
231
|
+
|
|
232
|
+
if (Math.hypot(x + 0.5 - p.sunX, y + 0.5 - p.sunY) < 2.1) return sun
|
|
233
|
+
|
|
234
|
+
return sky[dither(y / 10, 3, x, y)]
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
pixels.each((x, y) => {
|
|
238
|
+
if (y < base) return scene(x, y)
|
|
239
|
+
const mirrored = scene(x, base * 2 - y - 1)
|
|
240
|
+
|
|
241
|
+
return y % 2 && x % 4 === y % 4 ? tint(mirrored, 0.25) : shade(mix(mirrored, bottom, 0.25), 0.82)
|
|
242
|
+
})
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
id: "waves",
|
|
247
|
+
name: "Waves",
|
|
248
|
+
family: "Nature and materials",
|
|
249
|
+
label: "Stacked ocean swells with foam crests under a strip of sky; they roll on hover",
|
|
250
|
+
animated: true,
|
|
251
|
+
resolve: (random) => {
|
|
252
|
+
const r = random("waves")
|
|
253
|
+
|
|
254
|
+
return {
|
|
255
|
+
grid: 16,
|
|
256
|
+
...prefixed("w", pick(r, SEAS)),
|
|
257
|
+
horizon: int(r, 3, 6),
|
|
258
|
+
bands: int(r, 3, 4),
|
|
259
|
+
amplitude: range(r, 0.8, 2),
|
|
260
|
+
frequency: range(r, 0.45, 0.9),
|
|
261
|
+
phase: r() * 6.28,
|
|
262
|
+
sun: r() < 0.6 ? 1 : 0,
|
|
263
|
+
sunX: range(r, 3, 13),
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
paint: (pixels, p, t) => {
|
|
267
|
+
const [sky, deep, middle, light, foam, sun] = colors(p, "w", 6)
|
|
268
|
+
const tones = [light, middle, mix(middle, deep, 0.5), deep]
|
|
269
|
+
|
|
270
|
+
pixels.each((x, y) => {
|
|
271
|
+
const crests = Array.from({ length: p.bands }, (_, k) => {
|
|
272
|
+
const spacing = (16 - p.horizon) / p.bands
|
|
273
|
+
const swell = p.amplitude * (0.6 + k * 0.25)
|
|
274
|
+
const curve = p.horizon + k * spacing + swell * Math.sin(x * p.frequency + p.phase + k * 1.9 + t * (1.5 + k * 0.4))
|
|
275
|
+
|
|
276
|
+
return curve
|
|
277
|
+
})
|
|
278
|
+
const band = crests.findLastIndex((curve) => y + 0.5 >= curve)
|
|
279
|
+
|
|
280
|
+
if (band < 0) {
|
|
281
|
+
if (p.sun && Math.hypot(x + 0.5 - p.sunX, y + 0.5 - (p.horizon - 0.5)) < 2.4) return sun
|
|
282
|
+
|
|
283
|
+
return y === p.horizon - 1 ? mix(sky, light, 0.4) : sky
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (y + 0.5 - crests[band] < 1) return foam
|
|
287
|
+
|
|
288
|
+
if (y + 0.5 - crests[band] < 2 && (x + band) % 3 === 0) return mix(foam, tones[band], 0.5)
|
|
289
|
+
|
|
290
|
+
return tones[Math.min(3, band + (4 - p.bands))]
|
|
291
|
+
})
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
id: "aurora",
|
|
296
|
+
name: "Aurora",
|
|
297
|
+
family: "Nature and materials",
|
|
298
|
+
label: "Rayed aurora curtains over pines, snowy hills or a still lake; they ripple on hover",
|
|
299
|
+
animated: true,
|
|
300
|
+
resolve: (random) => {
|
|
301
|
+
const r = random("aurora")
|
|
302
|
+
const [low, high] = pick(r, AURORAS)
|
|
303
|
+
|
|
304
|
+
return {
|
|
305
|
+
grid: 16,
|
|
306
|
+
seed: seed(r),
|
|
307
|
+
night: pick(r, NIGHTS),
|
|
308
|
+
low,
|
|
309
|
+
high,
|
|
310
|
+
ribbons: r() < 0.4 ? 2 : 1,
|
|
311
|
+
base: range(r, 7, 10),
|
|
312
|
+
amplitude: range(r, 1, 3),
|
|
313
|
+
frequency: range(r, 0.25, 0.6),
|
|
314
|
+
phase: r() * 6.28,
|
|
315
|
+
length: range(r, 4, 7),
|
|
316
|
+
ground: int(r, 0, 2),
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
paint: (pixels, p, t) => {
|
|
320
|
+
pixels.fill(p.night)
|
|
321
|
+
stars(pixels, mulberry32(p.seed), p.night, 6)
|
|
322
|
+
const rand = mulberry32(p.seed + 1)
|
|
323
|
+
const pines = Array.from({ length: 5 }, () => ({ x: rand() * 16, h: 3 + rand() * 3 }))
|
|
324
|
+
|
|
325
|
+
const glow = (x: number, y: number) =>
|
|
326
|
+
Math.max(
|
|
327
|
+
...Array.from({ length: p.ribbons }, (_, k) => {
|
|
328
|
+
const edge =
|
|
329
|
+
p.base - k * 3 + p.amplitude * Math.sin(x * p.frequency + p.phase + k * 2.1 + t * 1.3)
|
|
330
|
+
const above = edge - (y + 0.5)
|
|
331
|
+
|
|
332
|
+
if (above < -0.5 || above > p.length) return 0
|
|
333
|
+
const rays = 0.65 + 0.35 * Math.sin(x * 2.3 + p.phase * 3 + k + t * 4)
|
|
334
|
+
|
|
335
|
+
return (1 - above / p.length) * rays
|
|
336
|
+
}),
|
|
337
|
+
)
|
|
338
|
+
|
|
339
|
+
pixels.each((x, y) => {
|
|
340
|
+
const ground = [
|
|
341
|
+
() => pines.some((pine) => 13 - y < pine.h - Math.abs(x + 0.5 - pine.x) * 1.6) || y >= 14,
|
|
342
|
+
() => y >= 13 - Math.sin(x * 0.5 + p.phase) * 1.2,
|
|
343
|
+
() => y >= 13,
|
|
344
|
+
][p.ground]()
|
|
345
|
+
|
|
346
|
+
if (ground && p.ground === 2) return mix(p.night, mix(p.low, p.high, 0.3), glow(x, 26 - y) * 0.35)
|
|
347
|
+
|
|
348
|
+
if (ground) return p.ground === 1 ? mix(0xdfe9f5, p.night, 0.55) : mix(p.night, 0x000000, 0.4)
|
|
349
|
+
const k = glow(x, y)
|
|
350
|
+
|
|
351
|
+
if (k <= 0) return undefined
|
|
352
|
+
const level = dither(k * 1.35, 4, x, y)
|
|
353
|
+
|
|
354
|
+
return level ? mix(p.night, mix(p.low, p.high, clamp01((p.base - y) / p.length)), level / 3) : undefined
|
|
355
|
+
})
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
id: "marble",
|
|
360
|
+
name: "Marble",
|
|
361
|
+
family: "Nature and materials",
|
|
362
|
+
label: "Domain-warped veins through Carrara, Nero, Verde, Rosso, Calacatta and other stones",
|
|
363
|
+
resolve: (random) => {
|
|
364
|
+
const r = random("marble")
|
|
365
|
+
|
|
366
|
+
return {
|
|
367
|
+
grid: 32,
|
|
368
|
+
...prefixed("m", pick(r, MARBLES)),
|
|
369
|
+
angle: r() * Math.PI,
|
|
370
|
+
frequency: range(r, 0.15, 0.32),
|
|
371
|
+
warp: range(r, 2.5, 5.5),
|
|
372
|
+
width: range(r, 0.06, 0.16),
|
|
373
|
+
seedX: r() * 40,
|
|
374
|
+
seedY: r() * 40,
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
paint: (pixels, p) => {
|
|
378
|
+
const [base, vein, cloud] = colors(p, "m", 3)
|
|
379
|
+
|
|
380
|
+
pixels.each((x, y) => {
|
|
381
|
+
const qx = fbm(x * 0.07 + p.seedX, y * 0.07 + p.seedY)
|
|
382
|
+
const qy = fbm(x * 0.07 + p.seedY + 3.1, y * 0.07 + p.seedX + 1.7)
|
|
383
|
+
const w = fbm(x * 0.06 + qx * 2.5 + p.seedX, y * 0.06 + qy * 2.5 + p.seedY)
|
|
384
|
+
const along = (x * Math.cos(p.angle) + y * Math.sin(p.angle)) * p.frequency
|
|
385
|
+
const main = Math.abs(Math.sin(along + w * p.warp))
|
|
386
|
+
const fine = Math.abs(Math.sin(along * 2.7 + w * p.warp * 1.8 + 1.3))
|
|
387
|
+
const stone = mix(base, cloud, smoothstep(0.35, 0.75, qx))
|
|
388
|
+
const veined = mix(stone, vein, 1 - smoothstep(0, p.width, main))
|
|
389
|
+
|
|
390
|
+
return mix(veined, vein, (1 - smoothstep(0, p.width * 0.35, fine)) * 0.45)
|
|
391
|
+
})
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
id: "wood",
|
|
396
|
+
name: "Wood grain",
|
|
397
|
+
family: "Nature and materials",
|
|
398
|
+
label: "End grain, flat-sawn cathedrals or quartersawn stripes in oak, walnut, cherry and more",
|
|
399
|
+
resolve: (random) => {
|
|
400
|
+
const r = random("wood")
|
|
401
|
+
|
|
402
|
+
return {
|
|
403
|
+
grid: 32,
|
|
404
|
+
...prefixed("w", pick(r, WOODS)),
|
|
405
|
+
cut: int(r, 0, 2),
|
|
406
|
+
cx: range(r, -8, 40),
|
|
407
|
+
cy: range(r, -8, 40),
|
|
408
|
+
density: range(r, 0.18, 0.4),
|
|
409
|
+
knot: r() < 0.4 ? 1 : 0,
|
|
410
|
+
kx: range(r, 8, 24),
|
|
411
|
+
ky: range(r, 8, 24),
|
|
412
|
+
seedX: r() * 40,
|
|
413
|
+
seedY: r() * 40,
|
|
414
|
+
}
|
|
415
|
+
},
|
|
416
|
+
paint: (pixels, p) => {
|
|
417
|
+
const [early, late] = colors(p, "w", 2)
|
|
418
|
+
|
|
419
|
+
pixels.each((x, y) => {
|
|
420
|
+
const n = fbm(x * 0.08 + p.seedX, y * 0.08 + p.seedY)
|
|
421
|
+
const knot = p.knot && p.cut === 1 ? 6 / (1 + Math.hypot(x - p.kx, (y - p.ky) * 0.6)) : 0
|
|
422
|
+
|
|
423
|
+
const distance = [
|
|
424
|
+
Math.hypot(x - p.cx, y - p.cy),
|
|
425
|
+
Math.hypot((x - 16) * 0.22, y - p.cy - 40) + knot * 3,
|
|
426
|
+
x + n * 4,
|
|
427
|
+
][p.cut]
|
|
428
|
+
|
|
429
|
+
const ring = (((distance * p.density + n * 0.9) % 1) + 1) % 1
|
|
430
|
+
const wood = mix(early, late, smoothstep(0.55, 0.95, ring))
|
|
431
|
+
const ray = p.cut === 2 && grain(Math.floor(x / 3), y, 3) > 0.93 ? 0.35 : 0
|
|
432
|
+
const check = p.cut === 0 && Math.abs(Math.sin(Math.atan2(y - p.cy, x - p.cx) * 3 + p.seedX)) < 0.03
|
|
433
|
+
|
|
434
|
+
return check ? shade(late, 0.6) : shade(mix(wood, tint(early, 0.3), ray), grain(x, y, 1) < 0.15 ? 0.92 : 1)
|
|
435
|
+
})
|
|
436
|
+
},
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
id: "lava",
|
|
440
|
+
name: "Lava lamp",
|
|
441
|
+
family: "Nature and materials",
|
|
442
|
+
label: "A tapered lamp of metaball wax in a dithered liquid, on a chrome, brass or black base; the wax rises on hover",
|
|
443
|
+
animated: true,
|
|
444
|
+
resolve: (random) => {
|
|
445
|
+
const r = random("lava")
|
|
446
|
+
const all = colors(palette(random("palette")))
|
|
447
|
+
|
|
448
|
+
return {
|
|
449
|
+
grid: 16,
|
|
450
|
+
seed: seed(r),
|
|
451
|
+
count: int(r, 3, 4),
|
|
452
|
+
...prefixed("l", pick(r, LAMPS)),
|
|
453
|
+
metal: pick(r, [0xb8bec6, 0xd4af37, 0x2e2e33, 0xc8743a]),
|
|
454
|
+
ground: r() < 0.65 ? pick(r, [0x14121f, 0x0f1418, 0x1c1414, 0x101a1a]) : all[0],
|
|
455
|
+
belly: range(r, 3.2, 4.2),
|
|
456
|
+
}
|
|
457
|
+
},
|
|
458
|
+
paint: (pixels, p, t) => {
|
|
459
|
+
const [top, bottom, wax] = colors(p, "l", 3)
|
|
460
|
+
const rand = mulberry32(p.seed)
|
|
461
|
+
const half = (y: number) => (y < 2 || y > 11 ? 0 : 1.2 + (p.belly - 1.2) * Math.sin((Math.PI * (y - 1.5)) / 11) ** 0.8)
|
|
462
|
+
const glass = (x: number, y: number) => Math.abs(x + 0.5 - 8) < half(y)
|
|
463
|
+
const dark = luma(p.ground) < 0.3
|
|
464
|
+
|
|
465
|
+
const blobs = Array.from({ length: p.count }, () => {
|
|
466
|
+
const speed = 0.6 + rand() * 1
|
|
467
|
+
const phase = rand() * 6.28
|
|
468
|
+
|
|
469
|
+
return { x: 7 + rand() * 2, y: 7 + Math.sin(phase + t * speed) * 3.5, r: 0.9 + rand() * 0.8 }
|
|
470
|
+
})
|
|
471
|
+
|
|
472
|
+
pixels.each((x, y) => {
|
|
473
|
+
if (glass(x, y)) {
|
|
474
|
+
const field = blobs.reduce((sum, blob) => sum + (blob.r * blob.r) / ((x + 0.5 - blob.x) ** 2 + (y + 0.5 - blob.y) ** 2 + 0.01), 0)
|
|
475
|
+
|
|
476
|
+
if (field > 1) return field > 3 ? tint(wax, 0.3) : wax
|
|
477
|
+
|
|
478
|
+
return [top, mix(top, bottom, 0.5), bottom][dither((y - 2) / 9, 3, x, y)]
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
if (y <= 1 && y >= 0 && Math.abs(x + 0.5 - 8) < 1.6 + y * 0.4) return y === 0 ? shade(p.metal, 0.8) : p.metal
|
|
482
|
+
|
|
483
|
+
if (y >= 12 && y <= 14 && Math.abs(x + 0.5 - 8) < 1.6 + (y - 12) * 0.9) return y === 12 ? tint(p.metal, 0.25) : y === 14 ? shade(p.metal, 0.7) : p.metal
|
|
484
|
+
|
|
485
|
+
const near = [-1, 1].some((d) => glass(x + d, y) || glass(x + d * 2, y))
|
|
486
|
+
|
|
487
|
+
return dark && near ? mix(p.ground, wax, 0.18) : p.ground
|
|
488
|
+
})
|
|
489
|
+
},
|
|
490
|
+
},
|
|
491
|
+
]
|
|
492
|
+
|
|
493
|
+
const CREATURES: Definition[] = [
|
|
494
|
+
{
|
|
495
|
+
id: "robot",
|
|
496
|
+
name: "Robot",
|
|
497
|
+
family: "Creatures",
|
|
498
|
+
label: "A boxy robot head with its own eyes, mouth and antenna; it blinks and beeps on hover",
|
|
499
|
+
animated: true,
|
|
500
|
+
resolve: (random) => {
|
|
501
|
+
const r = random("robot")
|
|
502
|
+
const all = colors(palette(random("palette")))
|
|
503
|
+
const body = r() < 0.6 ? pick(r, METALS) : pick(r, all.slice(1))
|
|
504
|
+
|
|
505
|
+
return {
|
|
506
|
+
grid: 16,
|
|
507
|
+
body,
|
|
508
|
+
ground: luma(body) > 0.5 ? mix(0x1a1c22, body, 0.12) : mix(all[0], body, 0.1),
|
|
509
|
+
glow: pick(r, GLOWS),
|
|
510
|
+
width: pick(r, [8, 10, 10, 12]),
|
|
511
|
+
height: int(r, 6, 8),
|
|
512
|
+
round: r() < 0.5 ? 1 : 0,
|
|
513
|
+
eyes: int(r, 0, 3),
|
|
514
|
+
mouth: int(r, 0, 3),
|
|
515
|
+
antenna: int(r, 0, 3),
|
|
516
|
+
ears: r() < 0.5 ? 1 : 0,
|
|
517
|
+
}
|
|
518
|
+
},
|
|
519
|
+
paint: (pixels, p, t) => {
|
|
520
|
+
const x0 = (16 - p.width) / 2
|
|
521
|
+
const y0 = 13 - p.height - 2
|
|
522
|
+
const dark = shade(p.body, 0.55)
|
|
523
|
+
const blink = t % 1.8 > 1.6
|
|
524
|
+
const beep = t > 0 && Math.floor(t * 3) % 2 === 0
|
|
525
|
+
pixels.fill(p.ground)
|
|
526
|
+
pixels.rect(5, y0 + p.height, 6, 1, dark)
|
|
527
|
+
pixels.rect(2, y0 + p.height + 1, 12, 4, shade(p.body, 0.8))
|
|
528
|
+
pixels.rect(2, y0 + p.height + 1, 12, 1, p.body)
|
|
529
|
+
pixels.rect(x0, y0, p.width, p.height, p.body)
|
|
530
|
+
pixels.rect(x0, y0 + p.height - 1, p.width, 1, shade(p.body, 0.8))
|
|
531
|
+
pixels.rect(x0, y0, p.width, 1, tint(p.body, 0.3))
|
|
532
|
+
|
|
533
|
+
if (p.round) {
|
|
534
|
+
;[
|
|
535
|
+
[x0, y0],
|
|
536
|
+
[x0 + p.width - 1, y0],
|
|
537
|
+
[x0, y0 + p.height - 1],
|
|
538
|
+
[x0 + p.width - 1, y0 + p.height - 1],
|
|
539
|
+
].forEach(([x, y]) => pixels.set(x, y, p.ground))
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
if (p.ears) {
|
|
543
|
+
pixels.rect(x0 - 1, y0 + 2, 1, 2, dark)
|
|
544
|
+
pixels.rect(x0 + p.width, y0 + 2, 1, 2, dark)
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
const eye = blink ? dark : p.glow
|
|
548
|
+
const eyeY = y0 + 2
|
|
549
|
+
const eyes = [
|
|
550
|
+
() => {
|
|
551
|
+
pixels.rect(x0 + 1, eyeY, 2, 2, eye)
|
|
552
|
+
pixels.rect(x0 + p.width - 3, eyeY, 2, 2, eye)
|
|
553
|
+
},
|
|
554
|
+
() => {
|
|
555
|
+
pixels.rect(x0 + 1, eyeY, p.width - 2, 2, shade(p.body, 0.3))
|
|
556
|
+
pixels.rect(x0 + 2 + (beep ? 1 : 0), eyeY, 2, 1, eye)
|
|
557
|
+
pixels.rect(x0 + p.width - 4 - (beep ? 1 : 0), eyeY, 2, 1, eye)
|
|
558
|
+
},
|
|
559
|
+
() => {
|
|
560
|
+
pixels.rect(7, eyeY - 1, 2, 3, eye)
|
|
561
|
+
pixels.rect(6, eyeY, 4, 1, eye)
|
|
562
|
+
},
|
|
563
|
+
() => {
|
|
564
|
+
pixels.set(x0 + 2, eyeY, eye)
|
|
565
|
+
pixels.set(x0 + p.width - 3, eyeY, eye)
|
|
566
|
+
pixels.set(x0 + 1, eyeY + 1, eye)
|
|
567
|
+
pixels.set(x0 + 3, eyeY + 1, eye)
|
|
568
|
+
pixels.set(x0 + p.width - 4, eyeY + 1, eye)
|
|
569
|
+
pixels.set(x0 + p.width - 2, eyeY + 1, eye)
|
|
570
|
+
},
|
|
571
|
+
]
|
|
572
|
+
|
|
573
|
+
eyes[p.eyes]()
|
|
574
|
+
const mouthY = y0 + p.height - 2
|
|
575
|
+
const mouths = [
|
|
576
|
+
() => Array.from({ length: p.width - 4 }, (_, i) => i % 2 === 0 && pixels.set(x0 + 2 + i, mouthY, dark)),
|
|
577
|
+
() => pixels.rect(x0 + 3, mouthY, p.width - 6, 1, dark),
|
|
578
|
+
() => {
|
|
579
|
+
pixels.rect(x0 + 2, mouthY, p.width - 4, 1, 0xf4f1ea)
|
|
580
|
+
Array.from({ length: p.width - 4 }, (_, i) => i % 2 && pixels.set(x0 + 2 + i, mouthY, dark))
|
|
581
|
+
},
|
|
582
|
+
() => pixels.rect(7, mouthY, 2, 1, beep ? p.glow : dark),
|
|
583
|
+
]
|
|
584
|
+
|
|
585
|
+
mouths[p.mouth]()
|
|
586
|
+
const tip = beep ? tint(p.glow, 0.5) : p.glow
|
|
587
|
+
const antennas = [
|
|
588
|
+
() => pixels.rect(x0 + 1, y0 - 1, p.width - 2, 1, dark),
|
|
589
|
+
() => {
|
|
590
|
+
pixels.rect(7, y0 - 2, 1, 2, dark)
|
|
591
|
+
pixels.rect(7, y0 - 3, 2, 1, tip)
|
|
592
|
+
},
|
|
593
|
+
() => {
|
|
594
|
+
pixels.rect(x0 + 1, y0 - 2, 1, 2, dark)
|
|
595
|
+
pixels.rect(x0 + p.width - 2, y0 - 2, 1, 2, dark)
|
|
596
|
+
pixels.set(x0 + 1, y0 - 3, tip)
|
|
597
|
+
pixels.set(x0 + p.width - 2, y0 - 3, tip)
|
|
598
|
+
},
|
|
599
|
+
() => {
|
|
600
|
+
pixels.set(8, y0 - 1, dark)
|
|
601
|
+
pixels.set(7, y0 - 2, dark)
|
|
602
|
+
pixels.set(8, y0 - 3, tip)
|
|
603
|
+
},
|
|
604
|
+
]
|
|
605
|
+
|
|
606
|
+
antennas[p.antenna]()
|
|
607
|
+
},
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
id: "slime",
|
|
611
|
+
name: "Slime",
|
|
612
|
+
family: "Creatures",
|
|
613
|
+
label: "A glossy dome of slime with a face and a sprout, crown or bubble; it squashes on hover",
|
|
614
|
+
animated: true,
|
|
615
|
+
resolve: (random) => {
|
|
616
|
+
const r = random("slime")
|
|
617
|
+
|
|
618
|
+
return {
|
|
619
|
+
grid: 16,
|
|
620
|
+
body: pick(r, SLIMES),
|
|
621
|
+
ground: pick(r, PASTELS),
|
|
622
|
+
width: range(r, 10, 14),
|
|
623
|
+
height: range(r, 7, 10),
|
|
624
|
+
eyes: int(r, 0, 2),
|
|
625
|
+
mouth: int(r, 0, 2),
|
|
626
|
+
hat: int(r, 0, 3),
|
|
627
|
+
drip: int(r, 3, 12),
|
|
628
|
+
}
|
|
629
|
+
},
|
|
630
|
+
paint: (pixels, p, t) => {
|
|
631
|
+
const squash = Math.sin(t * 6) * 0.12 * Math.min(1, t * 3)
|
|
632
|
+
const w = p.width * (1 + squash) * 0.5
|
|
633
|
+
const h = p.height * (1 - squash)
|
|
634
|
+
const base = 13
|
|
635
|
+
const top = Math.round(base - h)
|
|
636
|
+
const inside = (x: number, y: number) => y < base && ((x + 0.5 - 8) / w) ** 2 + ((y + 0.5 - base) / h) ** 2 < 1
|
|
637
|
+
const outline = shade(p.body, 0.6)
|
|
638
|
+
pixels.fill(p.ground)
|
|
639
|
+
pixels.rect(Math.round(8 - w), base, Math.round(w * 2), 1, mix(p.ground, 0x000000, 0.18))
|
|
640
|
+
pixels.each((x, y) => {
|
|
641
|
+
if (inside(x, y)) return inside(x - 1, y) && inside(x + 1, y) && inside(x, y - 1) ? p.body : outline
|
|
642
|
+
|
|
643
|
+
return undefined
|
|
644
|
+
})
|
|
645
|
+
pixels.set(p.drip, base, outline)
|
|
646
|
+
pixels.set(Math.round(8 - w * 0.55), top + 2, tint(p.body, 0.75))
|
|
647
|
+
pixels.set(Math.round(8 - w * 0.55) + 1, top + 1, tint(p.body, 0.6))
|
|
648
|
+
const eyeY = Math.round(base - h * 0.45)
|
|
649
|
+
const ink = 0x1a1a24
|
|
650
|
+
const faces = [
|
|
651
|
+
() => {
|
|
652
|
+
pixels.rect(5, eyeY, 1, 2, ink)
|
|
653
|
+
pixels.rect(10, eyeY, 1, 2, ink)
|
|
654
|
+
},
|
|
655
|
+
() => {
|
|
656
|
+
pixels.rect(4, eyeY, 2, 2, ink)
|
|
657
|
+
pixels.rect(10, eyeY, 2, 2, ink)
|
|
658
|
+
pixels.set(4, eyeY, 0xffffff)
|
|
659
|
+
pixels.set(10, eyeY, 0xffffff)
|
|
660
|
+
},
|
|
661
|
+
() => {
|
|
662
|
+
;[4, 10].forEach((x) => {
|
|
663
|
+
pixels.set(x, eyeY + 1, ink)
|
|
664
|
+
pixels.set(x + 1, eyeY, ink)
|
|
665
|
+
pixels.set(x + 2, eyeY + 1, ink)
|
|
666
|
+
})
|
|
667
|
+
},
|
|
668
|
+
]
|
|
669
|
+
|
|
670
|
+
faces[p.eyes]()
|
|
671
|
+
const mouths = [
|
|
672
|
+
() => {
|
|
673
|
+
pixels.set(7, eyeY + 2, ink)
|
|
674
|
+
pixels.set(8, eyeY + 2, ink)
|
|
675
|
+
},
|
|
676
|
+
() => {
|
|
677
|
+
pixels.set(6, eyeY + 2, ink)
|
|
678
|
+
pixels.set(7, eyeY + 3, ink)
|
|
679
|
+
pixels.set(8, eyeY + 2, ink)
|
|
680
|
+
pixels.set(9, eyeY + 3, ink)
|
|
681
|
+
},
|
|
682
|
+
() => {
|
|
683
|
+
pixels.set(3, eyeY + 2, 0xff8fab)
|
|
684
|
+
pixels.set(12, eyeY + 2, 0xff8fab)
|
|
685
|
+
},
|
|
686
|
+
]
|
|
687
|
+
|
|
688
|
+
mouths[p.mouth]()
|
|
689
|
+
const hats = [
|
|
690
|
+
() => undefined,
|
|
691
|
+
() => {
|
|
692
|
+
pixels.set(8, top - 1, 0x4c956c)
|
|
693
|
+
pixels.set(9, top - 2, 0x6fcf6f)
|
|
694
|
+
pixels.set(7, top - 2, 0x6fcf6f)
|
|
695
|
+
},
|
|
696
|
+
() => {
|
|
697
|
+
pixels.rect(6, top - 1, 4, 1, 0xf2c230)
|
|
698
|
+
pixels.set(6, top - 2, 0xf2c230)
|
|
699
|
+
pixels.set(8, top - 2, 0xf2c230)
|
|
700
|
+
pixels.set(9, top - 2, 0xf2c230)
|
|
701
|
+
},
|
|
702
|
+
() => {
|
|
703
|
+
pixels.set(11, base - 3, tint(p.body, 0.5))
|
|
704
|
+
pixels.set(10, base - 2, tint(p.body, 0.3))
|
|
705
|
+
},
|
|
706
|
+
]
|
|
707
|
+
|
|
708
|
+
hats[p.hat]()
|
|
709
|
+
},
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
id: "ghost",
|
|
713
|
+
name: "Ghost",
|
|
714
|
+
family: "Creatures",
|
|
715
|
+
label: "A sheet ghost with a wavy hem and a mood of its own; it floats on hover",
|
|
716
|
+
animated: true,
|
|
717
|
+
resolve: (random) => {
|
|
718
|
+
const r = random("ghost")
|
|
719
|
+
|
|
720
|
+
return {
|
|
721
|
+
grid: 16,
|
|
722
|
+
sheet: pick(r, SHEETS),
|
|
723
|
+
ground: pick(r, HAUNTS),
|
|
724
|
+
width: pick(r, [5, 5.5, 6]),
|
|
725
|
+
period: pick(r, [3, 4]),
|
|
726
|
+
eyes: int(r, 0, 3),
|
|
727
|
+
mouth: int(r, 0, 2),
|
|
728
|
+
arms: r() < 0.5 ? 1 : 0,
|
|
729
|
+
lean: range(r, -0.15, 0.15),
|
|
730
|
+
blush: r() < 0.4 ? 1 : 0,
|
|
731
|
+
}
|
|
732
|
+
},
|
|
733
|
+
paint: (pixels, p, t) => {
|
|
734
|
+
const bob = Math.round(Math.sin(t * 3) * 1)
|
|
735
|
+
const cy = 6.5 + bob
|
|
736
|
+
const hem = 13 + bob
|
|
737
|
+
const shadowed = shade(p.sheet, 0.78)
|
|
738
|
+
|
|
739
|
+
const inside = (x: number, y: number) => {
|
|
740
|
+
const X = x + 0.5 - 8 - (y - 8) * p.lean
|
|
741
|
+
const Y = y + 0.5
|
|
742
|
+
const wave = Math.abs((((x + Math.floor(t * 6)) % p.period) + p.period) % p.period - p.period / 2) * 0.8
|
|
743
|
+
|
|
744
|
+
if (Y < cy) return Math.hypot(X, Y - cy) < p.width
|
|
745
|
+
|
|
746
|
+
return Math.abs(X) < p.width && Y < hem + 1 - wave
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
pixels.fill(p.ground)
|
|
750
|
+
pixels.each((x, y) => {
|
|
751
|
+
if (y === 14 && Math.abs(x + 0.5 - 8) < p.width - 1) return mix(p.ground, 0x000000, 0.3)
|
|
752
|
+
|
|
753
|
+
if (!inside(x, y)) return undefined
|
|
754
|
+
|
|
755
|
+
return inside(x + 1, y) ? p.sheet : shadowed
|
|
756
|
+
})
|
|
757
|
+
|
|
758
|
+
if (p.arms) {
|
|
759
|
+
pixels.set(Math.round(8 - p.width) - 1, 9 + bob, p.sheet)
|
|
760
|
+
pixels.set(Math.round(8 + p.width), 9 + bob, shadowed)
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
const ink = 0x1a1626
|
|
764
|
+
const ey = 5 + bob
|
|
765
|
+
const eyes = [
|
|
766
|
+
() => {
|
|
767
|
+
pixels.rect(5, ey, 2, 3, ink)
|
|
768
|
+
pixels.rect(9, ey, 2, 3, ink)
|
|
769
|
+
},
|
|
770
|
+
() => {
|
|
771
|
+
pixels.set(6, ey + 1, ink)
|
|
772
|
+
pixels.set(9, ey + 1, ink)
|
|
773
|
+
},
|
|
774
|
+
() => {
|
|
775
|
+
;[5, 9].forEach((x) => {
|
|
776
|
+
pixels.set(x, ey + 1, ink)
|
|
777
|
+
pixels.set(x + 1, ey, ink)
|
|
778
|
+
pixels.set(x + 2, ey + 1, ink)
|
|
779
|
+
})
|
|
780
|
+
},
|
|
781
|
+
() => {
|
|
782
|
+
pixels.rect(5, ey, 2, 2, p.ground)
|
|
783
|
+
pixels.rect(9, ey, 2, 2, p.ground)
|
|
784
|
+
},
|
|
785
|
+
]
|
|
786
|
+
|
|
787
|
+
eyes[p.eyes]()
|
|
788
|
+
const mouths = [
|
|
789
|
+
() => undefined,
|
|
790
|
+
() => pixels.rect(7, ey + 4, 2, 2, ink),
|
|
791
|
+
() => {
|
|
792
|
+
pixels.set(6, ey + 4, ink)
|
|
793
|
+
pixels.set(7, ey + 5, ink)
|
|
794
|
+
pixels.set(8, ey + 4, ink)
|
|
795
|
+
pixels.set(9, ey + 5, ink)
|
|
796
|
+
},
|
|
797
|
+
]
|
|
798
|
+
|
|
799
|
+
mouths[p.mouth]()
|
|
800
|
+
|
|
801
|
+
if (p.blush) {
|
|
802
|
+
pixels.set(4, ey + 3, 0xff9eb5)
|
|
803
|
+
pixels.set(11, ey + 3, 0xff9eb5)
|
|
804
|
+
}
|
|
805
|
+
},
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
id: "cat",
|
|
809
|
+
name: "Cat",
|
|
810
|
+
family: "Creatures",
|
|
811
|
+
label: "A cat's face in solid, tabby, tuxedo, calico or point coats, with slit eyes; it blinks on hover",
|
|
812
|
+
animated: true,
|
|
813
|
+
resolve: (random) => {
|
|
814
|
+
const r = random("cat")
|
|
815
|
+
const all = colors(palette(random("palette")))
|
|
816
|
+
const fur = pick(r, FURS)
|
|
817
|
+
|
|
818
|
+
return {
|
|
819
|
+
grid: 16,
|
|
820
|
+
fur,
|
|
821
|
+
ground: legible(r, all, fur),
|
|
822
|
+
coat: int(r, 0, 4),
|
|
823
|
+
iris: pick(r, IRISES),
|
|
824
|
+
ears: int(r, 3, 4),
|
|
825
|
+
width: pick(r, [6, 6.5, 7]),
|
|
826
|
+
}
|
|
827
|
+
},
|
|
828
|
+
paint: (pixels, p, t) => {
|
|
829
|
+
const dark = luma(p.fur) < 0.25 ? tint(p.fur, 0.25) : shade(p.fur, 0.62)
|
|
830
|
+
const white = 0xf6f3ec
|
|
831
|
+
const blink = t % 2.4 > 2.2
|
|
832
|
+
const inHead = (x: number, y: number) => ((x + 0.5 - 8) / p.width) ** 2 + ((y + 0.5 - 10) / 5) ** 2 < 1
|
|
833
|
+
|
|
834
|
+
const inEar = (x: number, y: number) =>
|
|
835
|
+
[3.5, 12.5].some((ex) => y >= 6 - p.ears && y <= 6 && Math.abs(x + 0.5 - ex) <= ((y - (6 - p.ears)) / p.ears) * 2.2)
|
|
836
|
+
|
|
837
|
+
const coat = (x: number, y: number) => {
|
|
838
|
+
const coats = [
|
|
839
|
+
() => p.fur,
|
|
840
|
+
() => ((y === 6 || y === 8) && x >= 6 && x <= 9 && x % 2 === 0) || ((x <= 3 || x >= 12) && y % 2 === 1) ? dark : p.fur,
|
|
841
|
+
() => (y >= 11 && x >= 5 && x <= 10) || (y >= 9 && x >= 7 && x <= 8) ? white : p.fur,
|
|
842
|
+
() => (x < 7 && y < 9 ? 0xe8964a : x > 9 && y > 9 ? 0x2b2b30 : white),
|
|
843
|
+
() => (Math.hypot(x + 0.5 - 8, y + 0.5 - 11) < 3 ? shade(0x5a4030, 1) : 0xf0e2c4),
|
|
844
|
+
]
|
|
845
|
+
|
|
846
|
+
return coats[p.coat]()
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
pixels.fill(p.ground)
|
|
850
|
+
pixels.each((x, y) => {
|
|
851
|
+
if (inEar(x, y)) {
|
|
852
|
+
const pink = Math.abs(x + 0.5 - (x < 8 ? 3.5 : 12.5)) < 0.8 && y > 6 - p.ears + 1
|
|
853
|
+
|
|
854
|
+
return pink ? 0xf2a7b8 : p.coat === 4 ? 0x5a4030 : coat(x, 7)
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
return inHead(x, y) ? coat(x, y) : undefined
|
|
858
|
+
})
|
|
859
|
+
|
|
860
|
+
const eyeY = 9
|
|
861
|
+
;[5, 9].forEach((x) => {
|
|
862
|
+
if (blink) return pixels.rect(x, eyeY + 1, 2, 1, shade(p.fur, 0.4))
|
|
863
|
+
pixels.rect(x, eyeY, 2, 2, p.iris)
|
|
864
|
+
pixels.rect(x + (x < 8 ? 1 : 0), eyeY, 1, 2, 0x161616)
|
|
865
|
+
})
|
|
866
|
+
pixels.rect(7, 12, 2, 1, 0xf28fa3)
|
|
867
|
+
pixels.set(7, 13, shade(coat(7, 13), 0.6))
|
|
868
|
+
pixels.set(8, 13, shade(coat(8, 13), 0.6))
|
|
869
|
+
const whisker = luma(p.ground) > 0.5 ? shade(p.ground, 0.55) : tint(p.ground, 0.55)
|
|
870
|
+
;[0, 1, 14, 15].forEach((x) => {
|
|
871
|
+
if (!inHead(x, 12)) pixels.set(x, 12, whisker)
|
|
872
|
+
|
|
873
|
+
if (!inHead(x, 13) && (x === 1 || x === 14)) pixels.set(x, 13, whisker)
|
|
874
|
+
})
|
|
875
|
+
},
|
|
876
|
+
},
|
|
877
|
+
]
|
|
878
|
+
|
|
879
|
+
const OBJECTS: Definition[] = [
|
|
880
|
+
{
|
|
881
|
+
id: "potion",
|
|
882
|
+
name: "Potion",
|
|
883
|
+
family: "Objects",
|
|
884
|
+
label: "A round, conical, vial or square flask of glowing liquid with a cork; it bubbles on hover",
|
|
885
|
+
animated: true,
|
|
886
|
+
resolve: (random) => {
|
|
887
|
+
const r = random("potion")
|
|
888
|
+
const all = colors(palette(random("palette")))
|
|
889
|
+
|
|
890
|
+
return {
|
|
891
|
+
grid: 16,
|
|
892
|
+
flask: int(r, 0, 3),
|
|
893
|
+
liquid: pick(r, POTIONS),
|
|
894
|
+
level: range(r, 0.35, 0.8),
|
|
895
|
+
ground: r() < 0.6 ? pick(r, [0x1a1626, 0x14231f, 0x231a14, 0x161c2a]) : all[0],
|
|
896
|
+
seed: seed(r),
|
|
897
|
+
}
|
|
898
|
+
},
|
|
899
|
+
paint: (pixels, p, t) => {
|
|
900
|
+
const flasks = [
|
|
901
|
+
(x: number, y: number) => Math.hypot(x + 0.5 - 8, y + 0.5 - 10) < 4.6 || (y >= 2 && y <= 6 && x >= 7 && x <= 8),
|
|
902
|
+
(x: number, y: number) => (y >= 2 && y <= 6 && x >= 7 && x <= 8) || (y > 6 && y <= 13 && Math.abs(x + 0.5 - 8) < 1 + (y - 6) * 0.75),
|
|
903
|
+
(x: number, y: number) => y >= 2 && y <= 13 && x >= 6 && x <= 9 && !(y === 13 && (x === 6 || x === 9)),
|
|
904
|
+
(x: number, y: number) =>
|
|
905
|
+
(y >= 2 && y <= 4 && x >= 7 && x <= 8) || (y === 5 && x >= 5 && x <= 10) || (y >= 6 && y <= 13 && x >= 4 && x <= 11),
|
|
906
|
+
]
|
|
907
|
+
|
|
908
|
+
const inside = flasks[p.flask]
|
|
909
|
+
const rows = Array.from({ length: 16 }, (_, y) => y).filter((y) => Array.from({ length: 16 }, (_, x) => x).some((x) => inside(x, y)))
|
|
910
|
+
const top = rows[0]
|
|
911
|
+
const bottom = rows[rows.length - 1]
|
|
912
|
+
const surface = Math.round(bottom - (bottom - top - 2) * p.level)
|
|
913
|
+
const dark = luma(p.ground) < 0.3
|
|
914
|
+
const glass = dark ? mix(p.ground, 0xffffff, 0.16) : mix(p.ground, 0x6a7a8a, 0.18)
|
|
915
|
+
const rim = dark ? mix(p.ground, 0xffffff, 0.5) : shade(p.ground, 0.45)
|
|
916
|
+
|
|
917
|
+
pixels.each((x, y) => {
|
|
918
|
+
if (inside(x, y)) {
|
|
919
|
+
if (y <= top) return 0x9c6b3e
|
|
920
|
+
|
|
921
|
+
if (y < surface) return x === 6 || x === 7 ? mix(glass, 0xffffff, 0.2) : glass
|
|
922
|
+
|
|
923
|
+
return y === surface ? tint(p.liquid, 0.35) : x <= 6 && y === surface + 1 ? tint(p.liquid, 0.2) : p.liquid
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
const edge = inside(x - 1, y) || inside(x + 1, y) || inside(x, y + 1)
|
|
927
|
+
|
|
928
|
+
if (edge) return rim
|
|
929
|
+
|
|
930
|
+
const near = [-2, -1, 1, 2].some((d) => inside(x + d, y) || inside(x, y + d))
|
|
931
|
+
|
|
932
|
+
return dark && near && dither(0.4, 2, x, y) ? mix(p.ground, p.liquid, 0.22) : p.ground
|
|
933
|
+
})
|
|
934
|
+
|
|
935
|
+
const rand = mulberry32(p.seed)
|
|
936
|
+
Array.from({ length: 3 }, () => {
|
|
937
|
+
const x = 6 + Math.floor(rand() * 4)
|
|
938
|
+
const span = bottom - surface - 1
|
|
939
|
+
const y = bottom - 1 - Math.floor(((rand() * span + t * 6) % Math.max(1, span)))
|
|
940
|
+
|
|
941
|
+
if (inside(x, y) && y > surface) pixels.set(x, y, tint(p.liquid, 0.6))
|
|
942
|
+
})
|
|
943
|
+
},
|
|
944
|
+
},
|
|
945
|
+
{
|
|
946
|
+
id: "gem",
|
|
947
|
+
name: "Gem",
|
|
948
|
+
family: "Objects",
|
|
949
|
+
label: "A faceted brilliant, emerald, cushion, trillion or marquise cut, lit from the top left",
|
|
950
|
+
animated: true,
|
|
951
|
+
resolve: (random) => {
|
|
952
|
+
const r = random("gem")
|
|
953
|
+
|
|
954
|
+
return {
|
|
955
|
+
grid: 16,
|
|
956
|
+
cut: int(r, 0, 4),
|
|
957
|
+
stone: pick(r, GEMS),
|
|
958
|
+
ground: pick(r, VELVETS),
|
|
959
|
+
facets: pick(r, [6, 8, 8, 10]),
|
|
960
|
+
turn: r() * Math.PI,
|
|
961
|
+
}
|
|
962
|
+
},
|
|
963
|
+
paint: (pixels, p, t) => {
|
|
964
|
+
const cuts = [
|
|
965
|
+
(dx: number, dy: number) => Math.max(Math.abs(dx), Math.abs(dy), (Math.abs(dx) + Math.abs(dy)) / 1.35) < 6,
|
|
966
|
+
(dx: number, dy: number) => Math.abs(dx) < 6.2 && Math.abs(dy) < 4.6 && Math.abs(dx) + Math.abs(dy) < 9,
|
|
967
|
+
(dx: number, dy: number) => (dx / 6) ** 4 + (dy / 6) ** 4 < 1,
|
|
968
|
+
(dx: number, dy: number) => dy > -4.5 && dy < 6 - Math.abs(dx) * 1.7 - 0.5 && Math.abs(dx) < 6.5,
|
|
969
|
+
(dx: number, dy: number) => Math.hypot(dx - 4.5, dy) < 7.8 && Math.hypot(dx + 4.5, dy) < 7.8 && Math.abs(dy) < 6.4,
|
|
970
|
+
]
|
|
971
|
+
|
|
972
|
+
const cut = cuts[p.cut]
|
|
973
|
+
const flip = p.cut === 3 ? -1 : 1
|
|
974
|
+
const [lx, ly] = [-0.6, -0.8]
|
|
975
|
+
const dark = luma(p.ground) < 0.4
|
|
976
|
+
|
|
977
|
+
pixels.each((x, y) => {
|
|
978
|
+
const dx = x + 0.5 - 8
|
|
979
|
+
const dy = (y + 0.5 - 8) * flip
|
|
980
|
+
const rotated = p.cut === 4 ? [dx * Math.cos(p.turn * 0.3) - dy * Math.sin(p.turn * 0.3), dx * Math.sin(p.turn * 0.3) + dy * Math.cos(p.turn * 0.3)] : [dx, dy]
|
|
981
|
+
|
|
982
|
+
if (!cut(rotated[0], rotated[1])) {
|
|
983
|
+
const halo = dark && cut(rotated[0] * 0.8, rotated[1] * 0.8)
|
|
984
|
+
|
|
985
|
+
return halo ? mix(p.ground, p.stone, 0.15) : p.ground
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
if (!cut(rotated[0] * 1.2, rotated[1] * 1.2)) return shade(p.stone, 0.45)
|
|
989
|
+
|
|
990
|
+
if (cut(rotated[0] * 2.1, rotated[1] * 2.1)) return dx + dy < -1 ? tint(p.stone, 0.45) : tint(p.stone, 0.22)
|
|
991
|
+
const sector = Math.floor(((Math.atan2(dy, dx) + Math.PI) / (Math.PI * 2)) * p.facets)
|
|
992
|
+
const middle = ((sector + 0.5) / p.facets) * Math.PI * 2 - Math.PI
|
|
993
|
+
const lit = Math.cos(middle) * lx + Math.sin(middle) * ly
|
|
994
|
+
|
|
995
|
+
return lit > 0.35 ? tint(p.stone, 0.3) : lit > -0.3 ? p.stone : shade(p.stone, 0.68)
|
|
996
|
+
})
|
|
997
|
+
|
|
998
|
+
const glint = Math.floor(t * 2.5) % 3
|
|
999
|
+
const spots = [
|
|
1000
|
+
[5, 5],
|
|
1001
|
+
[10, 6],
|
|
1002
|
+
[6, 10],
|
|
1003
|
+
]
|
|
1004
|
+
const [sx, sy] = spots[t > 0 ? glint : 0]
|
|
1005
|
+
pixels.set(sx, sy, 0xffffff)
|
|
1006
|
+
pixels.set(sx - 1, sy, tint(p.stone, 0.7))
|
|
1007
|
+
pixels.set(sx + 1, sy, tint(p.stone, 0.7))
|
|
1008
|
+
pixels.set(sx, sy - 1, tint(p.stone, 0.7))
|
|
1009
|
+
pixels.set(sx, sy + 1, tint(p.stone, 0.7))
|
|
1010
|
+
},
|
|
1011
|
+
},
|
|
1012
|
+
{
|
|
1013
|
+
id: "house",
|
|
1014
|
+
name: "Tiny house",
|
|
1015
|
+
family: "Objects",
|
|
1016
|
+
label: "A little house with a gable, A-frame, flat, mansard or dome roof; its chimney smokes on hover",
|
|
1017
|
+
animated: true,
|
|
1018
|
+
resolve: (random) => {
|
|
1019
|
+
const r = random("house")
|
|
1020
|
+
const wall = pick(r, WALLS)
|
|
1021
|
+
|
|
1022
|
+
return {
|
|
1023
|
+
grid: 16,
|
|
1024
|
+
...prefixed("d", pick(r, DAYS)),
|
|
1025
|
+
wall,
|
|
1026
|
+
roofColor: pick(
|
|
1027
|
+
r,
|
|
1028
|
+
ROOFS.filter((roof) => Math.abs(luma(roof) - luma(wall)) > 0.15),
|
|
1029
|
+
),
|
|
1030
|
+
width: pick(r, [8, 9, 10, 11]),
|
|
1031
|
+
height: int(r, 4, 5),
|
|
1032
|
+
x: int(r, 2, 4),
|
|
1033
|
+
roof: int(r, 0, 4),
|
|
1034
|
+
door: r(),
|
|
1035
|
+
chimney: r() < 0.6 ? 1 : 0,
|
|
1036
|
+
tree: r() < 0.5 ? 1 : 0,
|
|
1037
|
+
moonX: int(r, 2, 13),
|
|
1038
|
+
}
|
|
1039
|
+
},
|
|
1040
|
+
paint: (pixels, p, t) => {
|
|
1041
|
+
const [top, bottom, ground, light] = colors(p, "d", 4)
|
|
1042
|
+
const night = luma(top) < 0.2
|
|
1043
|
+
const sky = [top, mix(top, bottom, 0.5), bottom]
|
|
1044
|
+
const base = 13
|
|
1045
|
+
const x0 = Math.min(p.x, 15 - p.width)
|
|
1046
|
+
const x1 = x0 + p.width - 1
|
|
1047
|
+
const y0 = base - p.height
|
|
1048
|
+
const center = (x0 + x1) / 2
|
|
1049
|
+
const roofShade = shade(p.roofColor, 0.75)
|
|
1050
|
+
|
|
1051
|
+
pixels.each((x, y) => (y >= base ? (y === base ? tint(ground, 0.12) : ground) : sky[dither(y / 12, 3, x, y)]))
|
|
1052
|
+
pixels.disc(p.moonX + 0.5, 2.5, 1.5, light)
|
|
1053
|
+
|
|
1054
|
+
if (p.tree) {
|
|
1055
|
+
const tx = x1 + 2 < 15 ? x1 + 2 : x0 - 2
|
|
1056
|
+
pixels.rect(tx, base - 2, 1, 2, 0x6b4423)
|
|
1057
|
+
pixels.disc(tx + 0.5, base - 3.5, 1.8, night ? 0x1f3b2c : 0x3f7d3a)
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
const roofs = [
|
|
1061
|
+
() => {
|
|
1062
|
+
const peak = Math.ceil(p.width / 2)
|
|
1063
|
+
Array.from({ length: peak }, (_, k) => pixels.rect(x0 - 1 + k, y0 - 1 - k, p.width + 2 - k * 2, 1, k % 2 ? roofShade : p.roofColor))
|
|
1064
|
+
|
|
1065
|
+
return y0 - peak
|
|
1066
|
+
},
|
|
1067
|
+
() => {
|
|
1068
|
+
pixels.each((x, y) => (y < base && y >= base - p.height - 5 && Math.abs(x + 0.5 - (center + 0.5)) < (y - (base - p.height - 6)) * 0.62 ? p.roofColor : undefined))
|
|
1069
|
+
|
|
1070
|
+
return base - p.height - 5
|
|
1071
|
+
},
|
|
1072
|
+
() => {
|
|
1073
|
+
pixels.rect(x0 - 1, y0 - 1, p.width + 2, 1, p.roofColor)
|
|
1074
|
+
pixels.rect(x0, y0 - 2, 1, 1, p.roofColor)
|
|
1075
|
+
pixels.rect(x1, y0 - 2, 1, 1, p.roofColor)
|
|
1076
|
+
|
|
1077
|
+
return y0 - 2
|
|
1078
|
+
},
|
|
1079
|
+
() => {
|
|
1080
|
+
pixels.rect(x0 - 1, y0 - 1, p.width + 2, 1, roofShade)
|
|
1081
|
+
pixels.rect(x0, y0 - 2, p.width, 1, p.roofColor)
|
|
1082
|
+
pixels.rect(x0 + 1, y0 - 3, p.width - 2, 1, p.roofColor)
|
|
1083
|
+
|
|
1084
|
+
return y0 - 3
|
|
1085
|
+
},
|
|
1086
|
+
() => {
|
|
1087
|
+
pixels.disc(center + 0.5, y0, p.width / 2, p.roofColor)
|
|
1088
|
+
|
|
1089
|
+
return y0 - Math.floor(p.width / 2)
|
|
1090
|
+
},
|
|
1091
|
+
]
|
|
1092
|
+
|
|
1093
|
+
if (p.roof !== 1) pixels.rect(x0, y0, p.width, p.height, p.wall)
|
|
1094
|
+
const roofTop = roofs[p.roof]()
|
|
1095
|
+
|
|
1096
|
+
if (p.roof === 1) pixels.rect(Math.round(center) - 1, base - 3, 3, 3, p.wall)
|
|
1097
|
+
|
|
1098
|
+
const window = night ? light : mix(top, 0xffffff, 0.5)
|
|
1099
|
+
const doorX = p.roof === 1 ? Math.round(center) : x0 + 1 + Math.floor(p.door * (p.width - 3))
|
|
1100
|
+
pixels.rect(doorX, base - 3, p.roof === 1 ? 1 : 2, 3, shade(p.roofColor, 0.6))
|
|
1101
|
+
|
|
1102
|
+
if (p.roof !== 1) {
|
|
1103
|
+
;[x0 + 1, x1 - 2].forEach((wx) => {
|
|
1104
|
+
if (Math.abs(wx - doorX) < 3) return
|
|
1105
|
+
pixels.rect(wx, y0 + 1, 2, 2, window)
|
|
1106
|
+
})
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
if (!p.chimney || p.roof === 1 || p.roof === 4) return
|
|
1110
|
+
const cx = x1 - 2
|
|
1111
|
+
pixels.rect(cx, roofTop, 1, Math.max(1, y0 - roofTop), shade(p.roofColor, 0.55))
|
|
1112
|
+
const puff = Math.floor(t * 3)
|
|
1113
|
+
;[0, 1, 2].forEach((k) => pixels.set(cx + ((k + puff) % 2), roofTop - 1 - k - (t > 0 ? puff % 2 : 0), mix(sky[0], 0xffffff, 0.6 - k * 0.15)))
|
|
1114
|
+
},
|
|
1115
|
+
},
|
|
1116
|
+
{
|
|
1117
|
+
id: "lighthouse",
|
|
1118
|
+
name: "Lighthouse",
|
|
1119
|
+
family: "Objects",
|
|
1120
|
+
label: "A banded or spiral tower on a rock in the sea, by day or with a beam at night; the beam turns on hover",
|
|
1121
|
+
animated: true,
|
|
1122
|
+
resolve: (random) => {
|
|
1123
|
+
const r = random("lighthouse")
|
|
1124
|
+
|
|
1125
|
+
return {
|
|
1126
|
+
grid: 16,
|
|
1127
|
+
...prefixed("s", pick(r, SEAS)),
|
|
1128
|
+
x: int(r, 5, 10),
|
|
1129
|
+
bands: int(r, 0, 3),
|
|
1130
|
+
tower: pick(r, [0xc8102e, 0x1a1a1a, 0x1f4fa0, 0x2a9d8f]),
|
|
1131
|
+
beam: r() < 0.5 ? 1 : -1,
|
|
1132
|
+
rock: pick(r, [0x5c5c66, 0x6b4a32, 0x3d3d48]),
|
|
1133
|
+
birds: r() < 0.4 ? 1 : 0,
|
|
1134
|
+
}
|
|
1135
|
+
},
|
|
1136
|
+
paint: (pixels, p, t) => {
|
|
1137
|
+
const [sky, deep, middle, light, foam, sun] = colors(p, "s", 6)
|
|
1138
|
+
const night = luma(sky) < 0.25
|
|
1139
|
+
const white = 0xf4f1ea
|
|
1140
|
+
const lamp = 3
|
|
1141
|
+
|
|
1142
|
+
pixels.each((x, y) => {
|
|
1143
|
+
if (y >= 12) return (x + y * 3) % 7 === 0 ? foam : y === 12 ? light : y > 13 ? deep : middle
|
|
1144
|
+
|
|
1145
|
+
return sky
|
|
1146
|
+
})
|
|
1147
|
+
|
|
1148
|
+
const sweep = Math.sin(t * 1.6) * 0.5
|
|
1149
|
+
const reach = p.beam + (t > 0 ? sweep : 0)
|
|
1150
|
+
|
|
1151
|
+
if (night || t > 0) {
|
|
1152
|
+
pixels.each((x, y) => {
|
|
1153
|
+
const dx = (x + 0.5 - (p.x + 0.5)) * Math.sign(reach)
|
|
1154
|
+
|
|
1155
|
+
if (dx < 1 || y >= 12) return undefined
|
|
1156
|
+
const spread = Math.abs(y + 0.5 - (lamp + 0.5)) / dx
|
|
1157
|
+
|
|
1158
|
+
return spread < 0.28 ? mix(pixels.get(x, y), sun, 0.55 * (1 - dx / 16) * Math.min(1, Math.abs(reach))) : undefined
|
|
1159
|
+
})
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
pixels.each((x, y) => (y >= 11 && y <= 13 && Math.abs(x + 0.5 - (p.x + 0.5)) < 4 - (y - 11) * -0.6 - (y === 11 ? 1.4 : 0) ? p.rock : undefined))
|
|
1163
|
+
|
|
1164
|
+
for (let y = 4; y <= 10; y++) {
|
|
1165
|
+
const half = 1 + (y >= 8 ? 1 : 0)
|
|
1166
|
+
|
|
1167
|
+
for (let x = p.x - half + 1; x <= p.x + half; x++) {
|
|
1168
|
+
const stripes = [y % 4 < 2, (x + y) % 4 < 2, y >= 8 || y === 4, Math.floor((y - 4) / 3) % 2 === 0]
|
|
1169
|
+
pixels.set(x, y, stripes[p.bands] ? p.tower : white)
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
pixels.rect(p.x - 1, 3, 3, 1, 0x2b2b2b)
|
|
1174
|
+
pixels.rect(p.x, 2, 2, 2, sun)
|
|
1175
|
+
pixels.rect(p.x, lamp, 1, 1, tint(sun, 0.5))
|
|
1176
|
+
pixels.rect(p.x - 1, 1, 4, 1, shade(p.tower, 0.7))
|
|
1177
|
+
|
|
1178
|
+
if (p.birds && !night) {
|
|
1179
|
+
;[
|
|
1180
|
+
[3, 3],
|
|
1181
|
+
[12, 2],
|
|
1182
|
+
].forEach(([bx, by]) => {
|
|
1183
|
+
pixels.set(bx, by, shade(sky, 0.4))
|
|
1184
|
+
pixels.set(bx + 2, by, shade(sky, 0.4))
|
|
1185
|
+
pixels.set(bx + 1, by + 1, shade(sky, 0.4))
|
|
1186
|
+
})
|
|
1187
|
+
}
|
|
1188
|
+
},
|
|
1189
|
+
},
|
|
1190
|
+
{
|
|
1191
|
+
id: "dice",
|
|
1192
|
+
name: "Dice",
|
|
1193
|
+
family: "Objects",
|
|
1194
|
+
label: "One big die or an overlapping pair in six finishes on felt, wood or leather; they roll on hover",
|
|
1195
|
+
animated: true,
|
|
1196
|
+
resolve: (random) => {
|
|
1197
|
+
const r = random("dice")
|
|
1198
|
+
const [body, pip] = pick(r, DICE)
|
|
1199
|
+
|
|
1200
|
+
return {
|
|
1201
|
+
grid: 16,
|
|
1202
|
+
layout: int(r, 0, 1),
|
|
1203
|
+
body,
|
|
1204
|
+
pip,
|
|
1205
|
+
felt: pick(r, FELTS),
|
|
1206
|
+
a: int(r, 1, 6),
|
|
1207
|
+
b: int(r, 1, 6),
|
|
1208
|
+
}
|
|
1209
|
+
},
|
|
1210
|
+
paint: (pixels, p, t) => {
|
|
1211
|
+
const roll = Math.floor(t * 6)
|
|
1212
|
+
const face = (n: number) => ((n - 1 + roll) % 6) + 1
|
|
1213
|
+
pixels.fill(p.felt)
|
|
1214
|
+
pixels.each((x, y) => (grain(x, y, 2) < 0.12 ? shade(p.felt, 0.88) : undefined))
|
|
1215
|
+
|
|
1216
|
+
const die = (x0: number, y0: number, size: number, value: number, pipSize: number) => {
|
|
1217
|
+
pixels.rect(x0 + 1, y0 + size, size, 1, shade(p.felt, 0.6))
|
|
1218
|
+
pixels.rect(x0 + size, y0 + 1, 1, size, shade(p.felt, 0.6))
|
|
1219
|
+
pixels.rect(x0, y0, size, size, p.body)
|
|
1220
|
+
pixels.rect(x0, y0 + size - 1, size, 1, shade(p.body, 0.8))
|
|
1221
|
+
pixels.rect(x0 + size - 1, y0, 1, size, shade(p.body, 0.8))
|
|
1222
|
+
pixels.set(x0, y0, p.felt)
|
|
1223
|
+
pixels.set(x0 + size - 1, y0, p.felt)
|
|
1224
|
+
pixels.set(x0, y0 + size - 1, p.felt)
|
|
1225
|
+
pixels.set(x0 + size - 1, y0 + size - 1, p.felt)
|
|
1226
|
+
const step = (size - pipSize) / 2
|
|
1227
|
+
PIPS[value - 1].forEach((spot) => {
|
|
1228
|
+
const color = value === 1 && p.pip === 0x1a1a1a ? 0xc8102e : p.pip
|
|
1229
|
+
pixels.rect(Math.round(x0 + (spot % 3) * step * 0.78 + step * 0.22), Math.round(y0 + Math.floor(spot / 3) * step * 0.78 + step * 0.22), pipSize, pipSize, color)
|
|
1230
|
+
})
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
const layouts = [
|
|
1234
|
+
() => die(2, 2, 12, face(p.a), 2),
|
|
1235
|
+
() => {
|
|
1236
|
+
die(1, 2, 8, face(p.a), 1)
|
|
1237
|
+
die(7, 6, 8, face(p.b), 1)
|
|
1238
|
+
},
|
|
1239
|
+
]
|
|
1240
|
+
|
|
1241
|
+
layouts[p.layout]()
|
|
1242
|
+
},
|
|
1243
|
+
},
|
|
1244
|
+
]
|
|
1245
|
+
|
|
1246
|
+
const EMBLEMS: Definition[] = [
|
|
1247
|
+
{
|
|
1248
|
+
id: "shield",
|
|
1249
|
+
name: "Shield",
|
|
1250
|
+
family: "Emblems",
|
|
1251
|
+
label: "A heater shield with one of thirteen heraldic divisions and ordinaries, by the rule of tincture",
|
|
1252
|
+
resolve: (random) => {
|
|
1253
|
+
const r = random("shield")
|
|
1254
|
+
const metal = pick(r, METAL_TINCTURES)
|
|
1255
|
+
const colour = pick(r, COLOUR_TINCTURES)
|
|
1256
|
+
const metalFirst = r() < 0.5
|
|
1257
|
+
const all = colors(palette(random("palette")))
|
|
1258
|
+
|
|
1259
|
+
return {
|
|
1260
|
+
grid: 16,
|
|
1261
|
+
field: metalFirst ? metal : colour,
|
|
1262
|
+
charge: metalFirst ? colour : metal,
|
|
1263
|
+
third: pick(
|
|
1264
|
+
r,
|
|
1265
|
+
[...METAL_TINCTURES, ...COLOUR_TINCTURES].filter((c) => c !== metal && c !== colour),
|
|
1266
|
+
),
|
|
1267
|
+
ordinary: int(r, 0, 12),
|
|
1268
|
+
roundel: r() < 0.4 ? 1 : 0,
|
|
1269
|
+
ground: r() < 0.5 ? all[0] : 0x1f2228,
|
|
1270
|
+
}
|
|
1271
|
+
},
|
|
1272
|
+
paint: (pixels, p) => {
|
|
1273
|
+
const inside = (x: number, y: number) => {
|
|
1274
|
+
if (y < 1 || y > 14 || x < 2 || x > 13) return false
|
|
1275
|
+
|
|
1276
|
+
if (y <= 7) return true
|
|
1277
|
+
|
|
1278
|
+
return Math.abs(x + 0.5 - 8) < 6 * Math.sqrt(Math.max(0, 1 - ((y + 0.5 - 7.5) / 7.2) ** 2))
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
const ordinaries = [
|
|
1282
|
+
(x: number) => x >= 6 && x <= 9,
|
|
1283
|
+
(_: number, y: number) => y >= 6 && y <= 9,
|
|
1284
|
+
(x: number, y: number) => Math.abs(x - y) <= 1.5,
|
|
1285
|
+
(x: number, y: number) => Math.abs(y - (12 - Math.abs(x + 0.5 - 8) * 1)) <= 1.2,
|
|
1286
|
+
(x: number, y: number) => (x >= 7 && x <= 8) || (y >= 6 && y <= 7),
|
|
1287
|
+
(x: number, y: number) => Math.abs(x - y) <= 0.8 || Math.abs(x + y - 15) <= 0.8,
|
|
1288
|
+
(_: number, y: number) => y <= 4,
|
|
1289
|
+
(x: number) => x >= 8,
|
|
1290
|
+
(x: number, y: number) => x >= 8 !== y >= 8,
|
|
1291
|
+
(x: number, y: number) => x < y,
|
|
1292
|
+
(x: number, y: number) => !inside(x - 1, y) || !inside(x + 1, y) || !inside(x, y + 1) || y <= 2,
|
|
1293
|
+
(x: number) => Math.floor((x - 2) / 2) % 2 === 1,
|
|
1294
|
+
(x: number, y: number) => (Math.floor((x - 2) / 3) + Math.floor((y - 1) / 3)) % 2 === 1,
|
|
1295
|
+
]
|
|
1296
|
+
|
|
1297
|
+
pixels.fill(p.ground)
|
|
1298
|
+
pixels.each((x, y) => {
|
|
1299
|
+
if (!inside(x, y)) return inside(x - 1, y) || inside(x + 1, y) || inside(x, y - 1) ? 0x2a2a2a : undefined
|
|
1300
|
+
|
|
1301
|
+
return ordinaries[p.ordinary](x, y) ? p.charge : p.field
|
|
1302
|
+
})
|
|
1303
|
+
|
|
1304
|
+
if (!p.roundel) return
|
|
1305
|
+
const spot = p.ordinary === 6 ? [8, 2.6] : [8, 10]
|
|
1306
|
+
pixels.disc(spot[0], spot[1], 1.6, p.third)
|
|
1307
|
+
},
|
|
1308
|
+
},
|
|
1309
|
+
{
|
|
1310
|
+
id: "constellation",
|
|
1311
|
+
name: "Constellation",
|
|
1312
|
+
family: "Emblems",
|
|
1313
|
+
label: "Four to seven stars joined by their shortest links, on a night sky or a parchment chart; they twinkle on hover",
|
|
1314
|
+
animated: true,
|
|
1315
|
+
resolve: (random) => {
|
|
1316
|
+
const r = random("constellation")
|
|
1317
|
+
const count = int(r, 4, 7)
|
|
1318
|
+
|
|
1319
|
+
const points = retry(
|
|
1320
|
+
() => Array.from({ length: count }, () => [range(r, 0.14, 0.86), range(r, 0.14, 0.86)]),
|
|
1321
|
+
(list) => list.every(([x, y], i) => list.every(([u, v], j) => i === j || Math.hypot(x - u, y - v) > 0.2)),
|
|
1322
|
+
)
|
|
1323
|
+
|
|
1324
|
+
return {
|
|
1325
|
+
count,
|
|
1326
|
+
seed: seed(r),
|
|
1327
|
+
...prefixed("k", pick(r, CHARTS)),
|
|
1328
|
+
...prefixed(
|
|
1329
|
+
"x",
|
|
1330
|
+
points.map(([x]) => x),
|
|
1331
|
+
),
|
|
1332
|
+
...prefixed(
|
|
1333
|
+
"y",
|
|
1334
|
+
points.map(([, y]) => y),
|
|
1335
|
+
),
|
|
1336
|
+
...prefixed(
|
|
1337
|
+
"m",
|
|
1338
|
+
points.map(() => r()),
|
|
1339
|
+
),
|
|
1340
|
+
}
|
|
1341
|
+
},
|
|
1342
|
+
vector: (ctx, px, p, t) => {
|
|
1343
|
+
const [top, bottom, line, star] = colors(p, "k", 4)
|
|
1344
|
+
const xs = colors(p, "x", p.count)
|
|
1345
|
+
const ys = colors(p, "y", p.count)
|
|
1346
|
+
const sizes = colors(p, "m", p.count)
|
|
1347
|
+
const gradient = ctx.createLinearGradient(0, 0, 0, px)
|
|
1348
|
+
gradient.addColorStop(0, css(top))
|
|
1349
|
+
gradient.addColorStop(1, css(bottom))
|
|
1350
|
+
ctx.fillStyle = gradient
|
|
1351
|
+
ctx.fillRect(0, 0, px, px)
|
|
1352
|
+
const rand = mulberry32(p.seed)
|
|
1353
|
+
ctx.fillStyle = css(star, 0.35)
|
|
1354
|
+
Array.from({ length: 18 }, () => ctx.fillRect(rand() * px, rand() * px, px / 64 + 0.5, px / 64 + 0.5))
|
|
1355
|
+
|
|
1356
|
+
const linked = [0]
|
|
1357
|
+
ctx.strokeStyle = css(line, 0.75)
|
|
1358
|
+
ctx.lineWidth = Math.max(1, px * 0.025)
|
|
1359
|
+
|
|
1360
|
+
while (linked.length < p.count) {
|
|
1361
|
+
const [a, b] = linked
|
|
1362
|
+
.flatMap((i) => xs.map((_, j) => [i, j]))
|
|
1363
|
+
.filter(([, j]) => !linked.includes(j))
|
|
1364
|
+
.toSorted(([i, j], [k, l]) => Math.hypot(xs[i] - xs[j], ys[i] - ys[j]) - Math.hypot(xs[k] - xs[l], ys[k] - ys[l]))[0]
|
|
1365
|
+
ctx.beginPath()
|
|
1366
|
+
ctx.moveTo(xs[a] * px, ys[a] * px)
|
|
1367
|
+
ctx.lineTo(xs[b] * px, ys[b] * px)
|
|
1368
|
+
ctx.stroke()
|
|
1369
|
+
linked.push(b)
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
xs.forEach((x, i) => {
|
|
1373
|
+
const twinkle = 1 - 0.35 * (1 - Math.cos(t * (3 + sizes[i] * 4)))
|
|
1374
|
+
const radius = px * (0.03 + sizes[i] * 0.035) * twinkle
|
|
1375
|
+
ctx.fillStyle = css(star, 0.25)
|
|
1376
|
+
ctx.beginPath()
|
|
1377
|
+
ctx.arc(x * px, ys[i] * px, radius * 2.2, 0, Math.PI * 2)
|
|
1378
|
+
ctx.fill()
|
|
1379
|
+
ctx.fillStyle = css(star)
|
|
1380
|
+
ctx.beginPath()
|
|
1381
|
+
ctx.arc(x * px, ys[i] * px, radius, 0, Math.PI * 2)
|
|
1382
|
+
ctx.fill()
|
|
1383
|
+
})
|
|
1384
|
+
},
|
|
1385
|
+
},
|
|
1386
|
+
{
|
|
1387
|
+
id: "compass",
|
|
1388
|
+
name: "Compass rose",
|
|
1389
|
+
family: "Emblems",
|
|
1390
|
+
label: "A four-, eight- or sixteen-point rose with split points, a ring and ticks; the needle swings on hover",
|
|
1391
|
+
animated: true,
|
|
1392
|
+
resolve: (random) => {
|
|
1393
|
+
const r = random("compass")
|
|
1394
|
+
|
|
1395
|
+
return {
|
|
1396
|
+
...prefixed("k", pick(r, ROSES)),
|
|
1397
|
+
points: pick(r, [4, 8, 8, 16]),
|
|
1398
|
+
ring: r() < 0.7 ? 1 : 0,
|
|
1399
|
+
ticks: pick(r, [0, 16, 32]),
|
|
1400
|
+
turn: pick(r, [0, 0, 0, Math.PI / 8, Math.PI / 4]),
|
|
1401
|
+
north: r() < 0.6 ? 1 : 0,
|
|
1402
|
+
}
|
|
1403
|
+
},
|
|
1404
|
+
vector: (ctx, px, p, t) => {
|
|
1405
|
+
const [ground, dark, light, accent] = colors(p, "k", 4)
|
|
1406
|
+
const c = px / 2
|
|
1407
|
+
ctx.fillStyle = css(ground)
|
|
1408
|
+
ctx.fillRect(0, 0, px, px)
|
|
1409
|
+
ctx.save()
|
|
1410
|
+
ctx.translate(c, c)
|
|
1411
|
+
ctx.rotate(p.turn + Math.sin(t * 3) * 0.25 * Math.exp(-t * 0.4))
|
|
1412
|
+
|
|
1413
|
+
if (p.ring) {
|
|
1414
|
+
ctx.strokeStyle = css(dark)
|
|
1415
|
+
ctx.lineWidth = px * 0.03
|
|
1416
|
+
ctx.beginPath()
|
|
1417
|
+
ctx.arc(0, 0, px * 0.36, 0, Math.PI * 2)
|
|
1418
|
+
ctx.stroke()
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
Array.from({ length: p.ticks }, (_, k) => {
|
|
1422
|
+
const angle = (k / p.ticks) * Math.PI * 2
|
|
1423
|
+
ctx.beginPath()
|
|
1424
|
+
ctx.moveTo(Math.cos(angle) * px * 0.4, Math.sin(angle) * px * 0.4)
|
|
1425
|
+
ctx.lineTo(Math.cos(angle) * px * 0.45, Math.sin(angle) * px * 0.45)
|
|
1426
|
+
ctx.strokeStyle = css(dark)
|
|
1427
|
+
ctx.lineWidth = px * 0.02
|
|
1428
|
+
ctx.stroke()
|
|
1429
|
+
})
|
|
1430
|
+
|
|
1431
|
+
const order = Array.from({ length: p.points }, (_, k) => k).toSorted((a, b) => (b % 2) - (a % 2) || (b % 4) - (a % 4))
|
|
1432
|
+
order.forEach((k) => {
|
|
1433
|
+
const angle = (k / p.points) * Math.PI * 2 - Math.PI / 2
|
|
1434
|
+
const level = k % 4 === 0 ? 1 : k % 2 === 0 ? 0.68 : 0.46
|
|
1435
|
+
const length = px * 0.46 * (p.points === 4 ? 1 : level)
|
|
1436
|
+
const width = px * (p.points === 4 ? 0.14 : 0.1) * (level < 1 ? 0.8 : 1)
|
|
1437
|
+
const tip = [Math.cos(angle) * length, Math.sin(angle) * length]
|
|
1438
|
+
const side = [Math.cos(angle + Math.PI / 2) * width, Math.sin(angle + Math.PI / 2) * width]
|
|
1439
|
+
;[1, -1].forEach((s) => {
|
|
1440
|
+
ctx.beginPath()
|
|
1441
|
+
ctx.moveTo(0, 0)
|
|
1442
|
+
ctx.lineTo(tip[0], tip[1])
|
|
1443
|
+
ctx.lineTo(side[0] * s, side[1] * s)
|
|
1444
|
+
ctx.closePath()
|
|
1445
|
+
ctx.fillStyle = css(k === 0 && p.north ? (s > 0 ? accent : shade(accent, 0.7)) : s > 0 ? dark : light)
|
|
1446
|
+
ctx.fill()
|
|
1447
|
+
ctx.strokeStyle = css(dark)
|
|
1448
|
+
ctx.lineWidth = px * 0.012
|
|
1449
|
+
ctx.stroke()
|
|
1450
|
+
})
|
|
1451
|
+
})
|
|
1452
|
+
ctx.fillStyle = css(light)
|
|
1453
|
+
ctx.beginPath()
|
|
1454
|
+
ctx.arc(0, 0, px * 0.035, 0, Math.PI * 2)
|
|
1455
|
+
ctx.fill()
|
|
1456
|
+
ctx.restore()
|
|
1457
|
+
},
|
|
1458
|
+
},
|
|
1459
|
+
{
|
|
1460
|
+
id: "sigil",
|
|
1461
|
+
name: "Sigil",
|
|
1462
|
+
family: "Emblems",
|
|
1463
|
+
label: "A bind-rune of staves and branches cut into slate, sandstone, wood or vellum, or glowing; the glow pulses on hover",
|
|
1464
|
+
animated: true,
|
|
1465
|
+
resolve: (random) => {
|
|
1466
|
+
const r = random("sigil")
|
|
1467
|
+
const [stone, mark, glows] = pick(r, TABLETS)
|
|
1468
|
+
const lattice = Array.from({ length: 15 }, (_, i) => i)
|
|
1469
|
+
const branches = int(r, 2, 4)
|
|
1470
|
+
|
|
1471
|
+
const segments = Array.from({ length: branches }, () => {
|
|
1472
|
+
const a = pick(r, lattice)
|
|
1473
|
+
const options = lattice.filter((b) => {
|
|
1474
|
+
const dx = Math.abs((b % 3) - (a % 3))
|
|
1475
|
+
const dy = Math.abs(Math.floor(b / 3) - Math.floor(a / 3))
|
|
1476
|
+
|
|
1477
|
+
return b !== a && dx <= 1 && dy <= 1
|
|
1478
|
+
})
|
|
1479
|
+
|
|
1480
|
+
return [a, pick(r, options)]
|
|
1481
|
+
})
|
|
1482
|
+
|
|
1483
|
+
return {
|
|
1484
|
+
grid: 16,
|
|
1485
|
+
stone,
|
|
1486
|
+
mark,
|
|
1487
|
+
glows,
|
|
1488
|
+
staves: r() < 0.7 ? 1 : 2,
|
|
1489
|
+
mirror: r() < 0.5 ? 1 : 0,
|
|
1490
|
+
branches,
|
|
1491
|
+
...prefixed(
|
|
1492
|
+
"a",
|
|
1493
|
+
segments.map(([a]) => a),
|
|
1494
|
+
),
|
|
1495
|
+
...prefixed(
|
|
1496
|
+
"b",
|
|
1497
|
+
segments.map(([, b]) => b),
|
|
1498
|
+
),
|
|
1499
|
+
salt: r() * 50,
|
|
1500
|
+
}
|
|
1501
|
+
},
|
|
1502
|
+
paint: (pixels, p, t) => {
|
|
1503
|
+
const point = (i: number) => [3 + (i % 3) * 4.5, 1.5 + Math.floor(i / 3) * 3.2].map(Math.round)
|
|
1504
|
+
const marks = new Pixels(16)
|
|
1505
|
+
marks.fill(-1)
|
|
1506
|
+
|
|
1507
|
+
const stroke = (a: number, b: number) => {
|
|
1508
|
+
const [x0, y0] = point(a)
|
|
1509
|
+
const [x1, y1] = point(b)
|
|
1510
|
+
marks.line(x0, y0, x1, y1, 1)
|
|
1511
|
+
marks.line(x0 + 1, y0, x1 + 1, y1, 1)
|
|
1512
|
+
|
|
1513
|
+
if (!p.mirror) return
|
|
1514
|
+
marks.line(15 - x0, y0, 15 - x1, y1, 1)
|
|
1515
|
+
marks.line(14 - x0, y0, 14 - x1, y1, 1)
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
if (p.staves === 1) stroke(1, 13)
|
|
1519
|
+
|
|
1520
|
+
if (p.staves === 2) {
|
|
1521
|
+
stroke(0, 12)
|
|
1522
|
+
stroke(2, 14)
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
Array.from({ length: p.branches }, (_, i) => stroke(p[`a${i}`], p[`b${i}`]))
|
|
1526
|
+
const pulse = p.glows ? 0.5 + 0.5 * Math.sin(t * 4) * Math.min(1, t * 2) : 0
|
|
1527
|
+
|
|
1528
|
+
pixels.each((x, y) => {
|
|
1529
|
+
const textured = shade(p.stone, 0.9 + grain(x, y, p.salt) * 0.2)
|
|
1530
|
+
|
|
1531
|
+
if (marks.cells[y * 16 + x] === 1) return p.glows ? tint(p.mark, pulse * 0.4) : p.mark
|
|
1532
|
+
|
|
1533
|
+
if (!p.glows) return marks.get(x - 1, y - 1) === 1 ? tint(p.stone, 0.2) : textured
|
|
1534
|
+
const near = [-1, 1].some((d) => marks.get(x + d, y) === 1 || marks.get(x, y + d) === 1)
|
|
1535
|
+
|
|
1536
|
+
return near ? mix(textured, p.mark, 0.3 + pulse * 0.2) : textured
|
|
1537
|
+
})
|
|
1538
|
+
},
|
|
1539
|
+
},
|
|
1540
|
+
]
|
|
1541
|
+
|
|
1542
|
+
export const WORLD: Definition[] = [...NATURE, ...CREATURES, ...OBJECTS, ...EMBLEMS]
|