@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,1079 +1,1079 @@
|
|
|
1
|
-
// Project icon styles from craft: textiles, printmaking and twentieth-century art. See procedural.ts for the contract.
|
|
2
|
-
|
|
3
|
-
import { mulberry32 } from "./generated"
|
|
4
|
-
import {
|
|
5
|
-
clamp01,
|
|
6
|
-
colors,
|
|
7
|
-
css,
|
|
8
|
-
dither,
|
|
9
|
-
fbm,
|
|
10
|
-
grain,
|
|
11
|
-
hsl,
|
|
12
|
-
int,
|
|
13
|
-
legible,
|
|
14
|
-
luma,
|
|
15
|
-
mix,
|
|
16
|
-
multiply,
|
|
17
|
-
palette,
|
|
18
|
-
pick,
|
|
19
|
-
prefixed,
|
|
20
|
-
range,
|
|
21
|
-
retry,
|
|
22
|
-
seed,
|
|
23
|
-
shade,
|
|
24
|
-
shuffle,
|
|
25
|
-
smoothstep,
|
|
26
|
-
tint,
|
|
27
|
-
type Definition,
|
|
28
|
-
} from "./procedural-kit"
|
|
29
|
-
|
|
30
|
-
// Red, navy, green, yellow, white and the like: five threads each, as real setts use.
|
|
31
|
-
const TARTANS = [
|
|
32
|
-
[0xb81d2b, 0x1b2a4a, 0x1e5631, 0xf2c230, 0xf4f1ea],
|
|
33
|
-
[0x1b2a4a, 0x1e4d2b, 0x101010, 0x2b3f6b, 0x3d6b3d],
|
|
34
|
-
[0xf4f1ea, 0x1b2a4a, 0x1e5631, 0xf2c230, 0x101010],
|
|
35
|
-
[0xf2c230, 0x1e5631, 0xb81d2b, 0x101010, 0xf4f1ea],
|
|
36
|
-
[0xc9a77c, 0x161616, 0xf4f1ea, 0xa6192e, 0x8a6b4a],
|
|
37
|
-
[0xe8a0b4, 0x6b2d5c, 0xf4f1ea, 0x2a9d8f, 0xffd166],
|
|
38
|
-
[0x7a8c9e, 0x2f3e4f, 0xe6e2d6, 0xc44536, 0x51606f],
|
|
39
|
-
]
|
|
40
|
-
|
|
41
|
-
// Ink, then ground.
|
|
42
|
-
const HOUNDSTOOTH = [
|
|
43
|
-
[0x161616, 0xf2efe6],
|
|
44
|
-
[0x4a2f1f, 0xe9dcc3],
|
|
45
|
-
[0x1b2a4a, 0xf4f1ea],
|
|
46
|
-
[0x8f1d21, 0x161616],
|
|
47
|
-
[0x2d3a2e, 0xd9cfb4],
|
|
48
|
-
]
|
|
49
|
-
|
|
50
|
-
const RISO = [0xff48b0, 0x0078bf, 0xffe800, 0x00a95c, 0xff6c2f, 0x765ba7, 0x00838a, 0xf15060, 0x5ec8e5, 0x3255a4]
|
|
51
|
-
|
|
52
|
-
const PAPERS = [0xf5f0e6, 0xfffcf2, 0xe8dcc2, 0xf3ece0]
|
|
53
|
-
|
|
54
|
-
const INDIGO = [0x1b2a55, 0x22315e, 0x141c33, 0x7a3f22, 0x2b2b2e]
|
|
55
|
-
|
|
56
|
-
const POP = [0xff2d6f, 0xffd60a, 0x00b4d8, 0x8338ec, 0x06d6a0, 0xff7b00, 0x111111, 0xf8f4ec, 0x3a86ff]
|
|
57
|
-
|
|
58
|
-
// Six-by-six motifs for the screenprint, top row in the high bits.
|
|
59
|
-
const MOTIFS = [
|
|
60
|
-
[0b010010, 0b111111, 0b111111, 0b111111, 0b011110, 0b001100],
|
|
61
|
-
[0b001100, 0b001100, 0b111111, 0b011110, 0b011110, 0b110011],
|
|
62
|
-
[0b011110, 0b101101, 0b111111, 0b101101, 0b110011, 0b011110],
|
|
63
|
-
[0b000110, 0b001100, 0b011110, 0b001100, 0b011000, 0b010000],
|
|
64
|
-
[0b001100, 0b001100, 0b011110, 0b111111, 0b111111, 0b011110],
|
|
65
|
-
[0b010010, 0b110011, 0b001100, 0b001100, 0b110011, 0b010010],
|
|
66
|
-
]
|
|
67
|
-
|
|
68
|
-
const DE_STIJL = [0xd7261e, 0x1d3f9a, 0xf6cf1a]
|
|
69
|
-
|
|
70
|
-
const MEMPHIS_GROUNDS = [0xffe3ec, 0xfff4c2, 0xd9f2ef, 0xe6e1ff, 0x1a1a1a]
|
|
71
|
-
|
|
72
|
-
const MEMPHIS_INKS = [0xff5fa2, 0xffcd3c, 0x2ec4b6, 0x3a5bff, 0x111111, 0xff7a3d]
|
|
73
|
-
|
|
74
|
-
const DECO_GROUNDS = [0x101418, 0x0e2a24, 0x1b1f3b, 0x2a0f1a, 0xf1e9d8]
|
|
75
|
-
|
|
76
|
-
const DECO_METALS = [0xd4af37, 0xc9c9c9, 0xe0a984, 0x7fd1b9]
|
|
77
|
-
|
|
78
|
-
const KANDINSKY = [0xe0a526, 0xc8323a, 0x24479a, 0x3a8a4f, 0x161616, 0xefe3c8, 0x6b3f8f, 0xe86a2b, 0xe58fb0]
|
|
79
|
-
|
|
80
|
-
// Ground, then up to three fields.
|
|
81
|
-
const ROTHKO = [
|
|
82
|
-
[0x5a1a1a, 0xd9472b, 0x2b0e0e, 0xe8a33d],
|
|
83
|
-
[0x1d2b3a, 0x2f5d62, 0x0d1a24, 0x5e8b7e],
|
|
84
|
-
[0xd96b2b, 0xf2c14e, 0xb3311f, 0xf6e0a6],
|
|
85
|
-
[0x2a1a2e, 0x6b2d5c, 0x111111, 0xa2456b],
|
|
86
|
-
[0x8a8a83, 0x2a2a2a, 0xcfcac0, 0x4a4a4a],
|
|
87
|
-
[0x6e1e2b, 0x1d1d3a, 0xcf3b2c, 0x2b1a14],
|
|
88
|
-
[0x3d5a80, 0x98c1d9, 0x293241, 0xe0fbfc],
|
|
89
|
-
]
|
|
90
|
-
|
|
91
|
-
const TEXTILES: Definition[] = [
|
|
92
|
-
{
|
|
93
|
-
id: "tartan",
|
|
94
|
-
name: "Tartan",
|
|
95
|
-
family: "Textiles",
|
|
96
|
-
label: "A mirrored sett of three to five stripes, woven in 2/2 twill; it slides on hover",
|
|
97
|
-
animated: true,
|
|
98
|
-
resolve: (random) => {
|
|
99
|
-
const r = random("tartan")
|
|
100
|
-
const threads = r() < 0.55 ? pick(r, TARTANS) : colors(palette(random("palette")))
|
|
101
|
-
const count = int(r, 3, 5)
|
|
102
|
-
|
|
103
|
-
const order = retry(
|
|
104
|
-
() => Array.from({ length: count }, () => Math.floor(r() * 5)),
|
|
105
|
-
(list) => list.every((color, i) => i === 0 || color !== list[i - 1]),
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
return {
|
|
109
|
-
grid: r() < 0.6 ? 16 : 24,
|
|
110
|
-
count,
|
|
111
|
-
twill: r() < 0.5 ? 1 : -1,
|
|
112
|
-
...prefixed(
|
|
113
|
-
"s",
|
|
114
|
-
order.map((i) => threads[i]),
|
|
115
|
-
),
|
|
116
|
-
...prefixed(
|
|
117
|
-
"w",
|
|
118
|
-
order.map((_, i) => (i === 0 ? int(r, 3, 6) : r() < 0.35 ? 1 : int(r, 2, 4))),
|
|
119
|
-
),
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
paint: (pixels, p, t) => {
|
|
123
|
-
const stripes = colors(p, "s", p.count)
|
|
124
|
-
const widths = colors(p, "w", p.count)
|
|
125
|
-
const period = widths.reduce((sum, width) => sum + width, 0)
|
|
126
|
-
const shift = Math.floor(t * 4)
|
|
127
|
-
|
|
128
|
-
const thread = (i: number) => {
|
|
129
|
-
const k = (((i + shift) % (period * 2)) + period * 2) % (period * 2)
|
|
130
|
-
const along = k < period ? k : period * 2 - 1 - k
|
|
131
|
-
const index = widths.findIndex((_, j) => widths.slice(0, j + 1).reduce((sum, w) => sum + w, 0) > along)
|
|
132
|
-
|
|
133
|
-
return stripes[index]
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
pixels.each((x, y) => (((x + p.twill * y) & 3) < 2 ? shade(thread(x), 0.9) : thread(y)))
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
id: "houndstooth",
|
|
141
|
-
name: "Houndstooth",
|
|
142
|
-
family: "Textiles",
|
|
143
|
-
label: "Four-and-four threads in a 2/2 twill, one and a half to three teeth across, sometimes overchecked",
|
|
144
|
-
animated: true,
|
|
145
|
-
resolve: (random) => {
|
|
146
|
-
const r = random("houndstooth")
|
|
147
|
-
const all = colors(palette(random("palette")))
|
|
148
|
-
const ink = legible(r, all.slice(1), all[0])
|
|
149
|
-
const [color, ground] = r() < 0.5 ? pick(r, HOUNDSTOOTH) : r() < 0.6 ? [ink, all[0]] : [all[0], ink]
|
|
150
|
-
|
|
151
|
-
const [grid, unit] = pick(r, [
|
|
152
|
-
[16, 1],
|
|
153
|
-
[24, 1],
|
|
154
|
-
[16, 1],
|
|
155
|
-
[12, 1],
|
|
156
|
-
])
|
|
157
|
-
|
|
158
|
-
return {
|
|
159
|
-
grid,
|
|
160
|
-
unit,
|
|
161
|
-
ink: color,
|
|
162
|
-
ground,
|
|
163
|
-
over: r() < 0.35 ? 1 : 0,
|
|
164
|
-
overColor: pick(r, all.slice(1).filter((c) => c !== color && c !== ground)),
|
|
165
|
-
dir: r() < 0.5 ? 1 : -1,
|
|
166
|
-
ox: int(r, 0, 7),
|
|
167
|
-
oy: int(r, 0, 7),
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
paint: (pixels, p, t) => {
|
|
171
|
-
const shift = Math.floor(t * 3)
|
|
172
|
-
|
|
173
|
-
pixels.each((x, y) => {
|
|
174
|
-
const i = Math.floor(x / p.unit) + p.ox + shift
|
|
175
|
-
const j = Math.floor(y / p.unit) + p.oy
|
|
176
|
-
const warp = (i & 7) < 4 ? p.ink : p.ground
|
|
177
|
-
const weft = (j & 7) < 4 ? p.ink : p.ground
|
|
178
|
-
const color = ((i + p.dir * j) & 3) < 2 ? warp : weft
|
|
179
|
-
|
|
180
|
-
return p.over && ((i & 15) === 9 || (j & 15) === 9) ? mix(color, p.overColor, 0.7) : color
|
|
181
|
-
})
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
id: "gingham",
|
|
186
|
-
name: "Gingham",
|
|
187
|
-
family: "Textiles",
|
|
188
|
-
label: "Even checks with a half-tone where bands cross, or a buffalo check or windowpane",
|
|
189
|
-
resolve: (random) => {
|
|
190
|
-
const r = random("gingham")
|
|
191
|
-
const all = colors(palette(random("palette")))
|
|
192
|
-
|
|
193
|
-
return {
|
|
194
|
-
grid: 16,
|
|
195
|
-
size: int(r, 2, 4),
|
|
196
|
-
kind: pick(r, [0, 0, 0, 1, 2]),
|
|
197
|
-
ink: legible(r, all.slice(1), all[0]),
|
|
198
|
-
paper: r() < 0.7 ? all[0] : 0xffffff,
|
|
199
|
-
ox: int(r, 0, 3),
|
|
200
|
-
oy: int(r, 0, 3),
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
paint: (pixels, p) => {
|
|
204
|
-
pixels.each((x, y) => {
|
|
205
|
-
const a = Math.floor((x + p.ox) / p.size) % 2 === 0
|
|
206
|
-
const b = Math.floor((y + p.oy) / p.size) % 2 === 0
|
|
207
|
-
const texture = (x + y) % 2 ? 0.93 : 1
|
|
208
|
-
|
|
209
|
-
if (p.kind === 1) {
|
|
210
|
-
if (a && b) return shade(mix(0x111111, p.ink, 0.25), 1)
|
|
211
|
-
|
|
212
|
-
return a || b ? shade(p.ink, 0.62 * texture) : p.ink
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
if (p.kind === 2) {
|
|
216
|
-
const period = p.size * 2 + 2
|
|
217
|
-
const line = (x + p.ox) % period === 0 || (y + p.oy) % period === 0
|
|
218
|
-
const thin = (x + p.ox) % period === p.size + 1 || (y + p.oy) % period === p.size + 1
|
|
219
|
-
|
|
220
|
-
return line ? p.ink : thin ? mix(p.paper, p.ink, 0.3) : p.paper
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
if (a && b) return p.ink
|
|
224
|
-
|
|
225
|
-
return a || b ? shade(mix(p.paper, p.ink, 0.5), texture) : p.paper
|
|
226
|
-
})
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
id: "argyle",
|
|
231
|
-
name: "Argyle",
|
|
232
|
-
family: "Textiles",
|
|
233
|
-
label: "Harlequin diamonds with a dashed or solid overcheck through their centres",
|
|
234
|
-
resolve: (random) => {
|
|
235
|
-
const r = random("argyle")
|
|
236
|
-
const all = shuffle(r, colors(palette(random("palette"))))
|
|
237
|
-
const [a, b] = all
|
|
238
|
-
|
|
239
|
-
return {
|
|
240
|
-
grid: 16,
|
|
241
|
-
across: pick(r, [1, 2, 2]),
|
|
242
|
-
tall: pick(r, [1, 1.3, 1.6]),
|
|
243
|
-
oy: range(r, 0, 4),
|
|
244
|
-
dashed: r() < 0.6 ? 1 : 0,
|
|
245
|
-
a,
|
|
246
|
-
b,
|
|
247
|
-
line: legible(r, all.slice(2), mix(a, b, 0.5)),
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
paint: (pixels, p) => {
|
|
251
|
-
const w = 16 / p.across
|
|
252
|
-
const h = w * p.tall
|
|
253
|
-
const scale = 1 / Math.hypot(1 / w, 1 / h)
|
|
254
|
-
|
|
255
|
-
pixels.each((x, y) => {
|
|
256
|
-
const u = (x + 0.5) / w + (y + 0.5 - p.oy) / h + 0.5
|
|
257
|
-
const v = (x + 0.5) / w - (y + 0.5 - p.oy) / h + 0.5
|
|
258
|
-
const base = (Math.floor(u) + Math.floor(v)) & 1 ? p.b : p.a
|
|
259
|
-
const du = Math.abs((((u % 1) + 1) % 1) - 0.5) * scale
|
|
260
|
-
const dv = Math.abs((((v % 1) + 1) % 1) - 0.5) * scale
|
|
261
|
-
const dash = !p.dashed || (x + y) % 3 !== 2
|
|
262
|
-
|
|
263
|
-
return (du < 0.55 || dv < 0.55) && dash ? p.line : base
|
|
264
|
-
})
|
|
265
|
-
},
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
id: "zigzag",
|
|
269
|
-
name: "Zigzag",
|
|
270
|
-
family: "Textiles",
|
|
271
|
-
label: "Chevron stripes, or bargello flame-stitch peaks in graded shades; they climb on hover",
|
|
272
|
-
animated: true,
|
|
273
|
-
resolve: (random) => {
|
|
274
|
-
const r = random("zigzag")
|
|
275
|
-
const all = colors(palette(random("palette")))
|
|
276
|
-
const flame = r() < 0.4 ? 1 : 0
|
|
277
|
-
const [from, to] = shuffle(r, all.slice(1))
|
|
278
|
-
const count = int(r, 3, 4)
|
|
279
|
-
|
|
280
|
-
return {
|
|
281
|
-
grid: 16,
|
|
282
|
-
flame,
|
|
283
|
-
seed: seed(r),
|
|
284
|
-
period: pick(r, [4, 8, 8, 16]),
|
|
285
|
-
width: int(r, 2, 3),
|
|
286
|
-
vertical: r() < 0.25 ? 1 : 0,
|
|
287
|
-
count: flame ? 5 : count,
|
|
288
|
-
...prefixed(
|
|
289
|
-
"z",
|
|
290
|
-
flame
|
|
291
|
-
? [shade(from, 0.6), from, mix(from, to, 0.5), to, tint(to, 0.5)]
|
|
292
|
-
: [all[0], ...shuffle(r, all.slice(1))].slice(0, count),
|
|
293
|
-
),
|
|
294
|
-
}
|
|
295
|
-
},
|
|
296
|
-
paint: (pixels, p, t) => {
|
|
297
|
-
const cycle = colors(p, "z", p.count)
|
|
298
|
-
const rand = mulberry32(p.seed)
|
|
299
|
-
const walk = Array.from({ length: 16 }).reduce<number[]>(
|
|
300
|
-
(list) => [...list, (list[list.length - 1] ?? 0) + pick(rand, [-2, -1, 1, 1, 2, 2])],
|
|
301
|
-
[],
|
|
302
|
-
)
|
|
303
|
-
const shift = t * 4
|
|
304
|
-
|
|
305
|
-
pixels.each((cx, cy) => {
|
|
306
|
-
const x = p.vertical ? cy : cx
|
|
307
|
-
const y = p.vertical ? cx : cy
|
|
308
|
-
const k = (x % p.period) / p.period
|
|
309
|
-
const offset = p.flame ? walk[x] : Math.abs(k - 0.5) * p.period
|
|
310
|
-
const band = Math.floor((y + offset + shift) / p.width)
|
|
311
|
-
|
|
312
|
-
return cycle[((band % p.count) + p.count) % p.count]
|
|
313
|
-
})
|
|
314
|
-
},
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
id: "seigaiha",
|
|
318
|
-
name: "Seigaiha",
|
|
319
|
-
family: "Textiles",
|
|
320
|
-
label: "Overlapping wave scales of three or four rings, one and a half to two across; the rings ripple on hover",
|
|
321
|
-
animated: true,
|
|
322
|
-
resolve: (random) => {
|
|
323
|
-
const r = random("seigaiha")
|
|
324
|
-
const all = colors(palette(random("palette")))
|
|
325
|
-
const classic = r() < 0.35
|
|
326
|
-
const [a, b, c] = shuffle(r, all.slice(1))
|
|
327
|
-
|
|
328
|
-
return {
|
|
329
|
-
across: pick(r, [1.5, 2, 2]),
|
|
330
|
-
rings: int(r, 3, 4),
|
|
331
|
-
lines: r() < 0.4 ? 1 : 0,
|
|
332
|
-
accent: r() < 0.4 ? 1 : 0,
|
|
333
|
-
ground: classic ? 0x1d3557 : a,
|
|
334
|
-
ink: classic ? 0xf4efe6 : legible(r, [b, c, all[0]], a),
|
|
335
|
-
third: c,
|
|
336
|
-
}
|
|
337
|
-
},
|
|
338
|
-
vector: (ctx, px, p, t) => {
|
|
339
|
-
const radius = px / p.across / 2
|
|
340
|
-
const step = radius * 0.5
|
|
341
|
-
const phase = (t * 0.8) % 1
|
|
342
|
-
|
|
343
|
-
for (let j = -1; j * step < px + radius; j++)
|
|
344
|
-
for (let i = -1; i * radius * 2 < px + radius * 2; i++) {
|
|
345
|
-
const cx = i * radius * 2 + (j % 2 ? radius : 0)
|
|
346
|
-
const cy = j * step
|
|
347
|
-
|
|
348
|
-
for (let k = 0; k < p.rings; k++) {
|
|
349
|
-
const ring = Math.max(0, radius * (1 - (k - (k ? phase : 0)) / p.rings))
|
|
350
|
-
ctx.beginPath()
|
|
351
|
-
ctx.arc(cx, cy, ring, 0, Math.PI * 2)
|
|
352
|
-
|
|
353
|
-
if (p.lines) {
|
|
354
|
-
ctx.fillStyle = css(p.ground)
|
|
355
|
-
ctx.fill()
|
|
356
|
-
ctx.strokeStyle = css(p.accent && k === p.rings - 1 ? p.third : p.ink)
|
|
357
|
-
ctx.lineWidth = radius * 0.1
|
|
358
|
-
ctx.stroke()
|
|
359
|
-
continue
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
ctx.fillStyle = css(k % 2 ? p.ink : p.accent && k === 2 ? p.third : p.ground)
|
|
363
|
-
ctx.fill()
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
},
|
|
367
|
-
},
|
|
368
|
-
{
|
|
369
|
-
id: "tie-dye",
|
|
370
|
-
name: "Tie-dye",
|
|
371
|
-
family: "Textiles",
|
|
372
|
-
label: "A dye spiral, bullseye or crumple with bleeding bands and white crinkles",
|
|
373
|
-
resolve: (random) => {
|
|
374
|
-
const r = random("tie-dye")
|
|
375
|
-
const rainbow = r() < 0.55
|
|
376
|
-
const count = int(r, 4, 6)
|
|
377
|
-
const hue = r()
|
|
378
|
-
const inks = shuffle(r, colors(palette(random("palette"))).slice(1))
|
|
379
|
-
|
|
380
|
-
return {
|
|
381
|
-
grid: 32,
|
|
382
|
-
kind: pick(r, [0, 0, 1, 2]),
|
|
383
|
-
arms: int(r, 2, 5),
|
|
384
|
-
twist: range(r, 2, 6) * (r() < 0.5 ? -1 : 1),
|
|
385
|
-
cx: range(r, 10, 22),
|
|
386
|
-
cy: range(r, 10, 22),
|
|
387
|
-
seedX: r() * 40,
|
|
388
|
-
seedY: r() * 40,
|
|
389
|
-
count: rainbow ? count : 4,
|
|
390
|
-
...prefixed(
|
|
391
|
-
"d",
|
|
392
|
-
rainbow ? Array.from({ length: count }, (_, i) => hsl(hue + i / count, 0.85, 0.55)) : inks,
|
|
393
|
-
),
|
|
394
|
-
}
|
|
395
|
-
},
|
|
396
|
-
paint: (pixels, p) => {
|
|
397
|
-
const dyes = colors(p, "d", p.count)
|
|
398
|
-
|
|
399
|
-
pixels.each((x, y) => {
|
|
400
|
-
const dx = x + 0.5 - p.cx
|
|
401
|
-
const dy = y + 0.5 - p.cy
|
|
402
|
-
const d = Math.hypot(dx, dy) / 32
|
|
403
|
-
const wobble = fbm(x * 0.15 + p.seedX, y * 0.15 + p.seedY)
|
|
404
|
-
const angle = Math.atan2(dy, dx) / (Math.PI * 2)
|
|
405
|
-
|
|
406
|
-
const value =
|
|
407
|
-
p.kind === 0
|
|
408
|
-
? angle * p.arms + p.twist * Math.sqrt(d) + wobble * 0.5
|
|
409
|
-
: p.kind === 1
|
|
410
|
-
? d * 7 + wobble * 1.2 + Math.sin(angle * Math.PI * 2 * p.arms) * 0.15
|
|
411
|
-
: fbm(x * 0.09 + p.seedY, y * 0.09 + p.seedX) * p.count * 1.6
|
|
412
|
-
|
|
413
|
-
const band = Math.floor(value * (p.kind === 0 ? 1 : 1))
|
|
414
|
-
const along = value - band
|
|
415
|
-
const a = dyes[((band % p.count) + p.count) % p.count]
|
|
416
|
-
const b = dyes[(((band + 1) % p.count) + p.count) % p.count]
|
|
417
|
-
const color = mix(a, b, smoothstep(0.7, 1, along))
|
|
418
|
-
const crinkle = fbm(x * 0.6 + p.seedX * 2, y * 0.6 + p.seedY)
|
|
419
|
-
|
|
420
|
-
return crinkle > 0.74 ? mix(color, 0xffffff, 0.55) : color
|
|
421
|
-
})
|
|
422
|
-
},
|
|
423
|
-
},
|
|
424
|
-
{
|
|
425
|
-
id: "shibori",
|
|
426
|
-
name: "Shibori",
|
|
427
|
-
family: "Textiles",
|
|
428
|
-
label: "Resist-dyed indigo: clamped squares, circles or diamonds, pole-wrapped stripes or spider webs",
|
|
429
|
-
resolve: (random) => {
|
|
430
|
-
const r = random("shibori")
|
|
431
|
-
|
|
432
|
-
return {
|
|
433
|
-
grid: 32,
|
|
434
|
-
kind: pick(r, [0, 0, 1, 2]),
|
|
435
|
-
dye: pick(r, INDIGO),
|
|
436
|
-
cloth: pick(r, [0xeef0ee, 0xf2ead8, 0xe3e8ee]),
|
|
437
|
-
cells: pick(r, [2, 3, 4]),
|
|
438
|
-
shape: int(r, 0, 2),
|
|
439
|
-
angle: range(r, 0.3, 1.2) * (r() < 0.5 ? 1 : -1),
|
|
440
|
-
spacing: range(r, 3.5, 6),
|
|
441
|
-
centers: int(r, 1, 3),
|
|
442
|
-
seed: seed(r),
|
|
443
|
-
seedX: r() * 40,
|
|
444
|
-
seedY: r() * 40,
|
|
445
|
-
}
|
|
446
|
-
},
|
|
447
|
-
paint: (pixels, p) => {
|
|
448
|
-
const rand = mulberry32(p.seed)
|
|
449
|
-
const webs = Array.from({ length: p.centers }, () => ({
|
|
450
|
-
x: range(rand, 6, 26),
|
|
451
|
-
y: range(rand, 6, 26),
|
|
452
|
-
r: range(rand, 7, 12),
|
|
453
|
-
}))
|
|
454
|
-
const size = 32 / p.cells
|
|
455
|
-
|
|
456
|
-
pixels.each((x, y) => {
|
|
457
|
-
const n = fbm(x * 0.2 + p.seedX, y * 0.2 + p.seedY)
|
|
458
|
-
const kinds = [
|
|
459
|
-
() => {
|
|
460
|
-
const u = ((x + 0.5) % size) / size - 0.5
|
|
461
|
-
const v = ((y + 0.5) % size) / size - 0.5
|
|
462
|
-
const d = [Math.max(Math.abs(u), Math.abs(v)), Math.hypot(u, v), Math.abs(u) + Math.abs(v)][p.shape]
|
|
463
|
-
|
|
464
|
-
return smoothstep(0.32, 0.22, d + (n - 0.5) * 0.18)
|
|
465
|
-
},
|
|
466
|
-
() => {
|
|
467
|
-
const v = (x * Math.cos(p.angle) + y * Math.sin(p.angle)) / p.spacing + n * 1.4
|
|
468
|
-
|
|
469
|
-
return smoothstep(0.8, 0.97, Math.abs(Math.sin(v * Math.PI))) * smoothstep(0.25, 0.5, n)
|
|
470
|
-
},
|
|
471
|
-
() =>
|
|
472
|
-
Math.max(
|
|
473
|
-
...webs.map((web) => {
|
|
474
|
-
const d = Math.hypot(x + 0.5 - web.x, y + 0.5 - web.y)
|
|
475
|
-
const spoke = Math.abs(Math.sin(Math.atan2(y + 0.5 - web.y, x + 0.5 - web.x) * 6 + d * 0.15))
|
|
476
|
-
|
|
477
|
-
return d < web.r ? smoothstep(0.75, 0.98, spoke) * (1 - d / web.r) + (d < 1.6 ? 1 : 0) : 0
|
|
478
|
-
}),
|
|
479
|
-
),
|
|
480
|
-
() => {
|
|
481
|
-
const row = Math.round(y / p.spacing) * p.spacing
|
|
482
|
-
const stitch = Math.abs(y - row) < 0.8 && Math.floor(x / 2 + row) % 2 === 0
|
|
483
|
-
|
|
484
|
-
return stitch ? 0.85 : 0
|
|
485
|
-
},
|
|
486
|
-
]
|
|
487
|
-
|
|
488
|
-
const resist = clamp01(kinds[p.kind]())
|
|
489
|
-
const dyed = shade(p.dye, 0.85 + n * 0.3)
|
|
490
|
-
|
|
491
|
-
return [dyed, mix(dyed, p.cloth, 0.5), p.cloth][dither(resist, 3, x, y)]
|
|
492
|
-
})
|
|
493
|
-
},
|
|
494
|
-
},
|
|
495
|
-
]
|
|
496
|
-
|
|
497
|
-
const PRINT: Definition[] = [
|
|
498
|
-
{
|
|
499
|
-
id: "risograph",
|
|
500
|
-
name: "Risograph",
|
|
501
|
-
family: "Print",
|
|
502
|
-
label: "Two fluorescent inks, each a disc, stripes, half or ring, overprinted out of register with grain",
|
|
503
|
-
resolve: (random) => {
|
|
504
|
-
const r = random("riso")
|
|
505
|
-
const [a, b] = shuffle(r, RISO)
|
|
506
|
-
|
|
507
|
-
const layer = (prefix: string) =>
|
|
508
|
-
prefixed(prefix, [int(r, 0, 3), range(r, 0.3, 0.7), range(r, 0.3, 0.7), range(r, 0.3, 0.45), r() * Math.PI])
|
|
509
|
-
|
|
510
|
-
return {
|
|
511
|
-
grid: 32,
|
|
512
|
-
paper: pick(r, PAPERS),
|
|
513
|
-
a,
|
|
514
|
-
b,
|
|
515
|
-
...layer("a"),
|
|
516
|
-
...layer("b"),
|
|
517
|
-
mx: range(r, 0.8, 1.8) * (r() < 0.5 ? 1 : -1),
|
|
518
|
-
my: range(r, 0.8, 1.8) * (r() < 0.5 ? 1 : -1),
|
|
519
|
-
salt: r() * 100,
|
|
520
|
-
}
|
|
521
|
-
},
|
|
522
|
-
paint: (pixels, p) => {
|
|
523
|
-
const layer = (prefix: string, ox: number, oy: number) => {
|
|
524
|
-
const [kind, cx, cy, size, angle] = colors(p, prefix, 5)
|
|
525
|
-
const cos = Math.cos(angle)
|
|
526
|
-
const sin = Math.sin(angle)
|
|
527
|
-
const bands = 4 + size * 8
|
|
528
|
-
|
|
529
|
-
return (x: number, y: number) => {
|
|
530
|
-
const u = (x + ox) / 32 - cx
|
|
531
|
-
const v = (y + oy) / 32 - cy
|
|
532
|
-
const along = u * cos + v * sin
|
|
533
|
-
|
|
534
|
-
if (kind === 1) return Math.floor((along + 2) * bands) % 2
|
|
535
|
-
if (kind === 2) return along > 0 ? 1 : 0
|
|
536
|
-
const d = Math.hypot(u, v)
|
|
537
|
-
|
|
538
|
-
return (kind === 0 ? d < size : Math.abs(d - size) < size * 0.4) ? 1 : 0
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
const a = layer("a", 0.5, 0.5)
|
|
543
|
-
const b = layer("b", 0.5 + p.mx, 0.5 + p.my)
|
|
544
|
-
|
|
545
|
-
// Uneven coverage and speckle are properties of the paper, so both inks share them.
|
|
546
|
-
pixels.each((x, y) => {
|
|
547
|
-
const texture = (0.78 + 0.22 * fbm(x * 0.3 + 7, y * 0.3)) * (grain(x, y, p.salt) < 0.1 ? 0.3 : 1)
|
|
548
|
-
|
|
549
|
-
return multiply(multiply(p.paper, mix(0xffffff, p.a, a(x, y) * texture)), mix(0xffffff, p.b, b(x, y) * texture))
|
|
550
|
-
})
|
|
551
|
-
},
|
|
552
|
-
},
|
|
553
|
-
{
|
|
554
|
-
id: "halftone",
|
|
555
|
-
name: "Halftone",
|
|
556
|
-
family: "Print",
|
|
557
|
-
label: "A rotated dot screen of a gradient, sphere or wave, sometimes two screens overprinted",
|
|
558
|
-
resolve: (random) => {
|
|
559
|
-
const r = random("halftone")
|
|
560
|
-
const all = colors(palette(random("palette")))
|
|
561
|
-
const ink = legible(r, all.slice(1), all[0])
|
|
562
|
-
const field = int(r, 0, 3)
|
|
563
|
-
|
|
564
|
-
return {
|
|
565
|
-
cells: int(r, 6, 9),
|
|
566
|
-
angle: (pick(r, [15, 45, 75, 0]) * Math.PI) / 180,
|
|
567
|
-
field,
|
|
568
|
-
dir: r() * Math.PI * 2,
|
|
569
|
-
cx: range(r, 0.3, 0.7),
|
|
570
|
-
cy: range(r, 0.3, 0.7),
|
|
571
|
-
paper: all[0],
|
|
572
|
-
ink,
|
|
573
|
-
second: r() < 0.4 ? 1 : 0,
|
|
574
|
-
ink2: pick(
|
|
575
|
-
r,
|
|
576
|
-
all.slice(1).filter((color) => color !== ink),
|
|
577
|
-
),
|
|
578
|
-
}
|
|
579
|
-
},
|
|
580
|
-
vector: (ctx, px, p) => {
|
|
581
|
-
ctx.fillStyle = css(p.paper)
|
|
582
|
-
ctx.fillRect(0, 0, px, px)
|
|
583
|
-
|
|
584
|
-
const tone = (u: number, v: number, screen: number) => {
|
|
585
|
-
const dx = u - p.cx
|
|
586
|
-
const dy = v - p.cy
|
|
587
|
-
const along = dx * Math.cos(p.dir + screen * 2) + dy * Math.sin(p.dir + screen * 2)
|
|
588
|
-
|
|
589
|
-
const fields = [
|
|
590
|
-
() => along + 0.5,
|
|
591
|
-
() => 1 - Math.hypot(dx, dy) * 1.6,
|
|
592
|
-
() => {
|
|
593
|
-
const d = Math.hypot(dx, dy) / 0.34
|
|
594
|
-
|
|
595
|
-
return d > 1 ? 0.06 : 1 - (Math.sqrt(1 - Math.min(1, d * d)) * 0.6 + 0.25 - (dx + dy) * 0.7)
|
|
596
|
-
},
|
|
597
|
-
() => 0.5 + 0.5 * Math.sin(along * 14),
|
|
598
|
-
]
|
|
599
|
-
|
|
600
|
-
return clamp01(fields[p.field]())
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
const screens = p.second ? [0, 1] : [0]
|
|
604
|
-
ctx.globalCompositeOperation = "multiply"
|
|
605
|
-
screens.forEach((screen) => {
|
|
606
|
-
const cell = px / p.cells
|
|
607
|
-
const angle = p.angle + screen * (Math.PI / 6)
|
|
608
|
-
ctx.fillStyle = css(screen ? p.ink2 : p.ink)
|
|
609
|
-
|
|
610
|
-
for (let i = -p.cells; i < p.cells * 2; i++)
|
|
611
|
-
for (let j = -p.cells; j < p.cells * 2; j++) {
|
|
612
|
-
const lx = (i + 0.5) * cell
|
|
613
|
-
const ly = (j + 0.5) * cell
|
|
614
|
-
const x = px / 2 + (lx - px / 2) * Math.cos(angle) - (ly - px / 2) * Math.sin(angle)
|
|
615
|
-
const y = px / 2 + (lx - px / 2) * Math.sin(angle) + (ly - px / 2) * Math.cos(angle)
|
|
616
|
-
|
|
617
|
-
if (x < -cell || y < -cell || x > px + cell || y > px + cell) continue
|
|
618
|
-
const radius = Math.sqrt(tone(x / px, y / px, screen)) * cell * 0.62
|
|
619
|
-
|
|
620
|
-
if (radius < cell * 0.06) continue
|
|
621
|
-
ctx.beginPath()
|
|
622
|
-
ctx.arc(x, y, radius, 0, Math.PI * 2)
|
|
623
|
-
ctx.fill()
|
|
624
|
-
}
|
|
625
|
-
})
|
|
626
|
-
ctx.globalCompositeOperation = "source-over"
|
|
627
|
-
},
|
|
628
|
-
},
|
|
629
|
-
{
|
|
630
|
-
id: "linocut",
|
|
631
|
-
name: "Linocut",
|
|
632
|
-
family: "Print",
|
|
633
|
-
label: "A sun, peak, moon or hill left standing in paper, with gouged lines that shorten away from it",
|
|
634
|
-
resolve: (random) => {
|
|
635
|
-
const r = random("linocut")
|
|
636
|
-
|
|
637
|
-
return {
|
|
638
|
-
grid: 24,
|
|
639
|
-
motif: int(r, 0, 3),
|
|
640
|
-
mx: range(r, 8, 16),
|
|
641
|
-
my: range(r, 7, 12),
|
|
642
|
-
size: range(r, 4.5, 6.5),
|
|
643
|
-
spacing: pick(r, [3, 3, 4]),
|
|
644
|
-
horizon: int(r, 16, 19),
|
|
645
|
-
ink: pick(r, [0x161616, 0x1d2b4f, 0x5a1a1a, 0x1f3b2c, 0x3a2a4f]),
|
|
646
|
-
paper: pick(r, [0xf2ead8, 0xf6f1e7, 0xe9d8b4, 0xf0d9c8]),
|
|
647
|
-
seedX: r() * 40,
|
|
648
|
-
seedY: r() * 40,
|
|
649
|
-
}
|
|
650
|
-
},
|
|
651
|
-
paint: (pixels, p) => {
|
|
652
|
-
pixels.each((x, y) => {
|
|
653
|
-
const X = x + 0.5
|
|
654
|
-
const Y = y + 0.5
|
|
655
|
-
const dx = X - p.mx
|
|
656
|
-
const dy = Y - p.my
|
|
657
|
-
const d = Math.hypot(dx, dy)
|
|
658
|
-
|
|
659
|
-
const motifs = [
|
|
660
|
-
() => d < p.size,
|
|
661
|
-
() => Y > p.my - p.size && Y < p.horizon && Math.abs(dx) < (Y - (p.my - p.size)) * 0.85,
|
|
662
|
-
() => d < p.size && Math.hypot(dx - p.size * 0.5, dy - p.size * 0.2) > p.size * 0.8,
|
|
663
|
-
() => Y > p.my + 2 + Math.sin(X * 0.3 + p.seedX) * 2.5 && Y < p.horizon,
|
|
664
|
-
]
|
|
665
|
-
|
|
666
|
-
if (motifs[p.motif]()) {
|
|
667
|
-
const gouge = p.motif === 1 ? Y > p.my - p.size * 0.2 && (x + y) % 4 === 0 : p.motif === 3 && (x - y * 2) % 6 === 0
|
|
668
|
-
|
|
669
|
-
return gouge ? p.ink : p.paper
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
const wobble = fbm(X * 0.3 + p.seedX, Y * 0.3 + p.seedY)
|
|
673
|
-
|
|
674
|
-
if (Y >= p.horizon) return (y - p.horizon) % 2 === 1 && wobble > 0.35 ? p.paper : p.ink
|
|
675
|
-
const near = 1 - clamp01((d - p.size) / 11)
|
|
676
|
-
|
|
677
|
-
return y % p.spacing === 1 && wobble < near * 0.95 ? p.paper : p.ink
|
|
678
|
-
})
|
|
679
|
-
},
|
|
680
|
-
},
|
|
681
|
-
{
|
|
682
|
-
id: "screenprint",
|
|
683
|
-
name: "Screenprint",
|
|
684
|
-
family: "Print",
|
|
685
|
-
label: "A pop motif repeated in clashing colourways with a misregistered shadow, or one big",
|
|
686
|
-
resolve: (random) => {
|
|
687
|
-
const r = random("screenprint")
|
|
688
|
-
const ways = shuffle(r, POP)
|
|
689
|
-
|
|
690
|
-
return {
|
|
691
|
-
grid: 16,
|
|
692
|
-
motif: int(r, 0, MOTIFS.length - 1),
|
|
693
|
-
single: r() < 0.5 ? 1 : 0,
|
|
694
|
-
dx: pick(r, [1, -1]),
|
|
695
|
-
dy: pick(r, [1, 0, -1]),
|
|
696
|
-
...prefixed("g", ways.slice(0, 4)),
|
|
697
|
-
...prefixed("i", ways.slice(4, 8)),
|
|
698
|
-
...prefixed("s", ways.slice(1, 5)),
|
|
699
|
-
}
|
|
700
|
-
},
|
|
701
|
-
paint: (pixels, p) => {
|
|
702
|
-
const grounds = colors(p, "g", 4)
|
|
703
|
-
const inks = colors(p, "i", 4)
|
|
704
|
-
const shadows = colors(p, "s", 4)
|
|
705
|
-
const motif = MOTIFS[p.motif]
|
|
706
|
-
const at = (x: number, y: number) => x >= 0 && y >= 0 && x < 6 && y < 6 && ((motif[y] >> (5 - x)) & 1) === 1
|
|
707
|
-
|
|
708
|
-
pixels.each((x, y) => {
|
|
709
|
-
if (p.single) {
|
|
710
|
-
const lx = Math.floor((x - 2) / 2)
|
|
711
|
-
const ly = Math.floor((y - 2) / 2)
|
|
712
|
-
|
|
713
|
-
if (at(lx, ly)) return inks[0]
|
|
714
|
-
|
|
715
|
-
return at(Math.floor((x - 2 - p.dx) / 2), Math.floor((y - 2 - p.dy) / 2)) ? shadows[1] : grounds[0]
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
const panel = Math.floor(y / 8) * 2 + Math.floor(x / 8)
|
|
719
|
-
const lx = (x % 8) - 1
|
|
720
|
-
const ly = (y % 8) - 1
|
|
721
|
-
const ink = inks[panel] === grounds[panel] ? shadows[panel] : inks[panel]
|
|
722
|
-
|
|
723
|
-
if (at(lx, ly)) return ink
|
|
724
|
-
|
|
725
|
-
return at(lx - p.dx, ly - p.dy) ? shadows[(panel + 1) % 4] : grounds[panel]
|
|
726
|
-
})
|
|
727
|
-
},
|
|
728
|
-
},
|
|
729
|
-
]
|
|
730
|
-
|
|
731
|
-
const ART: Definition[] = [
|
|
732
|
-
{
|
|
733
|
-
id: "de-stijl",
|
|
734
|
-
name: "De Stijl",
|
|
735
|
-
family: "Art movements",
|
|
736
|
-
label: "Recursive black-lined rectangles with primary fills, sometimes turned 45° like van Doesburg",
|
|
737
|
-
resolve: (random) => {
|
|
738
|
-
const r = random("de-stijl")
|
|
739
|
-
|
|
740
|
-
return {
|
|
741
|
-
seed: seed(r),
|
|
742
|
-
depth: int(r, 2, 4),
|
|
743
|
-
weight: range(r, 0.05, 0.085),
|
|
744
|
-
turn: r() < 0.22 ? 1 : 0,
|
|
745
|
-
line: r() < 0.85 ? 0x111111 : 0x5a5a5a,
|
|
746
|
-
white: pick(r, [0xf2efe8, 0xf7f4ee, 0xebe6dc]),
|
|
747
|
-
grey: r() < 0.3 ? 1 : 0,
|
|
748
|
-
}
|
|
749
|
-
},
|
|
750
|
-
vector: (ctx, px, p) => {
|
|
751
|
-
const rand = mulberry32(p.seed)
|
|
752
|
-
const gap = px * p.weight
|
|
753
|
-
const leaves: { x: number; y: number; w: number; h: number }[] = []
|
|
754
|
-
|
|
755
|
-
const split = (x: number, y: number, w: number, h: number, depth: number) => {
|
|
756
|
-
if (depth === 0 || (depth < p.depth && rand() < 0.3) || Math.min(w, h) < px * 0.18) {
|
|
757
|
-
leaves.push({ x, y, w, h })
|
|
758
|
-
|
|
759
|
-
return
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
const k = 0.28 + rand() * 0.44
|
|
763
|
-
|
|
764
|
-
if (w > h ? rand() < 0.75 : rand() < 0.25) {
|
|
765
|
-
split(x, y, w * k, h, depth - 1)
|
|
766
|
-
split(x + w * k, y, w * (1 - k), h, depth - 1)
|
|
767
|
-
|
|
768
|
-
return
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
split(x, y, w, h * k, depth - 1)
|
|
772
|
-
split(x, y + h * k, w, h * (1 - k), depth - 1)
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
const extent = p.turn ? px * 1.5 : px
|
|
776
|
-
split(-gap / 2, -gap / 2, extent + gap, extent + gap, p.depth)
|
|
777
|
-
const fills = shuffle(rand, leaves.map((_, i) => i)).slice(0, Math.max(1, Math.round(leaves.length * 0.4)))
|
|
778
|
-
|
|
779
|
-
ctx.save()
|
|
780
|
-
|
|
781
|
-
if (p.turn) {
|
|
782
|
-
ctx.translate(px / 2, px / 2)
|
|
783
|
-
ctx.rotate(Math.PI / 4)
|
|
784
|
-
ctx.translate(-extent / 2, -extent / 2)
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
ctx.fillStyle = css(p.line)
|
|
788
|
-
ctx.fillRect(-px, -px, extent + px * 2, extent + px * 2)
|
|
789
|
-
leaves.forEach((leaf, i) => {
|
|
790
|
-
const slot = fills.indexOf(i)
|
|
791
|
-
const accent = slot < 0 ? p.white : slot < 3 ? DE_STIJL[(slot + p.seed) % 3] : p.grey ? 0xbdbab3 : p.white
|
|
792
|
-
ctx.fillStyle = css(accent)
|
|
793
|
-
ctx.fillRect(leaf.x + gap / 2, leaf.y + gap / 2, Math.max(0, leaf.w - gap), Math.max(0, leaf.h - gap))
|
|
794
|
-
})
|
|
795
|
-
ctx.restore()
|
|
796
|
-
},
|
|
797
|
-
},
|
|
798
|
-
{
|
|
799
|
-
id: "memphis",
|
|
800
|
-
name: "Memphis",
|
|
801
|
-
family: "Art movements",
|
|
802
|
-
label: "Squiggles, triangles, dot grids and zigzags scattered over a pastel ground",
|
|
803
|
-
resolve: (random) => {
|
|
804
|
-
const r = random("memphis")
|
|
805
|
-
|
|
806
|
-
return { seed: seed(r), ground: pick(r, MEMPHIS_GROUNDS), count: int(r, 3, 4) }
|
|
807
|
-
},
|
|
808
|
-
vector: (ctx, px, p) => {
|
|
809
|
-
const rand = mulberry32(p.seed)
|
|
810
|
-
const dark = luma(p.ground) < 0.3
|
|
811
|
-
const inks = MEMPHIS_INKS.filter((ink) => !dark || ink !== 0x111111)
|
|
812
|
-
ctx.fillStyle = css(p.ground)
|
|
813
|
-
ctx.fillRect(0, 0, px, px)
|
|
814
|
-
ctx.lineCap = "round"
|
|
815
|
-
ctx.lineJoin = "round"
|
|
816
|
-
ctx.lineWidth = px * 0.075
|
|
817
|
-
const spots = shuffle(rand, [
|
|
818
|
-
[0.28, 0.28],
|
|
819
|
-
[0.72, 0.3],
|
|
820
|
-
[0.3, 0.72],
|
|
821
|
-
[0.72, 0.72],
|
|
822
|
-
])
|
|
823
|
-
const kinds = shuffle(rand, [0, 1, 2, 3, 4, 5])
|
|
824
|
-
|
|
825
|
-
spots.slice(0, p.count).forEach(([u, v], i) => {
|
|
826
|
-
const x = u * px + (rand() - 0.5) * px * 0.1
|
|
827
|
-
const y = v * px + (rand() - 0.5) * px * 0.1
|
|
828
|
-
const s = px * (0.16 + rand() * 0.08)
|
|
829
|
-
const ink = css(pick(rand, inks))
|
|
830
|
-
ctx.fillStyle = ink
|
|
831
|
-
ctx.strokeStyle = ink
|
|
832
|
-
ctx.beginPath()
|
|
833
|
-
|
|
834
|
-
const shapes = [
|
|
835
|
-
() => {
|
|
836
|
-
ctx.moveTo(x - s * 1.2, y)
|
|
837
|
-
Array.from({ length: 13 }, (_, k) =>
|
|
838
|
-
ctx.lineTo(x - s * 1.2 + (k * s * 2.4) / 12, y + Math.sin(k * 1.1) * s * 0.4),
|
|
839
|
-
)
|
|
840
|
-
ctx.stroke()
|
|
841
|
-
},
|
|
842
|
-
() => {
|
|
843
|
-
const turn = rand() * Math.PI * 2
|
|
844
|
-
Array.from({ length: 3 }, (_, k) =>
|
|
845
|
-
ctx.lineTo(x + Math.cos(turn + (k * Math.PI * 2) / 3) * s, y + Math.sin(turn + (k * Math.PI * 2) / 3) * s),
|
|
846
|
-
)
|
|
847
|
-
ctx.fill()
|
|
848
|
-
},
|
|
849
|
-
() => {
|
|
850
|
-
Array.from({ length: 9 }, (_, k) => {
|
|
851
|
-
ctx.moveTo(x + ((k % 3) - 1) * s * 0.7 + s * 0.12, y + (Math.floor(k / 3) - 1) * s * 0.7)
|
|
852
|
-
ctx.arc(x + ((k % 3) - 1) * s * 0.7, y + (Math.floor(k / 3) - 1) * s * 0.7, s * 0.12, 0, Math.PI * 2)
|
|
853
|
-
})
|
|
854
|
-
ctx.fill()
|
|
855
|
-
},
|
|
856
|
-
() => {
|
|
857
|
-
ctx.moveTo(x - s * 1.1, y + s * 0.3)
|
|
858
|
-
Array.from({ length: 5 }, (_, k) => ctx.lineTo(x - s * 1.1 + ((k + 1) * s * 2.2) / 5, y + (k % 2 ? 0.3 : -0.3) * s))
|
|
859
|
-
ctx.stroke()
|
|
860
|
-
},
|
|
861
|
-
() => {
|
|
862
|
-
ctx.arc(x, y, s * 0.8, 0, Math.PI * 2)
|
|
863
|
-
ctx.stroke()
|
|
864
|
-
},
|
|
865
|
-
() => {
|
|
866
|
-
ctx.arc(x, y + s * 0.3, s * 0.9, Math.PI, Math.PI * 2)
|
|
867
|
-
ctx.fill()
|
|
868
|
-
},
|
|
869
|
-
]
|
|
870
|
-
|
|
871
|
-
shapes[kinds[i]]()
|
|
872
|
-
})
|
|
873
|
-
},
|
|
874
|
-
},
|
|
875
|
-
{
|
|
876
|
-
id: "deco",
|
|
877
|
-
name: "Art Deco",
|
|
878
|
-
family: "Art movements",
|
|
879
|
-
label: "Metallic sunburst fans, a trio of fans, a ziggurat or a corner fan on a dark lacquer",
|
|
880
|
-
resolve: (random) => {
|
|
881
|
-
const r = random("deco")
|
|
882
|
-
|
|
883
|
-
return {
|
|
884
|
-
layout: int(r, 0, 3),
|
|
885
|
-
ground: pick(r, DECO_GROUNDS),
|
|
886
|
-
metal: pick(r, DECO_METALS),
|
|
887
|
-
rays: int(r, 7, 13),
|
|
888
|
-
arcs: int(r, 2, 3),
|
|
889
|
-
}
|
|
890
|
-
},
|
|
891
|
-
vector: (ctx, px, p) => {
|
|
892
|
-
const ground = p.ground === 0xf1e9d8 ? shade(p.metal, 0.45) : p.metal
|
|
893
|
-
ctx.fillStyle = css(p.ground)
|
|
894
|
-
ctx.fillRect(0, 0, px, px)
|
|
895
|
-
ctx.strokeStyle = css(ground)
|
|
896
|
-
ctx.fillStyle = css(ground)
|
|
897
|
-
ctx.lineWidth = px * 0.035
|
|
898
|
-
|
|
899
|
-
const fan = (cx: number, cy: number, radius: number, from: number, to: number, filled: boolean) => {
|
|
900
|
-
Array.from({ length: p.rays }, (_, k) => {
|
|
901
|
-
const angle = from + ((to - from) * (k + 0.5)) / p.rays
|
|
902
|
-
ctx.beginPath()
|
|
903
|
-
ctx.moveTo(cx + Math.cos(angle) * radius * 0.3, cy + Math.sin(angle) * radius * 0.3)
|
|
904
|
-
ctx.lineTo(cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius)
|
|
905
|
-
ctx.stroke()
|
|
906
|
-
})
|
|
907
|
-
Array.from({ length: p.arcs }, (_, k) => {
|
|
908
|
-
ctx.beginPath()
|
|
909
|
-
ctx.arc(cx, cy, radius * (1 - k * 0.22), from, to)
|
|
910
|
-
ctx.stroke()
|
|
911
|
-
})
|
|
912
|
-
ctx.beginPath()
|
|
913
|
-
ctx.moveTo(cx, cy)
|
|
914
|
-
ctx.arc(cx, cy, radius * 0.3, from, to)
|
|
915
|
-
ctx.closePath()
|
|
916
|
-
|
|
917
|
-
if (filled) ctx.fill()
|
|
918
|
-
|
|
919
|
-
if (!filled) ctx.stroke()
|
|
920
|
-
}
|
|
921
|
-
|
|
922
|
-
const layouts = [
|
|
923
|
-
() => fan(px / 2, px * 0.92, px * 0.78, Math.PI, Math.PI * 2, true),
|
|
924
|
-
() => {
|
|
925
|
-
fan(px * 0.2, px * 0.95, px * 0.38, Math.PI, Math.PI * 2, false)
|
|
926
|
-
fan(px * 0.8, px * 0.95, px * 0.38, Math.PI, Math.PI * 2, false)
|
|
927
|
-
fan(px / 2, px * 0.95, px * 0.56, Math.PI, Math.PI * 2, true)
|
|
928
|
-
},
|
|
929
|
-
() => {
|
|
930
|
-
const steps = 4
|
|
931
|
-
Array.from({ length: steps }, (_, k) => {
|
|
932
|
-
const w = px * (0.7 - k * 0.15)
|
|
933
|
-
ctx.fillRect((px - w) / 2, px * (0.95 - (k + 1) * 0.1), w, px * 0.1 + 1)
|
|
934
|
-
})
|
|
935
|
-
fan(px / 2, px * 0.55, px * 0.5, Math.PI * 1.08, Math.PI * 1.92, false)
|
|
936
|
-
},
|
|
937
|
-
() => {
|
|
938
|
-
Array.from({ length: p.rays }, (_, k) => {
|
|
939
|
-
if (k % 2) return
|
|
940
|
-
const a = -Math.PI / 2 + ((Math.PI / 2) * k) / p.rays
|
|
941
|
-
const b = -Math.PI / 2 + ((Math.PI / 2) * (k + 1)) / p.rays
|
|
942
|
-
ctx.beginPath()
|
|
943
|
-
ctx.moveTo(0, px)
|
|
944
|
-
ctx.arc(0, px, px * 1.1, a, b)
|
|
945
|
-
ctx.closePath()
|
|
946
|
-
ctx.fill()
|
|
947
|
-
})
|
|
948
|
-
ctx.beginPath()
|
|
949
|
-
ctx.arc(0, px, px * 0.45, -Math.PI / 2, 0)
|
|
950
|
-
ctx.lineTo(0, px)
|
|
951
|
-
ctx.fillStyle = css(p.ground)
|
|
952
|
-
ctx.fill()
|
|
953
|
-
ctx.stroke()
|
|
954
|
-
},
|
|
955
|
-
]
|
|
956
|
-
|
|
957
|
-
layouts[p.layout]()
|
|
958
|
-
},
|
|
959
|
-
},
|
|
960
|
-
{
|
|
961
|
-
id: "kandinsky",
|
|
962
|
-
name: "Kandinsky",
|
|
963
|
-
family: "Art movements",
|
|
964
|
-
label: "Four squares of two to four loose concentric circles in clashing colours",
|
|
965
|
-
resolve: (random) => {
|
|
966
|
-
const r = random("kandinsky")
|
|
967
|
-
|
|
968
|
-
return { seed: seed(r), tiles: 2, rings: int(r, 2, 4) }
|
|
969
|
-
},
|
|
970
|
-
vector: (ctx, px, p) => {
|
|
971
|
-
const rand = mulberry32(p.seed)
|
|
972
|
-
const size = px / p.tiles
|
|
973
|
-
|
|
974
|
-
for (let i = 0; i < p.tiles; i++)
|
|
975
|
-
for (let j = 0; j < p.tiles; j++) {
|
|
976
|
-
const order = shuffle(rand, KANDINSKY)
|
|
977
|
-
const cx = (i + 0.5) * size
|
|
978
|
-
const cy = (j + 0.5) * size
|
|
979
|
-
ctx.fillStyle = css(order[0])
|
|
980
|
-
ctx.fillRect(i * size - 0.5, j * size - 0.5, size + 1, size + 1)
|
|
981
|
-
|
|
982
|
-
for (let k = 0; k < p.rings; k++) {
|
|
983
|
-
const radius = size * 0.44 * (1 - k / (p.rings + 0.4)) * (0.9 + rand() * 0.15)
|
|
984
|
-
ctx.beginPath()
|
|
985
|
-
ctx.arc(cx + (rand() - 0.5) * size * 0.06, cy + (rand() - 0.5) * size * 0.06, radius, 0, Math.PI * 2)
|
|
986
|
-
ctx.fillStyle = css(order[k + 1])
|
|
987
|
-
ctx.fill()
|
|
988
|
-
}
|
|
989
|
-
}
|
|
990
|
-
},
|
|
991
|
-
},
|
|
992
|
-
{
|
|
993
|
-
id: "albers",
|
|
994
|
-
name: "Albers",
|
|
995
|
-
family: "Art movements",
|
|
996
|
-
label: "Homage to the Square: three or four nested squares sinking toward the bottom edge",
|
|
997
|
-
resolve: (random) => {
|
|
998
|
-
const r = random("albers")
|
|
999
|
-
const hue = r()
|
|
1000
|
-
const count = int(r, 3, 4)
|
|
1001
|
-
const drift = range(r, -0.08, 0.08)
|
|
1002
|
-
const rising = r() < 0.6
|
|
1003
|
-
const s = range(r, 0.35, 0.8)
|
|
1004
|
-
|
|
1005
|
-
return {
|
|
1006
|
-
count,
|
|
1007
|
-
...prefixed(
|
|
1008
|
-
"a",
|
|
1009
|
-
Array.from({ length: count }, (_, k) => {
|
|
1010
|
-
const l = rising ? 0.28 + k * 0.17 : 0.82 - k * 0.15
|
|
1011
|
-
|
|
1012
|
-
return hsl(hue + drift * k, s, l)
|
|
1013
|
-
}),
|
|
1014
|
-
),
|
|
1015
|
-
}
|
|
1016
|
-
},
|
|
1017
|
-
vector: (ctx, px, p) => {
|
|
1018
|
-
const squares = colors(p, "a", p.count)
|
|
1019
|
-
const step = 1 / (p.count + 1)
|
|
1020
|
-
|
|
1021
|
-
squares.forEach((color, k) => {
|
|
1022
|
-
const size = px * (1 - k * step)
|
|
1023
|
-
const bottom = px * k * step * 0.25
|
|
1024
|
-
ctx.fillStyle = css(color)
|
|
1025
|
-
ctx.fillRect((px - size) / 2, px - bottom - size, size, size)
|
|
1026
|
-
})
|
|
1027
|
-
},
|
|
1028
|
-
},
|
|
1029
|
-
{
|
|
1030
|
-
id: "rothko",
|
|
1031
|
-
name: "Rothko",
|
|
1032
|
-
family: "Art movements",
|
|
1033
|
-
label: "Two or three soft-edged colour fields floating on a stained ground",
|
|
1034
|
-
resolve: (random) => {
|
|
1035
|
-
const r = random("rothko")
|
|
1036
|
-
const set = r() < 0.75 ? pick(r, ROTHKO) : [shade(hsl(r(), 0.5, 0.3), 1), hsl(r(), 0.6, 0.5), hsl(r(), 0.5, 0.25), hsl(r(), 0.7, 0.6)]
|
|
1037
|
-
const count = r() < 0.6 ? 2 : 3
|
|
1038
|
-
|
|
1039
|
-
return {
|
|
1040
|
-
grid: 32,
|
|
1041
|
-
count,
|
|
1042
|
-
split: range(r, 0.38, 0.62),
|
|
1043
|
-
margin: range(r, 3, 4.5),
|
|
1044
|
-
...prefixed("f", set),
|
|
1045
|
-
seedX: r() * 40,
|
|
1046
|
-
seedY: r() * 40,
|
|
1047
|
-
}
|
|
1048
|
-
},
|
|
1049
|
-
paint: (pixels, p) => {
|
|
1050
|
-
const [ground, ...fields] = colors(p, "f", 4)
|
|
1051
|
-
const gap = 2.2
|
|
1052
|
-
const top = p.margin
|
|
1053
|
-
const bottom = 32 - p.margin
|
|
1054
|
-
const inner = bottom - top - gap * (p.count - 1)
|
|
1055
|
-
const heights = p.count === 2 ? [inner * p.split, inner * (1 - p.split)] : [inner * 0.3, inner * 0.22, inner * 0.48]
|
|
1056
|
-
|
|
1057
|
-
const bands = heights.map((height, i) => {
|
|
1058
|
-
const y0 = top + heights.slice(0, i).reduce((sum, h) => sum + h, 0) + gap * i
|
|
1059
|
-
|
|
1060
|
-
return { y0, y1: y0 + height, color: fields[i] }
|
|
1061
|
-
})
|
|
1062
|
-
|
|
1063
|
-
pixels.each((x, y) => {
|
|
1064
|
-
const n = fbm(x * 0.25 + p.seedX, y * 0.25 + p.seedY)
|
|
1065
|
-
const X = x + 0.5 + (n - 0.5) * 1.6
|
|
1066
|
-
const Y = y + 0.5 + (n - 0.5) * 1.6
|
|
1067
|
-
const stained = shade(ground, 0.88 + n * 0.22)
|
|
1068
|
-
|
|
1069
|
-
return bands.reduce((color, band) => {
|
|
1070
|
-
const edge = Math.min(X - p.margin + 0.6, 32 - p.margin + 0.6 - X, Y - band.y0, band.y1 - Y)
|
|
1071
|
-
|
|
1072
|
-
return mix(color, shade(band.color, 0.9 + n * 0.18), smoothstep(-0.8, 1.4, edge))
|
|
1073
|
-
}, stained)
|
|
1074
|
-
})
|
|
1075
|
-
},
|
|
1076
|
-
},
|
|
1077
|
-
]
|
|
1078
|
-
|
|
1079
|
-
export const CRAFT: Definition[] = [...TEXTILES, ...PRINT, ...ART]
|
|
1
|
+
// Project icon styles from craft: textiles, printmaking and twentieth-century art. See procedural.ts for the contract.
|
|
2
|
+
|
|
3
|
+
import { mulberry32 } from "./generated"
|
|
4
|
+
import {
|
|
5
|
+
clamp01,
|
|
6
|
+
colors,
|
|
7
|
+
css,
|
|
8
|
+
dither,
|
|
9
|
+
fbm,
|
|
10
|
+
grain,
|
|
11
|
+
hsl,
|
|
12
|
+
int,
|
|
13
|
+
legible,
|
|
14
|
+
luma,
|
|
15
|
+
mix,
|
|
16
|
+
multiply,
|
|
17
|
+
palette,
|
|
18
|
+
pick,
|
|
19
|
+
prefixed,
|
|
20
|
+
range,
|
|
21
|
+
retry,
|
|
22
|
+
seed,
|
|
23
|
+
shade,
|
|
24
|
+
shuffle,
|
|
25
|
+
smoothstep,
|
|
26
|
+
tint,
|
|
27
|
+
type Definition,
|
|
28
|
+
} from "./procedural-kit"
|
|
29
|
+
|
|
30
|
+
// Red, navy, green, yellow, white and the like: five threads each, as real setts use.
|
|
31
|
+
const TARTANS = [
|
|
32
|
+
[0xb81d2b, 0x1b2a4a, 0x1e5631, 0xf2c230, 0xf4f1ea],
|
|
33
|
+
[0x1b2a4a, 0x1e4d2b, 0x101010, 0x2b3f6b, 0x3d6b3d],
|
|
34
|
+
[0xf4f1ea, 0x1b2a4a, 0x1e5631, 0xf2c230, 0x101010],
|
|
35
|
+
[0xf2c230, 0x1e5631, 0xb81d2b, 0x101010, 0xf4f1ea],
|
|
36
|
+
[0xc9a77c, 0x161616, 0xf4f1ea, 0xa6192e, 0x8a6b4a],
|
|
37
|
+
[0xe8a0b4, 0x6b2d5c, 0xf4f1ea, 0x2a9d8f, 0xffd166],
|
|
38
|
+
[0x7a8c9e, 0x2f3e4f, 0xe6e2d6, 0xc44536, 0x51606f],
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
// Ink, then ground.
|
|
42
|
+
const HOUNDSTOOTH = [
|
|
43
|
+
[0x161616, 0xf2efe6],
|
|
44
|
+
[0x4a2f1f, 0xe9dcc3],
|
|
45
|
+
[0x1b2a4a, 0xf4f1ea],
|
|
46
|
+
[0x8f1d21, 0x161616],
|
|
47
|
+
[0x2d3a2e, 0xd9cfb4],
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
const RISO = [0xff48b0, 0x0078bf, 0xffe800, 0x00a95c, 0xff6c2f, 0x765ba7, 0x00838a, 0xf15060, 0x5ec8e5, 0x3255a4]
|
|
51
|
+
|
|
52
|
+
const PAPERS = [0xf5f0e6, 0xfffcf2, 0xe8dcc2, 0xf3ece0]
|
|
53
|
+
|
|
54
|
+
const INDIGO = [0x1b2a55, 0x22315e, 0x141c33, 0x7a3f22, 0x2b2b2e]
|
|
55
|
+
|
|
56
|
+
const POP = [0xff2d6f, 0xffd60a, 0x00b4d8, 0x8338ec, 0x06d6a0, 0xff7b00, 0x111111, 0xf8f4ec, 0x3a86ff]
|
|
57
|
+
|
|
58
|
+
// Six-by-six motifs for the screenprint, top row in the high bits.
|
|
59
|
+
const MOTIFS = [
|
|
60
|
+
[0b010010, 0b111111, 0b111111, 0b111111, 0b011110, 0b001100],
|
|
61
|
+
[0b001100, 0b001100, 0b111111, 0b011110, 0b011110, 0b110011],
|
|
62
|
+
[0b011110, 0b101101, 0b111111, 0b101101, 0b110011, 0b011110],
|
|
63
|
+
[0b000110, 0b001100, 0b011110, 0b001100, 0b011000, 0b010000],
|
|
64
|
+
[0b001100, 0b001100, 0b011110, 0b111111, 0b111111, 0b011110],
|
|
65
|
+
[0b010010, 0b110011, 0b001100, 0b001100, 0b110011, 0b010010],
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
const DE_STIJL = [0xd7261e, 0x1d3f9a, 0xf6cf1a]
|
|
69
|
+
|
|
70
|
+
const MEMPHIS_GROUNDS = [0xffe3ec, 0xfff4c2, 0xd9f2ef, 0xe6e1ff, 0x1a1a1a]
|
|
71
|
+
|
|
72
|
+
const MEMPHIS_INKS = [0xff5fa2, 0xffcd3c, 0x2ec4b6, 0x3a5bff, 0x111111, 0xff7a3d]
|
|
73
|
+
|
|
74
|
+
const DECO_GROUNDS = [0x101418, 0x0e2a24, 0x1b1f3b, 0x2a0f1a, 0xf1e9d8]
|
|
75
|
+
|
|
76
|
+
const DECO_METALS = [0xd4af37, 0xc9c9c9, 0xe0a984, 0x7fd1b9]
|
|
77
|
+
|
|
78
|
+
const KANDINSKY = [0xe0a526, 0xc8323a, 0x24479a, 0x3a8a4f, 0x161616, 0xefe3c8, 0x6b3f8f, 0xe86a2b, 0xe58fb0]
|
|
79
|
+
|
|
80
|
+
// Ground, then up to three fields.
|
|
81
|
+
const ROTHKO = [
|
|
82
|
+
[0x5a1a1a, 0xd9472b, 0x2b0e0e, 0xe8a33d],
|
|
83
|
+
[0x1d2b3a, 0x2f5d62, 0x0d1a24, 0x5e8b7e],
|
|
84
|
+
[0xd96b2b, 0xf2c14e, 0xb3311f, 0xf6e0a6],
|
|
85
|
+
[0x2a1a2e, 0x6b2d5c, 0x111111, 0xa2456b],
|
|
86
|
+
[0x8a8a83, 0x2a2a2a, 0xcfcac0, 0x4a4a4a],
|
|
87
|
+
[0x6e1e2b, 0x1d1d3a, 0xcf3b2c, 0x2b1a14],
|
|
88
|
+
[0x3d5a80, 0x98c1d9, 0x293241, 0xe0fbfc],
|
|
89
|
+
]
|
|
90
|
+
|
|
91
|
+
const TEXTILES: Definition[] = [
|
|
92
|
+
{
|
|
93
|
+
id: "tartan",
|
|
94
|
+
name: "Tartan",
|
|
95
|
+
family: "Textiles",
|
|
96
|
+
label: "A mirrored sett of three to five stripes, woven in 2/2 twill; it slides on hover",
|
|
97
|
+
animated: true,
|
|
98
|
+
resolve: (random) => {
|
|
99
|
+
const r = random("tartan")
|
|
100
|
+
const threads = r() < 0.55 ? pick(r, TARTANS) : colors(palette(random("palette")))
|
|
101
|
+
const count = int(r, 3, 5)
|
|
102
|
+
|
|
103
|
+
const order = retry(
|
|
104
|
+
() => Array.from({ length: count }, () => Math.floor(r() * 5)),
|
|
105
|
+
(list) => list.every((color, i) => i === 0 || color !== list[i - 1]),
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
grid: r() < 0.6 ? 16 : 24,
|
|
110
|
+
count,
|
|
111
|
+
twill: r() < 0.5 ? 1 : -1,
|
|
112
|
+
...prefixed(
|
|
113
|
+
"s",
|
|
114
|
+
order.map((i) => threads[i]),
|
|
115
|
+
),
|
|
116
|
+
...prefixed(
|
|
117
|
+
"w",
|
|
118
|
+
order.map((_, i) => (i === 0 ? int(r, 3, 6) : r() < 0.35 ? 1 : int(r, 2, 4))),
|
|
119
|
+
),
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
paint: (pixels, p, t) => {
|
|
123
|
+
const stripes = colors(p, "s", p.count)
|
|
124
|
+
const widths = colors(p, "w", p.count)
|
|
125
|
+
const period = widths.reduce((sum, width) => sum + width, 0)
|
|
126
|
+
const shift = Math.floor(t * 4)
|
|
127
|
+
|
|
128
|
+
const thread = (i: number) => {
|
|
129
|
+
const k = (((i + shift) % (period * 2)) + period * 2) % (period * 2)
|
|
130
|
+
const along = k < period ? k : period * 2 - 1 - k
|
|
131
|
+
const index = widths.findIndex((_, j) => widths.slice(0, j + 1).reduce((sum, w) => sum + w, 0) > along)
|
|
132
|
+
|
|
133
|
+
return stripes[index]
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
pixels.each((x, y) => (((x + p.twill * y) & 3) < 2 ? shade(thread(x), 0.9) : thread(y)))
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
id: "houndstooth",
|
|
141
|
+
name: "Houndstooth",
|
|
142
|
+
family: "Textiles",
|
|
143
|
+
label: "Four-and-four threads in a 2/2 twill, one and a half to three teeth across, sometimes overchecked",
|
|
144
|
+
animated: true,
|
|
145
|
+
resolve: (random) => {
|
|
146
|
+
const r = random("houndstooth")
|
|
147
|
+
const all = colors(palette(random("palette")))
|
|
148
|
+
const ink = legible(r, all.slice(1), all[0])
|
|
149
|
+
const [color, ground] = r() < 0.5 ? pick(r, HOUNDSTOOTH) : r() < 0.6 ? [ink, all[0]] : [all[0], ink]
|
|
150
|
+
|
|
151
|
+
const [grid, unit] = pick(r, [
|
|
152
|
+
[16, 1],
|
|
153
|
+
[24, 1],
|
|
154
|
+
[16, 1],
|
|
155
|
+
[12, 1],
|
|
156
|
+
])
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
grid,
|
|
160
|
+
unit,
|
|
161
|
+
ink: color,
|
|
162
|
+
ground,
|
|
163
|
+
over: r() < 0.35 ? 1 : 0,
|
|
164
|
+
overColor: pick(r, all.slice(1).filter((c) => c !== color && c !== ground)),
|
|
165
|
+
dir: r() < 0.5 ? 1 : -1,
|
|
166
|
+
ox: int(r, 0, 7),
|
|
167
|
+
oy: int(r, 0, 7),
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
paint: (pixels, p, t) => {
|
|
171
|
+
const shift = Math.floor(t * 3)
|
|
172
|
+
|
|
173
|
+
pixels.each((x, y) => {
|
|
174
|
+
const i = Math.floor(x / p.unit) + p.ox + shift
|
|
175
|
+
const j = Math.floor(y / p.unit) + p.oy
|
|
176
|
+
const warp = (i & 7) < 4 ? p.ink : p.ground
|
|
177
|
+
const weft = (j & 7) < 4 ? p.ink : p.ground
|
|
178
|
+
const color = ((i + p.dir * j) & 3) < 2 ? warp : weft
|
|
179
|
+
|
|
180
|
+
return p.over && ((i & 15) === 9 || (j & 15) === 9) ? mix(color, p.overColor, 0.7) : color
|
|
181
|
+
})
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
id: "gingham",
|
|
186
|
+
name: "Gingham",
|
|
187
|
+
family: "Textiles",
|
|
188
|
+
label: "Even checks with a half-tone where bands cross, or a buffalo check or windowpane",
|
|
189
|
+
resolve: (random) => {
|
|
190
|
+
const r = random("gingham")
|
|
191
|
+
const all = colors(palette(random("palette")))
|
|
192
|
+
|
|
193
|
+
return {
|
|
194
|
+
grid: 16,
|
|
195
|
+
size: int(r, 2, 4),
|
|
196
|
+
kind: pick(r, [0, 0, 0, 1, 2]),
|
|
197
|
+
ink: legible(r, all.slice(1), all[0]),
|
|
198
|
+
paper: r() < 0.7 ? all[0] : 0xffffff,
|
|
199
|
+
ox: int(r, 0, 3),
|
|
200
|
+
oy: int(r, 0, 3),
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
paint: (pixels, p) => {
|
|
204
|
+
pixels.each((x, y) => {
|
|
205
|
+
const a = Math.floor((x + p.ox) / p.size) % 2 === 0
|
|
206
|
+
const b = Math.floor((y + p.oy) / p.size) % 2 === 0
|
|
207
|
+
const texture = (x + y) % 2 ? 0.93 : 1
|
|
208
|
+
|
|
209
|
+
if (p.kind === 1) {
|
|
210
|
+
if (a && b) return shade(mix(0x111111, p.ink, 0.25), 1)
|
|
211
|
+
|
|
212
|
+
return a || b ? shade(p.ink, 0.62 * texture) : p.ink
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (p.kind === 2) {
|
|
216
|
+
const period = p.size * 2 + 2
|
|
217
|
+
const line = (x + p.ox) % period === 0 || (y + p.oy) % period === 0
|
|
218
|
+
const thin = (x + p.ox) % period === p.size + 1 || (y + p.oy) % period === p.size + 1
|
|
219
|
+
|
|
220
|
+
return line ? p.ink : thin ? mix(p.paper, p.ink, 0.3) : p.paper
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (a && b) return p.ink
|
|
224
|
+
|
|
225
|
+
return a || b ? shade(mix(p.paper, p.ink, 0.5), texture) : p.paper
|
|
226
|
+
})
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
id: "argyle",
|
|
231
|
+
name: "Argyle",
|
|
232
|
+
family: "Textiles",
|
|
233
|
+
label: "Harlequin diamonds with a dashed or solid overcheck through their centres",
|
|
234
|
+
resolve: (random) => {
|
|
235
|
+
const r = random("argyle")
|
|
236
|
+
const all = shuffle(r, colors(palette(random("palette"))))
|
|
237
|
+
const [a, b] = all
|
|
238
|
+
|
|
239
|
+
return {
|
|
240
|
+
grid: 16,
|
|
241
|
+
across: pick(r, [1, 2, 2]),
|
|
242
|
+
tall: pick(r, [1, 1.3, 1.6]),
|
|
243
|
+
oy: range(r, 0, 4),
|
|
244
|
+
dashed: r() < 0.6 ? 1 : 0,
|
|
245
|
+
a,
|
|
246
|
+
b,
|
|
247
|
+
line: legible(r, all.slice(2), mix(a, b, 0.5)),
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
paint: (pixels, p) => {
|
|
251
|
+
const w = 16 / p.across
|
|
252
|
+
const h = w * p.tall
|
|
253
|
+
const scale = 1 / Math.hypot(1 / w, 1 / h)
|
|
254
|
+
|
|
255
|
+
pixels.each((x, y) => {
|
|
256
|
+
const u = (x + 0.5) / w + (y + 0.5 - p.oy) / h + 0.5
|
|
257
|
+
const v = (x + 0.5) / w - (y + 0.5 - p.oy) / h + 0.5
|
|
258
|
+
const base = (Math.floor(u) + Math.floor(v)) & 1 ? p.b : p.a
|
|
259
|
+
const du = Math.abs((((u % 1) + 1) % 1) - 0.5) * scale
|
|
260
|
+
const dv = Math.abs((((v % 1) + 1) % 1) - 0.5) * scale
|
|
261
|
+
const dash = !p.dashed || (x + y) % 3 !== 2
|
|
262
|
+
|
|
263
|
+
return (du < 0.55 || dv < 0.55) && dash ? p.line : base
|
|
264
|
+
})
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
id: "zigzag",
|
|
269
|
+
name: "Zigzag",
|
|
270
|
+
family: "Textiles",
|
|
271
|
+
label: "Chevron stripes, or bargello flame-stitch peaks in graded shades; they climb on hover",
|
|
272
|
+
animated: true,
|
|
273
|
+
resolve: (random) => {
|
|
274
|
+
const r = random("zigzag")
|
|
275
|
+
const all = colors(palette(random("palette")))
|
|
276
|
+
const flame = r() < 0.4 ? 1 : 0
|
|
277
|
+
const [from, to] = shuffle(r, all.slice(1))
|
|
278
|
+
const count = int(r, 3, 4)
|
|
279
|
+
|
|
280
|
+
return {
|
|
281
|
+
grid: 16,
|
|
282
|
+
flame,
|
|
283
|
+
seed: seed(r),
|
|
284
|
+
period: pick(r, [4, 8, 8, 16]),
|
|
285
|
+
width: int(r, 2, 3),
|
|
286
|
+
vertical: r() < 0.25 ? 1 : 0,
|
|
287
|
+
count: flame ? 5 : count,
|
|
288
|
+
...prefixed(
|
|
289
|
+
"z",
|
|
290
|
+
flame
|
|
291
|
+
? [shade(from, 0.6), from, mix(from, to, 0.5), to, tint(to, 0.5)]
|
|
292
|
+
: [all[0], ...shuffle(r, all.slice(1))].slice(0, count),
|
|
293
|
+
),
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
paint: (pixels, p, t) => {
|
|
297
|
+
const cycle = colors(p, "z", p.count)
|
|
298
|
+
const rand = mulberry32(p.seed)
|
|
299
|
+
const walk = Array.from({ length: 16 }).reduce<number[]>(
|
|
300
|
+
(list) => [...list, (list[list.length - 1] ?? 0) + pick(rand, [-2, -1, 1, 1, 2, 2])],
|
|
301
|
+
[],
|
|
302
|
+
)
|
|
303
|
+
const shift = t * 4
|
|
304
|
+
|
|
305
|
+
pixels.each((cx, cy) => {
|
|
306
|
+
const x = p.vertical ? cy : cx
|
|
307
|
+
const y = p.vertical ? cx : cy
|
|
308
|
+
const k = (x % p.period) / p.period
|
|
309
|
+
const offset = p.flame ? walk[x] : Math.abs(k - 0.5) * p.period
|
|
310
|
+
const band = Math.floor((y + offset + shift) / p.width)
|
|
311
|
+
|
|
312
|
+
return cycle[((band % p.count) + p.count) % p.count]
|
|
313
|
+
})
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
id: "seigaiha",
|
|
318
|
+
name: "Seigaiha",
|
|
319
|
+
family: "Textiles",
|
|
320
|
+
label: "Overlapping wave scales of three or four rings, one and a half to two across; the rings ripple on hover",
|
|
321
|
+
animated: true,
|
|
322
|
+
resolve: (random) => {
|
|
323
|
+
const r = random("seigaiha")
|
|
324
|
+
const all = colors(palette(random("palette")))
|
|
325
|
+
const classic = r() < 0.35
|
|
326
|
+
const [a, b, c] = shuffle(r, all.slice(1))
|
|
327
|
+
|
|
328
|
+
return {
|
|
329
|
+
across: pick(r, [1.5, 2, 2]),
|
|
330
|
+
rings: int(r, 3, 4),
|
|
331
|
+
lines: r() < 0.4 ? 1 : 0,
|
|
332
|
+
accent: r() < 0.4 ? 1 : 0,
|
|
333
|
+
ground: classic ? 0x1d3557 : a,
|
|
334
|
+
ink: classic ? 0xf4efe6 : legible(r, [b, c, all[0]], a),
|
|
335
|
+
third: c,
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
vector: (ctx, px, p, t) => {
|
|
339
|
+
const radius = px / p.across / 2
|
|
340
|
+
const step = radius * 0.5
|
|
341
|
+
const phase = (t * 0.8) % 1
|
|
342
|
+
|
|
343
|
+
for (let j = -1; j * step < px + radius; j++)
|
|
344
|
+
for (let i = -1; i * radius * 2 < px + radius * 2; i++) {
|
|
345
|
+
const cx = i * radius * 2 + (j % 2 ? radius : 0)
|
|
346
|
+
const cy = j * step
|
|
347
|
+
|
|
348
|
+
for (let k = 0; k < p.rings; k++) {
|
|
349
|
+
const ring = Math.max(0, radius * (1 - (k - (k ? phase : 0)) / p.rings))
|
|
350
|
+
ctx.beginPath()
|
|
351
|
+
ctx.arc(cx, cy, ring, 0, Math.PI * 2)
|
|
352
|
+
|
|
353
|
+
if (p.lines) {
|
|
354
|
+
ctx.fillStyle = css(p.ground)
|
|
355
|
+
ctx.fill()
|
|
356
|
+
ctx.strokeStyle = css(p.accent && k === p.rings - 1 ? p.third : p.ink)
|
|
357
|
+
ctx.lineWidth = radius * 0.1
|
|
358
|
+
ctx.stroke()
|
|
359
|
+
continue
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
ctx.fillStyle = css(k % 2 ? p.ink : p.accent && k === 2 ? p.third : p.ground)
|
|
363
|
+
ctx.fill()
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
id: "tie-dye",
|
|
370
|
+
name: "Tie-dye",
|
|
371
|
+
family: "Textiles",
|
|
372
|
+
label: "A dye spiral, bullseye or crumple with bleeding bands and white crinkles",
|
|
373
|
+
resolve: (random) => {
|
|
374
|
+
const r = random("tie-dye")
|
|
375
|
+
const rainbow = r() < 0.55
|
|
376
|
+
const count = int(r, 4, 6)
|
|
377
|
+
const hue = r()
|
|
378
|
+
const inks = shuffle(r, colors(palette(random("palette"))).slice(1))
|
|
379
|
+
|
|
380
|
+
return {
|
|
381
|
+
grid: 32,
|
|
382
|
+
kind: pick(r, [0, 0, 1, 2]),
|
|
383
|
+
arms: int(r, 2, 5),
|
|
384
|
+
twist: range(r, 2, 6) * (r() < 0.5 ? -1 : 1),
|
|
385
|
+
cx: range(r, 10, 22),
|
|
386
|
+
cy: range(r, 10, 22),
|
|
387
|
+
seedX: r() * 40,
|
|
388
|
+
seedY: r() * 40,
|
|
389
|
+
count: rainbow ? count : 4,
|
|
390
|
+
...prefixed(
|
|
391
|
+
"d",
|
|
392
|
+
rainbow ? Array.from({ length: count }, (_, i) => hsl(hue + i / count, 0.85, 0.55)) : inks,
|
|
393
|
+
),
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
paint: (pixels, p) => {
|
|
397
|
+
const dyes = colors(p, "d", p.count)
|
|
398
|
+
|
|
399
|
+
pixels.each((x, y) => {
|
|
400
|
+
const dx = x + 0.5 - p.cx
|
|
401
|
+
const dy = y + 0.5 - p.cy
|
|
402
|
+
const d = Math.hypot(dx, dy) / 32
|
|
403
|
+
const wobble = fbm(x * 0.15 + p.seedX, y * 0.15 + p.seedY)
|
|
404
|
+
const angle = Math.atan2(dy, dx) / (Math.PI * 2)
|
|
405
|
+
|
|
406
|
+
const value =
|
|
407
|
+
p.kind === 0
|
|
408
|
+
? angle * p.arms + p.twist * Math.sqrt(d) + wobble * 0.5
|
|
409
|
+
: p.kind === 1
|
|
410
|
+
? d * 7 + wobble * 1.2 + Math.sin(angle * Math.PI * 2 * p.arms) * 0.15
|
|
411
|
+
: fbm(x * 0.09 + p.seedY, y * 0.09 + p.seedX) * p.count * 1.6
|
|
412
|
+
|
|
413
|
+
const band = Math.floor(value * (p.kind === 0 ? 1 : 1))
|
|
414
|
+
const along = value - band
|
|
415
|
+
const a = dyes[((band % p.count) + p.count) % p.count]
|
|
416
|
+
const b = dyes[(((band + 1) % p.count) + p.count) % p.count]
|
|
417
|
+
const color = mix(a, b, smoothstep(0.7, 1, along))
|
|
418
|
+
const crinkle = fbm(x * 0.6 + p.seedX * 2, y * 0.6 + p.seedY)
|
|
419
|
+
|
|
420
|
+
return crinkle > 0.74 ? mix(color, 0xffffff, 0.55) : color
|
|
421
|
+
})
|
|
422
|
+
},
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
id: "shibori",
|
|
426
|
+
name: "Shibori",
|
|
427
|
+
family: "Textiles",
|
|
428
|
+
label: "Resist-dyed indigo: clamped squares, circles or diamonds, pole-wrapped stripes or spider webs",
|
|
429
|
+
resolve: (random) => {
|
|
430
|
+
const r = random("shibori")
|
|
431
|
+
|
|
432
|
+
return {
|
|
433
|
+
grid: 32,
|
|
434
|
+
kind: pick(r, [0, 0, 1, 2]),
|
|
435
|
+
dye: pick(r, INDIGO),
|
|
436
|
+
cloth: pick(r, [0xeef0ee, 0xf2ead8, 0xe3e8ee]),
|
|
437
|
+
cells: pick(r, [2, 3, 4]),
|
|
438
|
+
shape: int(r, 0, 2),
|
|
439
|
+
angle: range(r, 0.3, 1.2) * (r() < 0.5 ? 1 : -1),
|
|
440
|
+
spacing: range(r, 3.5, 6),
|
|
441
|
+
centers: int(r, 1, 3),
|
|
442
|
+
seed: seed(r),
|
|
443
|
+
seedX: r() * 40,
|
|
444
|
+
seedY: r() * 40,
|
|
445
|
+
}
|
|
446
|
+
},
|
|
447
|
+
paint: (pixels, p) => {
|
|
448
|
+
const rand = mulberry32(p.seed)
|
|
449
|
+
const webs = Array.from({ length: p.centers }, () => ({
|
|
450
|
+
x: range(rand, 6, 26),
|
|
451
|
+
y: range(rand, 6, 26),
|
|
452
|
+
r: range(rand, 7, 12),
|
|
453
|
+
}))
|
|
454
|
+
const size = 32 / p.cells
|
|
455
|
+
|
|
456
|
+
pixels.each((x, y) => {
|
|
457
|
+
const n = fbm(x * 0.2 + p.seedX, y * 0.2 + p.seedY)
|
|
458
|
+
const kinds = [
|
|
459
|
+
() => {
|
|
460
|
+
const u = ((x + 0.5) % size) / size - 0.5
|
|
461
|
+
const v = ((y + 0.5) % size) / size - 0.5
|
|
462
|
+
const d = [Math.max(Math.abs(u), Math.abs(v)), Math.hypot(u, v), Math.abs(u) + Math.abs(v)][p.shape]
|
|
463
|
+
|
|
464
|
+
return smoothstep(0.32, 0.22, d + (n - 0.5) * 0.18)
|
|
465
|
+
},
|
|
466
|
+
() => {
|
|
467
|
+
const v = (x * Math.cos(p.angle) + y * Math.sin(p.angle)) / p.spacing + n * 1.4
|
|
468
|
+
|
|
469
|
+
return smoothstep(0.8, 0.97, Math.abs(Math.sin(v * Math.PI))) * smoothstep(0.25, 0.5, n)
|
|
470
|
+
},
|
|
471
|
+
() =>
|
|
472
|
+
Math.max(
|
|
473
|
+
...webs.map((web) => {
|
|
474
|
+
const d = Math.hypot(x + 0.5 - web.x, y + 0.5 - web.y)
|
|
475
|
+
const spoke = Math.abs(Math.sin(Math.atan2(y + 0.5 - web.y, x + 0.5 - web.x) * 6 + d * 0.15))
|
|
476
|
+
|
|
477
|
+
return d < web.r ? smoothstep(0.75, 0.98, spoke) * (1 - d / web.r) + (d < 1.6 ? 1 : 0) : 0
|
|
478
|
+
}),
|
|
479
|
+
),
|
|
480
|
+
() => {
|
|
481
|
+
const row = Math.round(y / p.spacing) * p.spacing
|
|
482
|
+
const stitch = Math.abs(y - row) < 0.8 && Math.floor(x / 2 + row) % 2 === 0
|
|
483
|
+
|
|
484
|
+
return stitch ? 0.85 : 0
|
|
485
|
+
},
|
|
486
|
+
]
|
|
487
|
+
|
|
488
|
+
const resist = clamp01(kinds[p.kind]())
|
|
489
|
+
const dyed = shade(p.dye, 0.85 + n * 0.3)
|
|
490
|
+
|
|
491
|
+
return [dyed, mix(dyed, p.cloth, 0.5), p.cloth][dither(resist, 3, x, y)]
|
|
492
|
+
})
|
|
493
|
+
},
|
|
494
|
+
},
|
|
495
|
+
]
|
|
496
|
+
|
|
497
|
+
const PRINT: Definition[] = [
|
|
498
|
+
{
|
|
499
|
+
id: "risograph",
|
|
500
|
+
name: "Risograph",
|
|
501
|
+
family: "Print",
|
|
502
|
+
label: "Two fluorescent inks, each a disc, stripes, half or ring, overprinted out of register with grain",
|
|
503
|
+
resolve: (random) => {
|
|
504
|
+
const r = random("riso")
|
|
505
|
+
const [a, b] = shuffle(r, RISO)
|
|
506
|
+
|
|
507
|
+
const layer = (prefix: string) =>
|
|
508
|
+
prefixed(prefix, [int(r, 0, 3), range(r, 0.3, 0.7), range(r, 0.3, 0.7), range(r, 0.3, 0.45), r() * Math.PI])
|
|
509
|
+
|
|
510
|
+
return {
|
|
511
|
+
grid: 32,
|
|
512
|
+
paper: pick(r, PAPERS),
|
|
513
|
+
a,
|
|
514
|
+
b,
|
|
515
|
+
...layer("a"),
|
|
516
|
+
...layer("b"),
|
|
517
|
+
mx: range(r, 0.8, 1.8) * (r() < 0.5 ? 1 : -1),
|
|
518
|
+
my: range(r, 0.8, 1.8) * (r() < 0.5 ? 1 : -1),
|
|
519
|
+
salt: r() * 100,
|
|
520
|
+
}
|
|
521
|
+
},
|
|
522
|
+
paint: (pixels, p) => {
|
|
523
|
+
const layer = (prefix: string, ox: number, oy: number) => {
|
|
524
|
+
const [kind, cx, cy, size, angle] = colors(p, prefix, 5)
|
|
525
|
+
const cos = Math.cos(angle)
|
|
526
|
+
const sin = Math.sin(angle)
|
|
527
|
+
const bands = 4 + size * 8
|
|
528
|
+
|
|
529
|
+
return (x: number, y: number) => {
|
|
530
|
+
const u = (x + ox) / 32 - cx
|
|
531
|
+
const v = (y + oy) / 32 - cy
|
|
532
|
+
const along = u * cos + v * sin
|
|
533
|
+
|
|
534
|
+
if (kind === 1) return Math.floor((along + 2) * bands) % 2
|
|
535
|
+
if (kind === 2) return along > 0 ? 1 : 0
|
|
536
|
+
const d = Math.hypot(u, v)
|
|
537
|
+
|
|
538
|
+
return (kind === 0 ? d < size : Math.abs(d - size) < size * 0.4) ? 1 : 0
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
const a = layer("a", 0.5, 0.5)
|
|
543
|
+
const b = layer("b", 0.5 + p.mx, 0.5 + p.my)
|
|
544
|
+
|
|
545
|
+
// Uneven coverage and speckle are properties of the paper, so both inks share them.
|
|
546
|
+
pixels.each((x, y) => {
|
|
547
|
+
const texture = (0.78 + 0.22 * fbm(x * 0.3 + 7, y * 0.3)) * (grain(x, y, p.salt) < 0.1 ? 0.3 : 1)
|
|
548
|
+
|
|
549
|
+
return multiply(multiply(p.paper, mix(0xffffff, p.a, a(x, y) * texture)), mix(0xffffff, p.b, b(x, y) * texture))
|
|
550
|
+
})
|
|
551
|
+
},
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
id: "halftone",
|
|
555
|
+
name: "Halftone",
|
|
556
|
+
family: "Print",
|
|
557
|
+
label: "A rotated dot screen of a gradient, sphere or wave, sometimes two screens overprinted",
|
|
558
|
+
resolve: (random) => {
|
|
559
|
+
const r = random("halftone")
|
|
560
|
+
const all = colors(palette(random("palette")))
|
|
561
|
+
const ink = legible(r, all.slice(1), all[0])
|
|
562
|
+
const field = int(r, 0, 3)
|
|
563
|
+
|
|
564
|
+
return {
|
|
565
|
+
cells: int(r, 6, 9),
|
|
566
|
+
angle: (pick(r, [15, 45, 75, 0]) * Math.PI) / 180,
|
|
567
|
+
field,
|
|
568
|
+
dir: r() * Math.PI * 2,
|
|
569
|
+
cx: range(r, 0.3, 0.7),
|
|
570
|
+
cy: range(r, 0.3, 0.7),
|
|
571
|
+
paper: all[0],
|
|
572
|
+
ink,
|
|
573
|
+
second: r() < 0.4 ? 1 : 0,
|
|
574
|
+
ink2: pick(
|
|
575
|
+
r,
|
|
576
|
+
all.slice(1).filter((color) => color !== ink),
|
|
577
|
+
),
|
|
578
|
+
}
|
|
579
|
+
},
|
|
580
|
+
vector: (ctx, px, p) => {
|
|
581
|
+
ctx.fillStyle = css(p.paper)
|
|
582
|
+
ctx.fillRect(0, 0, px, px)
|
|
583
|
+
|
|
584
|
+
const tone = (u: number, v: number, screen: number) => {
|
|
585
|
+
const dx = u - p.cx
|
|
586
|
+
const dy = v - p.cy
|
|
587
|
+
const along = dx * Math.cos(p.dir + screen * 2) + dy * Math.sin(p.dir + screen * 2)
|
|
588
|
+
|
|
589
|
+
const fields = [
|
|
590
|
+
() => along + 0.5,
|
|
591
|
+
() => 1 - Math.hypot(dx, dy) * 1.6,
|
|
592
|
+
() => {
|
|
593
|
+
const d = Math.hypot(dx, dy) / 0.34
|
|
594
|
+
|
|
595
|
+
return d > 1 ? 0.06 : 1 - (Math.sqrt(1 - Math.min(1, d * d)) * 0.6 + 0.25 - (dx + dy) * 0.7)
|
|
596
|
+
},
|
|
597
|
+
() => 0.5 + 0.5 * Math.sin(along * 14),
|
|
598
|
+
]
|
|
599
|
+
|
|
600
|
+
return clamp01(fields[p.field]())
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
const screens = p.second ? [0, 1] : [0]
|
|
604
|
+
ctx.globalCompositeOperation = "multiply"
|
|
605
|
+
screens.forEach((screen) => {
|
|
606
|
+
const cell = px / p.cells
|
|
607
|
+
const angle = p.angle + screen * (Math.PI / 6)
|
|
608
|
+
ctx.fillStyle = css(screen ? p.ink2 : p.ink)
|
|
609
|
+
|
|
610
|
+
for (let i = -p.cells; i < p.cells * 2; i++)
|
|
611
|
+
for (let j = -p.cells; j < p.cells * 2; j++) {
|
|
612
|
+
const lx = (i + 0.5) * cell
|
|
613
|
+
const ly = (j + 0.5) * cell
|
|
614
|
+
const x = px / 2 + (lx - px / 2) * Math.cos(angle) - (ly - px / 2) * Math.sin(angle)
|
|
615
|
+
const y = px / 2 + (lx - px / 2) * Math.sin(angle) + (ly - px / 2) * Math.cos(angle)
|
|
616
|
+
|
|
617
|
+
if (x < -cell || y < -cell || x > px + cell || y > px + cell) continue
|
|
618
|
+
const radius = Math.sqrt(tone(x / px, y / px, screen)) * cell * 0.62
|
|
619
|
+
|
|
620
|
+
if (radius < cell * 0.06) continue
|
|
621
|
+
ctx.beginPath()
|
|
622
|
+
ctx.arc(x, y, radius, 0, Math.PI * 2)
|
|
623
|
+
ctx.fill()
|
|
624
|
+
}
|
|
625
|
+
})
|
|
626
|
+
ctx.globalCompositeOperation = "source-over"
|
|
627
|
+
},
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
id: "linocut",
|
|
631
|
+
name: "Linocut",
|
|
632
|
+
family: "Print",
|
|
633
|
+
label: "A sun, peak, moon or hill left standing in paper, with gouged lines that shorten away from it",
|
|
634
|
+
resolve: (random) => {
|
|
635
|
+
const r = random("linocut")
|
|
636
|
+
|
|
637
|
+
return {
|
|
638
|
+
grid: 24,
|
|
639
|
+
motif: int(r, 0, 3),
|
|
640
|
+
mx: range(r, 8, 16),
|
|
641
|
+
my: range(r, 7, 12),
|
|
642
|
+
size: range(r, 4.5, 6.5),
|
|
643
|
+
spacing: pick(r, [3, 3, 4]),
|
|
644
|
+
horizon: int(r, 16, 19),
|
|
645
|
+
ink: pick(r, [0x161616, 0x1d2b4f, 0x5a1a1a, 0x1f3b2c, 0x3a2a4f]),
|
|
646
|
+
paper: pick(r, [0xf2ead8, 0xf6f1e7, 0xe9d8b4, 0xf0d9c8]),
|
|
647
|
+
seedX: r() * 40,
|
|
648
|
+
seedY: r() * 40,
|
|
649
|
+
}
|
|
650
|
+
},
|
|
651
|
+
paint: (pixels, p) => {
|
|
652
|
+
pixels.each((x, y) => {
|
|
653
|
+
const X = x + 0.5
|
|
654
|
+
const Y = y + 0.5
|
|
655
|
+
const dx = X - p.mx
|
|
656
|
+
const dy = Y - p.my
|
|
657
|
+
const d = Math.hypot(dx, dy)
|
|
658
|
+
|
|
659
|
+
const motifs = [
|
|
660
|
+
() => d < p.size,
|
|
661
|
+
() => Y > p.my - p.size && Y < p.horizon && Math.abs(dx) < (Y - (p.my - p.size)) * 0.85,
|
|
662
|
+
() => d < p.size && Math.hypot(dx - p.size * 0.5, dy - p.size * 0.2) > p.size * 0.8,
|
|
663
|
+
() => Y > p.my + 2 + Math.sin(X * 0.3 + p.seedX) * 2.5 && Y < p.horizon,
|
|
664
|
+
]
|
|
665
|
+
|
|
666
|
+
if (motifs[p.motif]()) {
|
|
667
|
+
const gouge = p.motif === 1 ? Y > p.my - p.size * 0.2 && (x + y) % 4 === 0 : p.motif === 3 && (x - y * 2) % 6 === 0
|
|
668
|
+
|
|
669
|
+
return gouge ? p.ink : p.paper
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
const wobble = fbm(X * 0.3 + p.seedX, Y * 0.3 + p.seedY)
|
|
673
|
+
|
|
674
|
+
if (Y >= p.horizon) return (y - p.horizon) % 2 === 1 && wobble > 0.35 ? p.paper : p.ink
|
|
675
|
+
const near = 1 - clamp01((d - p.size) / 11)
|
|
676
|
+
|
|
677
|
+
return y % p.spacing === 1 && wobble < near * 0.95 ? p.paper : p.ink
|
|
678
|
+
})
|
|
679
|
+
},
|
|
680
|
+
},
|
|
681
|
+
{
|
|
682
|
+
id: "screenprint",
|
|
683
|
+
name: "Screenprint",
|
|
684
|
+
family: "Print",
|
|
685
|
+
label: "A pop motif repeated in clashing colourways with a misregistered shadow, or one big",
|
|
686
|
+
resolve: (random) => {
|
|
687
|
+
const r = random("screenprint")
|
|
688
|
+
const ways = shuffle(r, POP)
|
|
689
|
+
|
|
690
|
+
return {
|
|
691
|
+
grid: 16,
|
|
692
|
+
motif: int(r, 0, MOTIFS.length - 1),
|
|
693
|
+
single: r() < 0.5 ? 1 : 0,
|
|
694
|
+
dx: pick(r, [1, -1]),
|
|
695
|
+
dy: pick(r, [1, 0, -1]),
|
|
696
|
+
...prefixed("g", ways.slice(0, 4)),
|
|
697
|
+
...prefixed("i", ways.slice(4, 8)),
|
|
698
|
+
...prefixed("s", ways.slice(1, 5)),
|
|
699
|
+
}
|
|
700
|
+
},
|
|
701
|
+
paint: (pixels, p) => {
|
|
702
|
+
const grounds = colors(p, "g", 4)
|
|
703
|
+
const inks = colors(p, "i", 4)
|
|
704
|
+
const shadows = colors(p, "s", 4)
|
|
705
|
+
const motif = MOTIFS[p.motif]
|
|
706
|
+
const at = (x: number, y: number) => x >= 0 && y >= 0 && x < 6 && y < 6 && ((motif[y] >> (5 - x)) & 1) === 1
|
|
707
|
+
|
|
708
|
+
pixels.each((x, y) => {
|
|
709
|
+
if (p.single) {
|
|
710
|
+
const lx = Math.floor((x - 2) / 2)
|
|
711
|
+
const ly = Math.floor((y - 2) / 2)
|
|
712
|
+
|
|
713
|
+
if (at(lx, ly)) return inks[0]
|
|
714
|
+
|
|
715
|
+
return at(Math.floor((x - 2 - p.dx) / 2), Math.floor((y - 2 - p.dy) / 2)) ? shadows[1] : grounds[0]
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
const panel = Math.floor(y / 8) * 2 + Math.floor(x / 8)
|
|
719
|
+
const lx = (x % 8) - 1
|
|
720
|
+
const ly = (y % 8) - 1
|
|
721
|
+
const ink = inks[panel] === grounds[panel] ? shadows[panel] : inks[panel]
|
|
722
|
+
|
|
723
|
+
if (at(lx, ly)) return ink
|
|
724
|
+
|
|
725
|
+
return at(lx - p.dx, ly - p.dy) ? shadows[(panel + 1) % 4] : grounds[panel]
|
|
726
|
+
})
|
|
727
|
+
},
|
|
728
|
+
},
|
|
729
|
+
]
|
|
730
|
+
|
|
731
|
+
const ART: Definition[] = [
|
|
732
|
+
{
|
|
733
|
+
id: "de-stijl",
|
|
734
|
+
name: "De Stijl",
|
|
735
|
+
family: "Art movements",
|
|
736
|
+
label: "Recursive black-lined rectangles with primary fills, sometimes turned 45° like van Doesburg",
|
|
737
|
+
resolve: (random) => {
|
|
738
|
+
const r = random("de-stijl")
|
|
739
|
+
|
|
740
|
+
return {
|
|
741
|
+
seed: seed(r),
|
|
742
|
+
depth: int(r, 2, 4),
|
|
743
|
+
weight: range(r, 0.05, 0.085),
|
|
744
|
+
turn: r() < 0.22 ? 1 : 0,
|
|
745
|
+
line: r() < 0.85 ? 0x111111 : 0x5a5a5a,
|
|
746
|
+
white: pick(r, [0xf2efe8, 0xf7f4ee, 0xebe6dc]),
|
|
747
|
+
grey: r() < 0.3 ? 1 : 0,
|
|
748
|
+
}
|
|
749
|
+
},
|
|
750
|
+
vector: (ctx, px, p) => {
|
|
751
|
+
const rand = mulberry32(p.seed)
|
|
752
|
+
const gap = px * p.weight
|
|
753
|
+
const leaves: { x: number; y: number; w: number; h: number }[] = []
|
|
754
|
+
|
|
755
|
+
const split = (x: number, y: number, w: number, h: number, depth: number) => {
|
|
756
|
+
if (depth === 0 || (depth < p.depth && rand() < 0.3) || Math.min(w, h) < px * 0.18) {
|
|
757
|
+
leaves.push({ x, y, w, h })
|
|
758
|
+
|
|
759
|
+
return
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
const k = 0.28 + rand() * 0.44
|
|
763
|
+
|
|
764
|
+
if (w > h ? rand() < 0.75 : rand() < 0.25) {
|
|
765
|
+
split(x, y, w * k, h, depth - 1)
|
|
766
|
+
split(x + w * k, y, w * (1 - k), h, depth - 1)
|
|
767
|
+
|
|
768
|
+
return
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
split(x, y, w, h * k, depth - 1)
|
|
772
|
+
split(x, y + h * k, w, h * (1 - k), depth - 1)
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
const extent = p.turn ? px * 1.5 : px
|
|
776
|
+
split(-gap / 2, -gap / 2, extent + gap, extent + gap, p.depth)
|
|
777
|
+
const fills = shuffle(rand, leaves.map((_, i) => i)).slice(0, Math.max(1, Math.round(leaves.length * 0.4)))
|
|
778
|
+
|
|
779
|
+
ctx.save()
|
|
780
|
+
|
|
781
|
+
if (p.turn) {
|
|
782
|
+
ctx.translate(px / 2, px / 2)
|
|
783
|
+
ctx.rotate(Math.PI / 4)
|
|
784
|
+
ctx.translate(-extent / 2, -extent / 2)
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
ctx.fillStyle = css(p.line)
|
|
788
|
+
ctx.fillRect(-px, -px, extent + px * 2, extent + px * 2)
|
|
789
|
+
leaves.forEach((leaf, i) => {
|
|
790
|
+
const slot = fills.indexOf(i)
|
|
791
|
+
const accent = slot < 0 ? p.white : slot < 3 ? DE_STIJL[(slot + p.seed) % 3] : p.grey ? 0xbdbab3 : p.white
|
|
792
|
+
ctx.fillStyle = css(accent)
|
|
793
|
+
ctx.fillRect(leaf.x + gap / 2, leaf.y + gap / 2, Math.max(0, leaf.w - gap), Math.max(0, leaf.h - gap))
|
|
794
|
+
})
|
|
795
|
+
ctx.restore()
|
|
796
|
+
},
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
id: "memphis",
|
|
800
|
+
name: "Memphis",
|
|
801
|
+
family: "Art movements",
|
|
802
|
+
label: "Squiggles, triangles, dot grids and zigzags scattered over a pastel ground",
|
|
803
|
+
resolve: (random) => {
|
|
804
|
+
const r = random("memphis")
|
|
805
|
+
|
|
806
|
+
return { seed: seed(r), ground: pick(r, MEMPHIS_GROUNDS), count: int(r, 3, 4) }
|
|
807
|
+
},
|
|
808
|
+
vector: (ctx, px, p) => {
|
|
809
|
+
const rand = mulberry32(p.seed)
|
|
810
|
+
const dark = luma(p.ground) < 0.3
|
|
811
|
+
const inks = MEMPHIS_INKS.filter((ink) => !dark || ink !== 0x111111)
|
|
812
|
+
ctx.fillStyle = css(p.ground)
|
|
813
|
+
ctx.fillRect(0, 0, px, px)
|
|
814
|
+
ctx.lineCap = "round"
|
|
815
|
+
ctx.lineJoin = "round"
|
|
816
|
+
ctx.lineWidth = px * 0.075
|
|
817
|
+
const spots = shuffle(rand, [
|
|
818
|
+
[0.28, 0.28],
|
|
819
|
+
[0.72, 0.3],
|
|
820
|
+
[0.3, 0.72],
|
|
821
|
+
[0.72, 0.72],
|
|
822
|
+
])
|
|
823
|
+
const kinds = shuffle(rand, [0, 1, 2, 3, 4, 5])
|
|
824
|
+
|
|
825
|
+
spots.slice(0, p.count).forEach(([u, v], i) => {
|
|
826
|
+
const x = u * px + (rand() - 0.5) * px * 0.1
|
|
827
|
+
const y = v * px + (rand() - 0.5) * px * 0.1
|
|
828
|
+
const s = px * (0.16 + rand() * 0.08)
|
|
829
|
+
const ink = css(pick(rand, inks))
|
|
830
|
+
ctx.fillStyle = ink
|
|
831
|
+
ctx.strokeStyle = ink
|
|
832
|
+
ctx.beginPath()
|
|
833
|
+
|
|
834
|
+
const shapes = [
|
|
835
|
+
() => {
|
|
836
|
+
ctx.moveTo(x - s * 1.2, y)
|
|
837
|
+
Array.from({ length: 13 }, (_, k) =>
|
|
838
|
+
ctx.lineTo(x - s * 1.2 + (k * s * 2.4) / 12, y + Math.sin(k * 1.1) * s * 0.4),
|
|
839
|
+
)
|
|
840
|
+
ctx.stroke()
|
|
841
|
+
},
|
|
842
|
+
() => {
|
|
843
|
+
const turn = rand() * Math.PI * 2
|
|
844
|
+
Array.from({ length: 3 }, (_, k) =>
|
|
845
|
+
ctx.lineTo(x + Math.cos(turn + (k * Math.PI * 2) / 3) * s, y + Math.sin(turn + (k * Math.PI * 2) / 3) * s),
|
|
846
|
+
)
|
|
847
|
+
ctx.fill()
|
|
848
|
+
},
|
|
849
|
+
() => {
|
|
850
|
+
Array.from({ length: 9 }, (_, k) => {
|
|
851
|
+
ctx.moveTo(x + ((k % 3) - 1) * s * 0.7 + s * 0.12, y + (Math.floor(k / 3) - 1) * s * 0.7)
|
|
852
|
+
ctx.arc(x + ((k % 3) - 1) * s * 0.7, y + (Math.floor(k / 3) - 1) * s * 0.7, s * 0.12, 0, Math.PI * 2)
|
|
853
|
+
})
|
|
854
|
+
ctx.fill()
|
|
855
|
+
},
|
|
856
|
+
() => {
|
|
857
|
+
ctx.moveTo(x - s * 1.1, y + s * 0.3)
|
|
858
|
+
Array.from({ length: 5 }, (_, k) => ctx.lineTo(x - s * 1.1 + ((k + 1) * s * 2.2) / 5, y + (k % 2 ? 0.3 : -0.3) * s))
|
|
859
|
+
ctx.stroke()
|
|
860
|
+
},
|
|
861
|
+
() => {
|
|
862
|
+
ctx.arc(x, y, s * 0.8, 0, Math.PI * 2)
|
|
863
|
+
ctx.stroke()
|
|
864
|
+
},
|
|
865
|
+
() => {
|
|
866
|
+
ctx.arc(x, y + s * 0.3, s * 0.9, Math.PI, Math.PI * 2)
|
|
867
|
+
ctx.fill()
|
|
868
|
+
},
|
|
869
|
+
]
|
|
870
|
+
|
|
871
|
+
shapes[kinds[i]]()
|
|
872
|
+
})
|
|
873
|
+
},
|
|
874
|
+
},
|
|
875
|
+
{
|
|
876
|
+
id: "deco",
|
|
877
|
+
name: "Art Deco",
|
|
878
|
+
family: "Art movements",
|
|
879
|
+
label: "Metallic sunburst fans, a trio of fans, a ziggurat or a corner fan on a dark lacquer",
|
|
880
|
+
resolve: (random) => {
|
|
881
|
+
const r = random("deco")
|
|
882
|
+
|
|
883
|
+
return {
|
|
884
|
+
layout: int(r, 0, 3),
|
|
885
|
+
ground: pick(r, DECO_GROUNDS),
|
|
886
|
+
metal: pick(r, DECO_METALS),
|
|
887
|
+
rays: int(r, 7, 13),
|
|
888
|
+
arcs: int(r, 2, 3),
|
|
889
|
+
}
|
|
890
|
+
},
|
|
891
|
+
vector: (ctx, px, p) => {
|
|
892
|
+
const ground = p.ground === 0xf1e9d8 ? shade(p.metal, 0.45) : p.metal
|
|
893
|
+
ctx.fillStyle = css(p.ground)
|
|
894
|
+
ctx.fillRect(0, 0, px, px)
|
|
895
|
+
ctx.strokeStyle = css(ground)
|
|
896
|
+
ctx.fillStyle = css(ground)
|
|
897
|
+
ctx.lineWidth = px * 0.035
|
|
898
|
+
|
|
899
|
+
const fan = (cx: number, cy: number, radius: number, from: number, to: number, filled: boolean) => {
|
|
900
|
+
Array.from({ length: p.rays }, (_, k) => {
|
|
901
|
+
const angle = from + ((to - from) * (k + 0.5)) / p.rays
|
|
902
|
+
ctx.beginPath()
|
|
903
|
+
ctx.moveTo(cx + Math.cos(angle) * radius * 0.3, cy + Math.sin(angle) * radius * 0.3)
|
|
904
|
+
ctx.lineTo(cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius)
|
|
905
|
+
ctx.stroke()
|
|
906
|
+
})
|
|
907
|
+
Array.from({ length: p.arcs }, (_, k) => {
|
|
908
|
+
ctx.beginPath()
|
|
909
|
+
ctx.arc(cx, cy, radius * (1 - k * 0.22), from, to)
|
|
910
|
+
ctx.stroke()
|
|
911
|
+
})
|
|
912
|
+
ctx.beginPath()
|
|
913
|
+
ctx.moveTo(cx, cy)
|
|
914
|
+
ctx.arc(cx, cy, radius * 0.3, from, to)
|
|
915
|
+
ctx.closePath()
|
|
916
|
+
|
|
917
|
+
if (filled) ctx.fill()
|
|
918
|
+
|
|
919
|
+
if (!filled) ctx.stroke()
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
const layouts = [
|
|
923
|
+
() => fan(px / 2, px * 0.92, px * 0.78, Math.PI, Math.PI * 2, true),
|
|
924
|
+
() => {
|
|
925
|
+
fan(px * 0.2, px * 0.95, px * 0.38, Math.PI, Math.PI * 2, false)
|
|
926
|
+
fan(px * 0.8, px * 0.95, px * 0.38, Math.PI, Math.PI * 2, false)
|
|
927
|
+
fan(px / 2, px * 0.95, px * 0.56, Math.PI, Math.PI * 2, true)
|
|
928
|
+
},
|
|
929
|
+
() => {
|
|
930
|
+
const steps = 4
|
|
931
|
+
Array.from({ length: steps }, (_, k) => {
|
|
932
|
+
const w = px * (0.7 - k * 0.15)
|
|
933
|
+
ctx.fillRect((px - w) / 2, px * (0.95 - (k + 1) * 0.1), w, px * 0.1 + 1)
|
|
934
|
+
})
|
|
935
|
+
fan(px / 2, px * 0.55, px * 0.5, Math.PI * 1.08, Math.PI * 1.92, false)
|
|
936
|
+
},
|
|
937
|
+
() => {
|
|
938
|
+
Array.from({ length: p.rays }, (_, k) => {
|
|
939
|
+
if (k % 2) return
|
|
940
|
+
const a = -Math.PI / 2 + ((Math.PI / 2) * k) / p.rays
|
|
941
|
+
const b = -Math.PI / 2 + ((Math.PI / 2) * (k + 1)) / p.rays
|
|
942
|
+
ctx.beginPath()
|
|
943
|
+
ctx.moveTo(0, px)
|
|
944
|
+
ctx.arc(0, px, px * 1.1, a, b)
|
|
945
|
+
ctx.closePath()
|
|
946
|
+
ctx.fill()
|
|
947
|
+
})
|
|
948
|
+
ctx.beginPath()
|
|
949
|
+
ctx.arc(0, px, px * 0.45, -Math.PI / 2, 0)
|
|
950
|
+
ctx.lineTo(0, px)
|
|
951
|
+
ctx.fillStyle = css(p.ground)
|
|
952
|
+
ctx.fill()
|
|
953
|
+
ctx.stroke()
|
|
954
|
+
},
|
|
955
|
+
]
|
|
956
|
+
|
|
957
|
+
layouts[p.layout]()
|
|
958
|
+
},
|
|
959
|
+
},
|
|
960
|
+
{
|
|
961
|
+
id: "kandinsky",
|
|
962
|
+
name: "Kandinsky",
|
|
963
|
+
family: "Art movements",
|
|
964
|
+
label: "Four squares of two to four loose concentric circles in clashing colours",
|
|
965
|
+
resolve: (random) => {
|
|
966
|
+
const r = random("kandinsky")
|
|
967
|
+
|
|
968
|
+
return { seed: seed(r), tiles: 2, rings: int(r, 2, 4) }
|
|
969
|
+
},
|
|
970
|
+
vector: (ctx, px, p) => {
|
|
971
|
+
const rand = mulberry32(p.seed)
|
|
972
|
+
const size = px / p.tiles
|
|
973
|
+
|
|
974
|
+
for (let i = 0; i < p.tiles; i++)
|
|
975
|
+
for (let j = 0; j < p.tiles; j++) {
|
|
976
|
+
const order = shuffle(rand, KANDINSKY)
|
|
977
|
+
const cx = (i + 0.5) * size
|
|
978
|
+
const cy = (j + 0.5) * size
|
|
979
|
+
ctx.fillStyle = css(order[0])
|
|
980
|
+
ctx.fillRect(i * size - 0.5, j * size - 0.5, size + 1, size + 1)
|
|
981
|
+
|
|
982
|
+
for (let k = 0; k < p.rings; k++) {
|
|
983
|
+
const radius = size * 0.44 * (1 - k / (p.rings + 0.4)) * (0.9 + rand() * 0.15)
|
|
984
|
+
ctx.beginPath()
|
|
985
|
+
ctx.arc(cx + (rand() - 0.5) * size * 0.06, cy + (rand() - 0.5) * size * 0.06, radius, 0, Math.PI * 2)
|
|
986
|
+
ctx.fillStyle = css(order[k + 1])
|
|
987
|
+
ctx.fill()
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
},
|
|
991
|
+
},
|
|
992
|
+
{
|
|
993
|
+
id: "albers",
|
|
994
|
+
name: "Albers",
|
|
995
|
+
family: "Art movements",
|
|
996
|
+
label: "Homage to the Square: three or four nested squares sinking toward the bottom edge",
|
|
997
|
+
resolve: (random) => {
|
|
998
|
+
const r = random("albers")
|
|
999
|
+
const hue = r()
|
|
1000
|
+
const count = int(r, 3, 4)
|
|
1001
|
+
const drift = range(r, -0.08, 0.08)
|
|
1002
|
+
const rising = r() < 0.6
|
|
1003
|
+
const s = range(r, 0.35, 0.8)
|
|
1004
|
+
|
|
1005
|
+
return {
|
|
1006
|
+
count,
|
|
1007
|
+
...prefixed(
|
|
1008
|
+
"a",
|
|
1009
|
+
Array.from({ length: count }, (_, k) => {
|
|
1010
|
+
const l = rising ? 0.28 + k * 0.17 : 0.82 - k * 0.15
|
|
1011
|
+
|
|
1012
|
+
return hsl(hue + drift * k, s, l)
|
|
1013
|
+
}),
|
|
1014
|
+
),
|
|
1015
|
+
}
|
|
1016
|
+
},
|
|
1017
|
+
vector: (ctx, px, p) => {
|
|
1018
|
+
const squares = colors(p, "a", p.count)
|
|
1019
|
+
const step = 1 / (p.count + 1)
|
|
1020
|
+
|
|
1021
|
+
squares.forEach((color, k) => {
|
|
1022
|
+
const size = px * (1 - k * step)
|
|
1023
|
+
const bottom = px * k * step * 0.25
|
|
1024
|
+
ctx.fillStyle = css(color)
|
|
1025
|
+
ctx.fillRect((px - size) / 2, px - bottom - size, size, size)
|
|
1026
|
+
})
|
|
1027
|
+
},
|
|
1028
|
+
},
|
|
1029
|
+
{
|
|
1030
|
+
id: "rothko",
|
|
1031
|
+
name: "Rothko",
|
|
1032
|
+
family: "Art movements",
|
|
1033
|
+
label: "Two or three soft-edged colour fields floating on a stained ground",
|
|
1034
|
+
resolve: (random) => {
|
|
1035
|
+
const r = random("rothko")
|
|
1036
|
+
const set = r() < 0.75 ? pick(r, ROTHKO) : [shade(hsl(r(), 0.5, 0.3), 1), hsl(r(), 0.6, 0.5), hsl(r(), 0.5, 0.25), hsl(r(), 0.7, 0.6)]
|
|
1037
|
+
const count = r() < 0.6 ? 2 : 3
|
|
1038
|
+
|
|
1039
|
+
return {
|
|
1040
|
+
grid: 32,
|
|
1041
|
+
count,
|
|
1042
|
+
split: range(r, 0.38, 0.62),
|
|
1043
|
+
margin: range(r, 3, 4.5),
|
|
1044
|
+
...prefixed("f", set),
|
|
1045
|
+
seedX: r() * 40,
|
|
1046
|
+
seedY: r() * 40,
|
|
1047
|
+
}
|
|
1048
|
+
},
|
|
1049
|
+
paint: (pixels, p) => {
|
|
1050
|
+
const [ground, ...fields] = colors(p, "f", 4)
|
|
1051
|
+
const gap = 2.2
|
|
1052
|
+
const top = p.margin
|
|
1053
|
+
const bottom = 32 - p.margin
|
|
1054
|
+
const inner = bottom - top - gap * (p.count - 1)
|
|
1055
|
+
const heights = p.count === 2 ? [inner * p.split, inner * (1 - p.split)] : [inner * 0.3, inner * 0.22, inner * 0.48]
|
|
1056
|
+
|
|
1057
|
+
const bands = heights.map((height, i) => {
|
|
1058
|
+
const y0 = top + heights.slice(0, i).reduce((sum, h) => sum + h, 0) + gap * i
|
|
1059
|
+
|
|
1060
|
+
return { y0, y1: y0 + height, color: fields[i] }
|
|
1061
|
+
})
|
|
1062
|
+
|
|
1063
|
+
pixels.each((x, y) => {
|
|
1064
|
+
const n = fbm(x * 0.25 + p.seedX, y * 0.25 + p.seedY)
|
|
1065
|
+
const X = x + 0.5 + (n - 0.5) * 1.6
|
|
1066
|
+
const Y = y + 0.5 + (n - 0.5) * 1.6
|
|
1067
|
+
const stained = shade(ground, 0.88 + n * 0.22)
|
|
1068
|
+
|
|
1069
|
+
return bands.reduce((color, band) => {
|
|
1070
|
+
const edge = Math.min(X - p.margin + 0.6, 32 - p.margin + 0.6 - X, Y - band.y0, band.y1 - Y)
|
|
1071
|
+
|
|
1072
|
+
return mix(color, shade(band.color, 0.9 + n * 0.18), smoothstep(-0.8, 1.4, edge))
|
|
1073
|
+
}, stained)
|
|
1074
|
+
})
|
|
1075
|
+
},
|
|
1076
|
+
},
|
|
1077
|
+
]
|
|
1078
|
+
|
|
1079
|
+
export const CRAFT: Definition[] = [...TEXTILES, ...PRINT, ...ART]
|