@mkbabb/glass-ui 3.1.1 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CardFooter-CSGcJkqa.js → CardFooter-3-VGho1J.js} +1 -1
- package/dist/{CommandShortcut-DWT19a2Y.js → CommandShortcut-C6lsz3pG.js} +3 -3
- package/dist/{ContextMenuSubContent-gAFxJ-qi.js → ContextMenuSubContent-DrWkXKQP.js} +4 -4
- package/dist/{DataTable-R8-Zidms.js → DataTable-BsrDYdoE.js} +3 -3
- package/dist/{DialogContent-2fALDSvc.js → DialogContent-B61rP8lj.js} +3 -3
- package/dist/{DialogFooter-ClrNEOVU.js → DialogFooter-Er0wA3K6.js} +2 -2
- package/dist/{DiscoGlyph-C3JfMnRV.js → DiscoGlyph-B7YooI2-.js} +1 -1
- package/dist/{GlyphFace-BRS8vUb7.js → GlyphFace-Bvk6OIas.js} +1 -1
- package/dist/{HoverPopover-CWFCfLx3.js → HoverPopover-BlEwqG7S.js} +1 -1
- package/dist/{IconTooltip-BkaA7tZ2.js → IconTooltip-DXveGjx7.js} +1 -1
- package/dist/{MetricBadge-DmAihkXd.js → MetricBadge-J_GBCb8e.js} +1 -1
- package/dist/{Notification-OqIpADml.js → Notification-DP_ApJLo.js} +3 -3
- package/dist/{NumberFieldContent-DTH9gb_N.js → NumberFieldContent-B6L6YrQz.js} +2 -2
- package/dist/{PopoverContent-EiklFrna.js → PopoverContent-CxEEUL7Y.js} +1 -1
- package/dist/{Progress-FApA9fm_.js → Progress-Bs44qWEM.js} +1 -1
- package/dist/{ScrollingText-BFd0i2zJ.js → ScrollingText-1Qjnwz6H.js} +2 -2
- package/dist/{SelectScrollDownButton-Dth8-wXQ.js → SelectScrollDownButton-BvvvAbuh.js} +4 -4
- package/dist/{Toaster-Bjlunvq4.js → Toaster-Brs6QjBU.js} +1 -1
- package/dist/{UnderlineTabs-DAWMLmJG.js → UnderlineTabs-B4FV2zi_.js} +1 -1
- package/dist/animated-digit.js +2 -2
- package/dist/api.js +1 -1
- package/dist/aurora.js +118 -150
- package/dist/badge.js +1 -1
- package/dist/button.js +1 -1
- package/dist/card.js +1 -1
- package/dist/carousel.js +5 -5
- package/dist/{check-dwgetki8.js → check-CdkxGxXJ.js} +1 -1
- package/dist/{chevron-down-DILQA1t6.js → chevron-down-pBY8sYfV.js} +1 -1
- package/dist/{chevron-right-fS7fal2t.js → chevron-right-BjeKC22V.js} +1 -1
- package/dist/{chevron-up-BtYjYQOS.js → chevron-up-DBeNHUm1.js} +1 -1
- package/dist/collapsible.js +1 -1
- package/dist/command.js +1 -1
- package/dist/components/custom/aurora/composables/color.d.ts +56 -8
- package/dist/components/custom/aurora/index.d.ts +2 -1
- package/dist/components/custom/aurora/presets.d.ts +1 -1
- package/dist/components/custom/aurora/shaders/aurora.frag.d.ts +1 -1
- package/dist/components/custom/configurator/Configurator.vue.d.ts +26 -0
- package/dist/components/custom/configurator/index.d.ts +1 -1
- package/dist/components/custom/dock/DockIconButton.vue.d.ts +14 -3
- package/dist/components/custom/dock/GlassDock.vue.d.ts +17 -0
- package/dist/composables/dom/index.d.ts +1 -0
- package/dist/composables/dom/useTextHighlight.d.ts +40 -0
- package/dist/composables/motion/core/index.d.ts +1 -0
- package/dist/composables/motion/usePrioritizedTask.d.ts +41 -0
- package/dist/composables/sortable/useSortable.d.ts +13 -0
- package/dist/configurator.js +1 -1
- package/dist/confirm-dialog.js +3 -3
- package/dist/context-menu.js +2 -2
- package/dist/controls.js +2 -2
- package/dist/dark.js +1 -1
- package/dist/data-table.js +1 -1
- package/dist/dialog.js +2 -2
- package/dist/disco-glyph.js +1 -1
- package/dist/dock.js +98 -81
- package/dist/dom.js +6 -5
- package/dist/{dropdown-menu-BvRUamNs.js → dropdown-menu-naE0skDg.js} +4 -4
- package/dist/dropdown-menu.js +1 -1
- package/dist/expandable-container.js +2 -2
- package/dist/forms.js +4 -4
- package/dist/glass-carousel.js +59 -52
- package/dist/glass-panel.js +2 -2
- package/dist/glass-ui.css +1 -1
- package/dist/glass-ui.js +231 -224
- package/dist/glyph-face.js +2 -2
- package/dist/header-ribbon.js +1 -1
- package/dist/hover-card.js +1 -1
- package/dist/hover-popover.js +1 -1
- package/dist/icon-tooltip.js +1 -1
- package/dist/instrument-chassis.js +1 -1
- package/dist/instrument-rail.js +1 -1
- package/dist/keyboard.js +1 -1
- package/dist/label.js +1 -1
- package/dist/labeled-field.js +6 -6
- package/dist/metric-badge.js +1 -1
- package/dist/metric-stack.js +1 -1
- package/dist/{minimize-2-LsCJ_eNt.js → minimize-2-BP27-qBY.js} +1 -1
- package/dist/motion-core.js +155 -95
- package/dist/motion.js +3 -3
- package/dist/notification.js +1 -1
- package/dist/number-field.js +1 -1
- package/dist/paper-backdrop.js +1 -1
- package/dist/popover.js +1 -1
- package/dist/{presets-a-D93K1S.js → presets-BpTf63Hp.js} +4 -4
- package/dist/progress.js +1 -1
- package/dist/pulse.js +1 -1
- package/dist/reactive.js +2 -2
- package/dist/responsive-tabs.js +2 -2
- package/dist/scrolling-text.js +1 -1
- package/dist/{search-DBAiUABx.js → search-DBG8qaRs.js} +1 -1
- package/dist/search.js +153 -149
- package/dist/select.js +3 -3
- package/dist/separator.js +1 -1
- package/dist/{sheet-CukNDezz.js → sheet-BnvZRXPq.js} +3 -3
- package/dist/sheet.js +1 -1
- package/dist/{slider-DJvHkTRe.js → slider-wx8ifVFB.js} +3 -3
- package/dist/slider.js +1 -1
- package/dist/sortable-list.js +2 -2
- package/dist/styles/components.css +45 -0
- package/dist/styles/dock.css +71 -2
- package/dist/styles/index.css +5 -1
- package/dist/styles/tokens.css +11 -0
- package/dist/styles/utilities.css +56 -0
- package/dist/supportsCssTimeline-IQY3gfKD.js +12 -0
- package/dist/switch.js +1 -1
- package/dist/tabs.js +25 -10
- package/dist/timeline.js +2 -2
- package/dist/toast.js +1 -1
- package/dist/toggle-group.js +1 -1
- package/dist/tooltip.js +1 -1
- package/dist/typewriter.js +1 -1
- package/dist/{useAnimatedNumber-DKQYVB7s.js → useAnimatedNumber-BOxrS3a6.js} +1 -1
- package/dist/{useConfiguratorState-CtRBE0m_.js → useConfiguratorState-Dq2gNv4A.js} +52 -40
- package/dist/{useIdleReady-Cmkhm03v.js → useIdleReady-sLhGo6CL.js} +1 -1
- package/dist/useSortable-DLK9kwZp.js +189 -0
- package/dist/useTextHighlight-CLST6an0.js +72 -0
- package/dist/{useTouchGate-D9Zvrzyc.js → useTouchGate-XX8gHfay.js} +1 -1
- package/dist/{useViewTransition-DYIK6Gzb.js → useViewTransition-CUJM7fXT.js} +5 -3
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/platformSupport.d.ts +8 -0
- package/dist/{x-q7pJa83X.js → x-C4pz9nbD.js} +1 -1
- package/package.json +13 -3
- package/src/styles/dock.css +71 -2
- package/src/styles/index.css +1 -1
- package/src/styles/tokens.css +11 -0
- package/src/styles/utilities.css +56 -0
- package/dist/useSortable-Cq2Y1JLO.js +0 -175
- /package/dist/{CollapsibleContent-CVMOcYlV.js → CollapsibleContent-wlmlDujU.js} +0 -0
- /package/dist/{ContextMenuContent-otjFIu8v.js → ContextMenuContent-De01_83g.js} +0 -0
- /package/dist/{HoverCardContent-DaGrgJBO.js → HoverCardContent-DGUhpRVt.js} +0 -0
- /package/dist/{Input-DDpFn568.js → Input-IFsIzId2.js} +0 -0
- /package/dist/{InstrumentChassis-CnHTMxds.js → InstrumentChassis-CqKPBNqp.js} +0 -0
- /package/dist/{InstrumentRail-C6dEbi8E.js → InstrumentRail-CCjvKkpB.js} +0 -0
- /package/dist/{Label-DJty89bp.js → Label-D53EOwLE.js} +0 -0
- /package/dist/{ModalOverlay-iWiAgbYH.js → ModalOverlay-B_CBtqcE.js} +0 -0
- /package/dist/{PaperBackdrop-CeZ-w0R0.js → PaperBackdrop-Ds-wDsKf.js} +0 -0
- /package/dist/{SelectGroup-DdR4tdDY.js → SelectGroup-DAgcsfFw.js} +0 -0
- /package/dist/{SelectSeparator-CXm_hlqA.js → SelectSeparator-DN1jzLaI.js} +0 -0
- /package/dist/{Separator-D8AUMhxY.js → Separator-DXxac0j8.js} +0 -0
- /package/dist/{Switch-Cr1t_F_U.js → Switch-imA0Hdjs.js} +0 -0
- /package/dist/{ToggleGroupItem-OesUouE7.js → ToggleGroupItem-Cy7xHFEo.js} +0 -0
- /package/dist/{TooltipProvider-DE78vbEP.js → TooltipProvider-MZFRxOvT.js} +0 -0
- /package/dist/{_plugin-vue_export-helper-Dq1MygBL.js → _plugin-vue_export-helper-C1je1s0u.js} +0 -0
- /package/dist/{badge-x46my_Fo.js → badge-Cl6JZ1B7.js} +0 -0
- /package/dist/{button-C0aHmBbt.js → button-DS3ULf5i.js} +0 -0
- /package/dist/{constants-DwBwnG8N.js → constants-DfWPi8kh.js} +0 -0
- /package/dist/{createLucideIcon-Bn9a1b70.js → createLucideIcon-DuDoe_ra.js} +0 -0
- /package/dist/{dockContext-D5NZCWJs.js → dockContext-DM58L1Jt.js} +0 -0
- /package/dist/{keys-CaTQS-vx.js → keys-SIKQYNx1.js} +0 -0
- /package/dist/{menuItemVariants-BsbGNq9C.js → menuItemVariants-C2QlXqT3.js} +0 -0
- /package/dist/{useGlassRenderer-Ds-nmrGz.js → useGlassRenderer-C98tZnJ7.js} +0 -0
- /package/dist/{useGlobalDark-B0WvLJE3.js → useGlobalDark-BUUTZvkU.js} +0 -0
- /package/dist/{useIntersectionPause-IY2CwPQb.js → useIntersectionPause-CUmANkoc.js} +0 -0
- /package/dist/{useInterval-DVgGUf_y.js → useInterval-B58LmYth.js} +0 -0
- /package/dist/{useKeyboardShortcuts-Dpw_RUcB.js → useKeyboardShortcuts-BQfnAHHW.js} +0 -0
- /package/dist/{useResizeObserver-Cg9npuM3.js → useResizeObserver-C_7GjpRn.js} +0 -0
- /package/dist/{useSpringMount-Cfk1XK1R.js → useSpringMount-CnizvZGm.js} +0 -0
- /package/dist/{useTimer-NAaj9zNq.js → useTimer-6FoosoDY.js} +0 -0
- /package/dist/{useUserInvalidAria-DVu1eTXG.js → useUserInvalidAria-BW5iyqWR.js} +0 -0
package/dist/aurora.js
CHANGED
|
@@ -1,157 +1,125 @@
|
|
|
1
|
-
import { t as e } from "./_plugin-vue_export-helper-
|
|
2
|
-
import { n as t, r as n, t as r } from "./presets-
|
|
3
|
-
import { t as i } from "./useIntersectionPause-
|
|
1
|
+
import { t as e } from "./_plugin-vue_export-helper-C1je1s0u.js";
|
|
2
|
+
import { n as t, r as n, t as r } from "./presets-BpTf63Hp.js";
|
|
3
|
+
import { t as i } from "./useIntersectionPause-CUmANkoc.js";
|
|
4
4
|
import { computed as a, createElementBlock as o, createElementVNode as s, defineComponent as c, normalizeClass as l, normalizeStyle as u, onBeforeUnmount as d, onMounted as f, openBlock as p, readonly as m, ref as h, unref as g, watch as _ } from "vue";
|
|
5
|
+
import { colorUnit2 as v, gamutMapOKLab as y, isInSRGBGamut as b, oklabToLinearSRGB as x, oklabToRgb255 as S, parseCSSColor as C, rawOklabToOklch as w, rawOklchToOklab as T, srgbToOKLab as E } from "@mkbabb/value.js";
|
|
5
6
|
//#region src/components/custom/aurora/shaders/aurora.vert.ts
|
|
6
|
-
var v = "#version 300 es\nin vec2 aPos;\nout vec2 vUv;\nvoid main() {\n vUv = aPos * 0.5 + 0.5;\n gl_Position = vec4(aPos, 0.0, 1.0);\n}", y = "#version 300 es\nprecision highp float;\n\nin vec2 vUv;\nout vec4 fragColor;\n\n#define MAX_NUCLEI 6\n#define MAX_STOPS 8\n\n// ── Uniforms ───────────────────────────────────────────────────────────────\nuniform float uTime;\n\n// Palette baked CPU-side to linear-sRGB\nuniform vec3 uPalette[MAX_STOPS];\nuniform int uStopCount;\n\n// Nuclei (parallel arrays)\nuniform int uNucleiCount;\nuniform vec2 uNucleiPos[MAX_NUCLEI];\nuniform float uNucleiRadius[MAX_NUCLEI];\nuniform float uNucleiPaletteBias[MAX_NUCLEI];\nuniform float uNucleiValueBias[MAX_NUCLEI];\nuniform float uNucleiDriftRadius[MAX_NUCLEI];\nuniform float uNucleiDriftPhase[MAX_NUCLEI];\n// Anisotropy: per-nucleus elongation (1.0 = isotropic) and major-axis angle (radians).\n// Defaults (1.0 / 0.0) reduce to the original circular Gaussian.\nuniform float uNucleiElong[MAX_NUCLEI];\nuniform float uNucleiAngle[MAX_NUCLEI];\nuniform float uSoftmaxBeta;\nuniform float uValueVariance;\n\n// Warp\nuniform float uWarpAmount;\nuniform float uWarpScale;\nuniform float uWarpDrift;\nuniform int uWarpMode; // 0=fbm 1=cellular 2=hybrid\nuniform int uNoiseOctaves;\n\n// Medium\n// 0 smooth, 1 pastel, 2 watercolor, 3 oil\nuniform int uMedium;\nuniform int uFlowPattern; // 0 none, 1 radial, 2 swirl, 3 diagonal, 4 multi\nuniform vec2 uFlowFocal;\nuniform float uFlowAngle;\nuniform float uFlowCurl;\nuniform vec2 uCursor; // in 0..1 screen space (matches pN)\nuniform float uCursorStrength; // 0..1 attraction amount\nuniform float uCursorRadius; // radius of influence (0.05..0.5)\nuniform float uStrokeAmount;\nuniform float uStrokeScale;\nuniform float uStrokeAnisotropy;\nuniform int uStrokeLayers; // 1 or 2 (crosshatch)\nuniform int uStrokeMode; // 0 oil (modern gestural), 1 palette-knife, 2 crayon/oil-pastel, 3 modern-chunky\nuniform float uWetEdge;\nuniform float uGranulation;\nuniform float uImpasto;\nuniform float uBrokenColor;\nuniform float uCanvasGrain;\n\n// Motion\nuniform float uNucleiDrift;\nuniform float uPaletteDrift;\nuniform float uBreathDepth;\nuniform float uBreathPeriod;\n\n// Output\nuniform float uSaturation;\nuniform float uPaperGrain;\nuniform float uAlpha;\n\n// ── Noise ──────────────────────────────────────────────────────────────────\nfloat hash21(vec2 p) {\n p = fract(p * vec2(123.34, 456.21));\n p += dot(p, p + 45.32);\n return fract(p.x * p.y);\n}\n\nvec2 hash22(vec2 p) {\n p = vec2(dot(p, vec2(127.1, 311.7)),\n dot(p, vec2(269.5, 183.3)));\n return fract(sin(p) * 43758.5453);\n}\n\nfloat vnoise(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n vec2 u = f * f * (3.0 - 2.0 * f);\n float a = hash21(i);\n float b = hash21(i + vec2(1.0, 0.0));\n float c = hash21(i + vec2(0.0, 1.0));\n float d = hash21(i + vec2(1.0, 1.0));\n return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);\n}\n\nfloat fbm(vec2 p) {\n float v = 0.0;\n float a = 0.5;\n mat2 r = mat2(0.8, 0.6, -0.6, 0.8);\n for (int i = 0; i < 5; i++) {\n if (i >= uNoiseOctaves) break;\n v += a * vnoise(p);\n p = r * p * 2.02;\n a *= 0.5;\n }\n return v;\n}\n\n// Cellular / Worley f1\nfloat cellular(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n float m = 1e9;\n for (int y = -1; y <= 1; y++) {\n for (int x = -1; x <= 1; x++) {\n vec2 g = vec2(float(x), float(y));\n vec2 o = hash22(i + g);\n vec2 r = g + o - f;\n m = min(m, dot(r, r));\n }\n }\n return sqrt(m);\n}\n\n// ── Warp ──────────────────────────────────────────────────────────────────\nvec2 domainWarp(vec2 p, float t) {\n // Quilez canonical double warp\n vec2 q = vec2(fbm(p * uWarpScale + vec2(0.0, 0.0) + t * uWarpDrift),\n fbm(p * uWarpScale + vec2(5.2, 1.3) + t * uWarpDrift));\n vec2 r = vec2(fbm(p * uWarpScale + 4.0 * q + vec2(1.7, 9.2)),\n fbm(p * uWarpScale + 4.0 * q + vec2(8.3, 2.8)));\n\n vec2 warp = r;\n if (uWarpMode == 1) {\n // cellular — chunky territories (MEADOW block-like)\n float c1 = cellular(p * uWarpScale * 1.5 + vec2(t * uWarpDrift * 2.0, 0.0));\n float c2 = cellular(p * uWarpScale * 1.5 + vec2(11.0, 7.0 + t * uWarpDrift * 2.0));\n warp = vec2(c1, c2);\n } else if (uWarpMode == 2) {\n // hybrid — fbm + cellular averaged\n float c1 = cellular(p * uWarpScale * 1.2);\n float c2 = cellular(p * uWarpScale * 1.2 + vec2(11.0, 7.0));\n warp = mix(r, vec2(c1, c2), 0.5);\n }\n vec2 warped = p + uWarpAmount * warp;\n\n // Cursor swirl — rotate p around uCursor with radial falloff.\n // This warps the underlying color field so the bands sweep around the pointer.\n if (uCursorStrength > 0.001) {\n vec2 toP = p - uCursor;\n float d = length(toP);\n float r = max(uCursorRadius, 0.01);\n // Smooth falloff; strong near cursor, zero beyond ~1.5× radius.\n float w = exp(-(d * d) / (r * r * 0.45));\n // Max rotation ~120° at cursor center, scaled by strength\n float ang = w * uCursorStrength * 2.1;\n float ca = cos(ang), sa = sin(ang);\n vec2 rotated = vec2(ca * toP.x - sa * toP.y, sa * toP.x + ca * toP.y) + uCursor;\n // Also pinch slightly toward the cursor (gravity) — adds depth to swirl\n float pinch = w * uCursorStrength * 0.08;\n rotated = mix(rotated, uCursor, pinch);\n // Blend original warped position with cursor-rotated version\n warped = mix(warped, rotated + uWarpAmount * warp * 0.7, w * uCursorStrength);\n }\n\n return warped;\n}\n\n// ── Palette LUT ───────────────────────────────────────────────────────────\nvec3 samplePalette(float id) {\n id = clamp(id, 0.0, 1.0);\n float scaled = id * float(uStopCount - 1);\n int i0 = int(floor(scaled));\n int i1 = min(i0 + 1, uStopCount - 1);\n float t = fract(scaled);\n t = smoothstep(0.0, 1.0, t);\n return mix(uPalette[i0], uPalette[i1], t);\n}\n\n// ── Nuclei field ──────────────────────────────────────────────────────────\nvoid nucleiField(vec2 p, float t, out float paletteId, out float valueMod) {\n float accumBias = 0.0;\n float accumValue = 0.0;\n float accumW = 0.0;\n for (int i = 0; i < MAX_NUCLEI; i++) {\n if (i >= uNucleiCount) break;\n vec2 posI = uNucleiPos[i]\n + uNucleiDriftRadius[i] * vec2(\n cos(t * uNucleiDrift + uNucleiDriftPhase[i]),\n sin(t * uNucleiDrift + uNucleiDriftPhase[i] * 1.13)\n );\n vec2 diff = p - posI;\n // Anisotropic Gaussian: rotate diff into the nucleus's local frame\n // (major axis along uNucleiAngle), then scale the major-axis component by\n // 1/elongation so the squared distance describes an ellipse. Defaults\n // 1.0/0.0 reduce to the isotropic dot(diff, diff).\n float ca = cos(uNucleiAngle[i]);\n float sa = sin(uNucleiAngle[i]);\n vec2 local = vec2( ca * diff.x + sa * diff.y,\n -sa * diff.x + ca * diff.y);\n float along = local.x / max(uNucleiElong[i], 0.01);\n float across = local.y;\n float d2 = along * along + across * across;\n float r = max(uNucleiRadius[i], 0.01);\n float w = exp(-uSoftmaxBeta * d2 / (r * r));\n accumBias += w * uNucleiPaletteBias[i];\n accumValue += w * uNucleiValueBias[i];\n accumW += w;\n }\n paletteId = accumBias / max(accumW, 1e-4);\n valueMod = accumValue / max(accumW, 1e-4);\n\n // Palette drift — subtle global paletteId shift\n paletteId += 0.04 * sin(t * uPaletteDrift * 6.2831) * uPaletteDrift * 20.0;\n paletteId = clamp(paletteId, 0.0, 1.0);\n}\n\n// ── Flow field ────────────────────────────────────────────────────────────\nvec2 flowField(vec2 p, float t) {\n vec2 dir = vec2(1.0, 0.0);\n if (uFlowPattern == 1) {\n // radial\n dir = normalize(p - uFlowFocal + 1e-4);\n } else if (uFlowPattern == 2) {\n // swirl — tangent to radial\n vec2 rad = normalize(p - uFlowFocal + 1e-4);\n dir = vec2(-rad.y, rad.x);\n } else if (uFlowPattern == 3) {\n // diagonal\n float a = radians(uFlowAngle);\n dir = vec2(cos(a), sin(a));\n } else if (uFlowPattern == 4) {\n // multi — curl-noise driven\n float n = fbm(p * 2.0 + t * 0.02);\n float a = n * 6.2831;\n dir = vec2(cos(a), sin(a));\n }\n // curl — perturb by noise. Radial gets much less curl so rays stay clean.\n if (uFlowCurl > 0.0) {\n float n = fbm(p * 3.0) - 0.5;\n float curlAmt = uFlowCurl;\n if (uFlowPattern == 1) curlAmt *= 0.25; // radial: preserve ray clarity\n if (uFlowPattern == 2) curlAmt *= 0.55; // swirl: allow moderate curl\n float a = atan(dir.y, dir.x) + n * 3.14159 * curlAmt;\n dir = vec2(cos(a), sin(a));\n }\n // cursor influence — swirl around the cursor position\n if (uCursorStrength > 0.001) {\n vec2 toCur = uCursor - p;\n float d = length(toCur);\n float r = max(uCursorRadius, 0.01);\n float w = exp(-(d * d) / (r * r * 0.5));\n // swirl tangent\n vec2 tangent = vec2(-toCur.y, toCur.x) / max(d, 1e-4);\n float a0 = atan(dir.y, dir.x);\n float a1 = atan(tangent.y, tangent.x);\n // blend angle\n float da = a1 - a0;\n da = atan(sin(da), cos(da)); // wrap to [-pi, pi]\n float a = a0 + da * w * uCursorStrength;\n dir = vec2(cos(a), sin(a));\n }\n return dir;\n}\n\n// ── Color utils ───────────────────────────────────────────────────────────\nconst vec3 W_LUMA = vec3(0.2126, 0.7152, 0.0722);\n\nvec3 hueShift(vec3 c, float degrees) {\n float a = radians(degrees);\n float co = cos(a), si = sin(a);\n mat3 m = mat3(\n 0.299 + 0.701 * co + 0.168 * si,\n 0.587 - 0.587 * co + 0.330 * si,\n 0.114 - 0.114 * co - 0.497 * si,\n\n 0.299 - 0.299 * co - 0.328 * si,\n 0.587 + 0.413 * co + 0.035 * si,\n 0.114 - 0.114 * co + 0.292 * si,\n\n 0.299 - 0.300 * co + 1.250 * si,\n 0.587 - 0.588 * co - 1.050 * si,\n 0.114 + 0.886 * co - 0.203 * si\n );\n return m * c;\n}\n\nvec3 brokenColorJitter(vec3 c, float hueSeed, float valueSeed, float strength) {\n float amt = clamp(uBrokenColor * strength, 0.0, 1.0);\n if (amt <= 0.001) return c;\n float hueDeg = (hueSeed - 0.5) * 32.0 * amt;\n float valueMul = 1.0 + (valueSeed - 0.5) * 0.28 * amt;\n return max(hueShift(c, hueDeg) * valueMul, vec3(0.0));\n}\n\nvec3 saturate3(vec3 c, float amt) {\n float l = dot(c, W_LUMA);\n return mix(vec3(l), c, amt);\n}\n\n// ACES approximation\nvec3 aces(vec3 x) {\n float a = 2.51;\n float b = 0.03;\n float c = 2.43;\n float d = 0.59;\n float e = 0.14;\n return clamp((x * (a * x + b)) / (x * (c * x + d) + e), 0.0, 1.0);\n}\n\n// ── Medium overlays ───────────────────────────────────────────────────────\n\n// A quick re-computation of base color for edge-mask sampling\nvec3 sampleBase(vec2 p, float t) {\n vec2 pw = domainWarp(p, t);\n float id; float vm;\n nucleiField(pw, t, id, vm);\n vec3 c = samplePalette(id);\n c *= 1.0 + uValueVariance * vm;\n return c;\n}\n\nvec3 mediumWatercolor(vec3 col, vec2 p, float t) {\n // Wet-edge cauliflowers via luma-gradient magnitude\n float eps = 0.004;\n vec3 cx1 = sampleBase(p + vec2(eps, 0.0), t);\n vec3 cx2 = sampleBase(p - vec2(eps, 0.0), t);\n vec3 cy1 = sampleBase(p + vec2(0.0, eps), t);\n vec3 cy2 = sampleBase(p - vec2(0.0, eps), t);\n float gx = dot(cx1 - cx2, W_LUMA);\n float gy = dot(cy1 - cy2, W_LUMA);\n float edge = sqrt(gx * gx + gy * gy) / (2.0 * eps);\n float mask = smoothstep(0.0, 2.5, edge);\n col *= mix(1.0, 0.78, mask * uWetEdge);\n\n // Granulation — pigment settles in paper tooth\n float paper = 0.5 * vnoise(p * 160.0) + 0.5 * vnoise(p * 360.0);\n float pigLoad = 1.0 - dot(col, W_LUMA);\n col *= 1.0 - uGranulation * pigLoad * (paper - 0.5);\n\n // Wash banding — faint horizontal wet gradient\n float band = fbm(vec2(p.x * 1.5, p.y * 0.4));\n col *= 1.0 + 0.04 * (band - 0.5);\n return col;\n}\n\nvec3 mediumPastel(vec3 col, vec2 p, float t) {\n vec2 flow = flowField(p, t);\n vec2 perp = vec2(-flow.y, flow.x);\n float along = dot(p, flow) * uStrokeScale;\n float across = dot(p, perp) * uStrokeScale;\n across += 0.03 * (vnoise(p * 260.0) - 0.5);\n\n float aniso = mix(1.0, 0.18, uStrokeAnisotropy);\n float stroke = fbm(vec2(along * aniso, across));\n col *= mix(1.0, 0.82 + 0.32 * stroke, uStrokeAmount);\n\n // Pastel tooth — tiny high-frequency grain\n float tooth = vnoise(p * 800.0);\n col *= 1.0 - 0.08 * uStrokeAmount * (tooth - 0.5);\n return col;\n}\n\n// ── Curved swept brushstroke primitive ────────────────────────────────────\n// A stroke is a curved spine from A to B with quadratic bulge K (sideways offset\n// at midpoint). Width varies along length via a shape profile. Edge is ragged\n// (bristle-modulated), ends are rounded blobs, inside has streak modulation.\n//\n// For pixel p, we invert an approximate projection onto the curved spine:\n// 1) project p onto straight AB axis -> along0, cross0\n// 2) at parameter along0, spine offset = 4·K·along0·(1-along0) perpendicular\n// 3) cross = cross0 - spineOffset, refine along one iteration\n// Coverage blends paint atop col based on per-stroke color sampled from the\n// underlying base at spine midpoint — so overlapping strokes from different\n// palette regions meet at hard, ragged demarcations.\n\nstruct StrokeHit {\n float coverage; // 0..1\n vec3 color;\n float alongT; // 0..1 along spine, for internal modulation\n float crossN; // cross distance / current half-width, signed\n float edgeN; // distance to edge in half-widths (0 = at edge, 1 = at spine)\n};\n\nStrokeHit noHit() { return StrokeHit(0.0, vec3(0.0), 0.0, 0.0, 0.0); }\n\nvec2 rotateDir(vec2 dir, float angle) {\n float ca = cos(angle), sa = sin(angle);\n return vec2(dir.x * ca - dir.y * sa, dir.x * sa + dir.y * ca);\n}\n\nvec2 safeDir(vec2 dir) {\n float len = length(dir);\n return len > 1e-4 ? dir / len : vec2(1.0, 0.0);\n}\n\n// Shape profile along the stroke. type:\n// 0 tapered — thin-fat-thin (classic brush)\n// 1 load-drag — fat start, tapers to a point\n// 2 dab — ellipse-like, round center\n// 3 even — near-constant, slight end taper\nfloat strokeShape(float t, int type) {\n t = clamp(t, 0.0, 1.0);\n if (type == 1) {\n // loaded at t=0, tapering\n return pow(1.0 - t, 0.55) * smoothstep(0.0, 0.08, t);\n } else if (type == 2) {\n // dab / blob\n float d = t - 0.5;\n return exp(-d * d * 12.0);\n } else if (type == 3) {\n // mostly even, slight end softening\n return smoothstep(0.0, 0.08, t) * smoothstep(1.0, 0.92, t) * 0.95 + 0.05;\n }\n // 0 tapered\n return smoothstep(0.0, 0.22, t) * smoothstep(1.0, 0.78, t);\n}\n\n// A single curved stroke.\n// a, b — endpoints\n// halfW — base half-width (world units)\n// bulge — signed perpendicular midpoint offset, in world units\n// shapeType — 0..3\n// bristleFreq — spatial frequency of edge raggedness\n// bristleAmp — 0..0.5 fraction of halfW chewed away at edge extrema\n// streakSeed — uniqueness seed for internal streaks\n// colAtMid — pre-sampled color at midpoint\nStrokeHit curvedStroke(vec2 p, vec2 a, vec2 b, float halfW,\n float bulge, int shapeType,\n float bristleFreq, float bristleAmp,\n float streakSeed, vec3 colAtMid) {\n vec2 ab = b - a;\n float L = length(ab);\n if (L < 1e-5) return noHit();\n vec2 tang = ab / L;\n vec2 norm = vec2(-tang.y, tang.x);\n\n vec2 rel = p - a;\n float along0 = dot(rel, tang) / L; // straight projection 0..1 along AB\n float cross0 = dot(rel, norm); // signed cross\n\n // Spine sideways offset due to bulge (parabolic)\n float bend = 4.0 * bulge * along0 * (1.0 - along0);\n float cross1 = cross0 - bend;\n\n // One refinement step: as the spine bends, the closest-point along shifts.\n // Spine tangent differs from straight tangent; first-order correction:\n float dBend = 4.0 * bulge * (1.0 - 2.0 * along0); // d(bend)/d(along)\n float along1 = along0 + (cross1 * dBend) / (L * (1.0 + dBend * dBend / (L * L)));\n\n // Bristle-ragged edge: half-width gets chewed by 1D noise along the spine\n float edgeNoise = fbm(vec2(along1 * bristleFreq, streakSeed * 7.3)) - 0.5;\n float edgeNoise2 = fbm(vec2(along1 * bristleFreq * 2.3, streakSeed * 3.1 + 17.0)) - 0.5;\n float edgeMod = 1.0 - bristleAmp * (0.6 + 0.4 * edgeNoise) * (0.5 + edgeNoise2);\n\n // Width profile along the stroke\n float shape = strokeShape(along1, shapeType);\n float halfWNow = halfW * shape * edgeMod;\n\n // Inside-segment coverage\n float cov = 0.0;\n if (along1 >= 0.0 && along1 <= 1.0 && halfWNow > 1e-6) {\n float cn = abs(cross1) / halfWNow;\n // razor-hard edge with tiny aa\n cov = 1.0 - smoothstep(0.88, 1.02, cn);\n }\n\n // End-cap blobs (rounded tips, not perpendicular cuts)\n float capA = 0.0, capB = 0.0;\n {\n vec2 capCenterA = a + norm * (bulge * 0.0); // at a\n vec2 capCenterB = a + tang * L + norm * bend * 0.0 + norm * 0.0; // at b; bend is 0 at endpoints\n capCenterB = b;\n float endShapeA = strokeShape(0.02, shapeType);\n float endShapeB = strokeShape(0.98, shapeType);\n float rA = halfW * endShapeA * (0.9 + 0.2 * fbm(vec2(streakSeed * 13.0)));\n float rB = halfW * endShapeB * (0.9 + 0.2 * fbm(vec2(streakSeed * 19.0 + 5.0)));\n float dA = length(p - capCenterA);\n float dB = length(p - capCenterB);\n capA = 1.0 - smoothstep(rA * 0.85, rA * 1.05, dA);\n capB = 1.0 - smoothstep(rB * 0.85, rB * 1.05, dB);\n // Only apply caps if we're BEYOND the segment; otherwise the segment wins.\n capA *= (along1 < 0.05) ? 1.0 : 0.0;\n capB *= (along1 > 0.95) ? 1.0 : 0.0;\n }\n\n float coverage = max(cov, max(capA, capB));\n if (coverage < 0.002) return noHit();\n\n // Edge distance (for impasto later): 0 at edge, 1 at spine\n float edgeDist = halfWNow > 1e-6 ? clamp(1.0 - abs(cross1) / halfWNow, 0.0, 1.0) : 0.0;\n\n return StrokeHit(\n coverage,\n colAtMid,\n clamp(along1, 0.0, 1.0),\n halfWNow > 1e-6 ? cross1 / halfWNow : 0.0,\n edgeDist\n );\n}\n\n// Composite stroke over col with internal streaking + impasto edge highlight.\n// streakAmp — 0..0.2 how much internal streaks darken/lighten\n// impastoAmp — 0..1 edge catch-light strength\n// hardness — 0..1 how crisp the compositing transition is (1 = razor, 0 = creamy)\nvoid paintOver(inout vec3 col, StrokeHit s, float streakFreq, float streakAmp,\n float impastoAmp, float hardness, float streakSeed) {\n if (s.coverage < 0.002) return;\n float strokeOpacity = clamp(uStrokeAmount, 0.0, 1.0);\n if (strokeOpacity <= 0.001) return;\n vec3 c = s.color;\n\n // Internal streaks — fbm along spine, modulated by cross position. Gives\n // the loaded-brush look: some bristles carry more pigment than others.\n float streakA = fbm(vec2(s.alongT * streakFreq, s.crossN * 2.7 + streakSeed));\n float streakB = fbm(vec2(s.alongT * streakFreq * 0.6 + streakSeed * 3.7, s.crossN * 4.1));\n float streak = 0.6 * (streakA - 0.5) + 0.4 * (streakB - 0.5);\n c *= 1.0 + streak * streakAmp * 2.0;\n\n // Subtle value variance across width (hollow-center catch-light)\n float crossShade = smoothstep(0.0, 0.4, s.edgeN) * (1.0 - smoothstep(0.65, 1.0, s.edgeN));\n c *= 1.0 + crossShade * 0.05;\n\n // Impasto edge highlight — bright rim on one side of the stroke\n float rim = smoothstep(0.85, 1.0, 1.0 - s.edgeN) * step(0.0, s.crossN);\n c += impastoAmp * rim * vec3(0.18, 0.15, 0.11);\n // Shadow on the other side (darker, cooler)\n float shadow = smoothstep(0.85, 1.0, 1.0 - s.edgeN) * step(0.0, -s.crossN);\n c -= impastoAmp * shadow * 0.25 * vec3(0.10, 0.09, 0.07);\n\n float softLimit = mix(0.35, 0.98, hardness);\n float alpha = smoothstep(0.0, 1.0 - softLimit, s.coverage) * strokeOpacity;\n col = mix(col, c, alpha);\n}\n\n// Best-of-9-neighbor placement: sample 3x3 surrounding cells and take the\n// stroke that covers this pixel most. Breaks the grid by per-cell jitter and\n// sparse density via noise thresholding.\nStrokeHit bestOil(vec2 p, float cellSize, float lenMul, float halfWMul,\n float jitterAmt, float density, int shapeType,\n float bristleAmp, vec2 flow, float t, float seed) {\n vec2 cell = floor(p / cellSize);\n\n StrokeHit best = noHit();\n // 3x3 neighborhood\n for (int dy = -1; dy <= 1; dy++) {\n for (int dx = -1; dx <= 1; dx++) {\n vec2 cc = cell + vec2(float(dx), float(dy));\n vec2 hh = hash22(cc + seed) - 0.5;\n // Density gate — noise threshold; sparse placement.\n float gate = hash21(cc * 1.7 + seed * 0.3);\n if (gate > density) continue;\n\n vec2 center = (cc + 0.5 + hh * jitterAmt) * cellSize;\n\n // Per-stroke direction: consume the layer-provided flow, then add only\n // deterministic local perturbation so alternate stroke layers stay live.\n vec2 f = safeDir(flow);\n float angJ = (hash21(cc + seed + 11.0) - 0.5) * 0.9; // +/- 0.45 rad\n float localCurl = (fbm(center * (2.6 + seed * 0.11) + seed * 1.9) - 0.5) * 0.55 * uFlowCurl;\n vec2 dir = rotateDir(f, angJ + localCurl);\n\n float lenV = cellSize * lenMul * (0.65 + 0.55 * hash21(cc + seed + 23.0));\n float halfW = cellSize * halfWMul * (0.70 + 0.55 * hash21(cc + seed + 41.0));\n float bulge = (hash21(cc + seed + 53.0) - 0.5) * lenV * 0.35;\n\n vec2 a = center - dir * (lenV * 0.5);\n vec2 b = center + dir * (lenV * 0.5);\n\n vec3 colMid = brokenColorJitter(\n sampleBase(center, t),\n hash21(cc + seed + 89.0),\n hash21(cc * 2.3 + seed + 97.0),\n 1.0\n );\n\n StrokeHit h = curvedStroke(p, a, b, halfW, bulge, shapeType,\n 7.0, bristleAmp,\n hash21(cc + seed + 67.0), colMid);\n if (h.coverage > best.coverage) best = h;\n }\n }\n return best;\n}\n\n// ── Crayon / oil-pastel — paper tooth × wax pigment ───────────────────────\n// Crayon is not strokes. It's pigment crumbs dragged across paper tooth.\n// Model: heavy 2D tooth noise at multiple scales, anisotropically stretched\n// along flow direction, multiplied into the base color. Add a slow \"waxy\n// film\" that slightly unifies hues, and occasional darker \"pressed\" spots\n// where the crayon dug in. NO straight segments.\nvec3 mediumOil_crayon(vec3 col, vec2 p, float t) {\n vec2 flow = flowField(p, t);\n float ang = atan(flow.y, flow.x);\n float ca = cos(-ang), sa = sin(-ang);\n vec2 pr = vec2(p.x * ca - p.y * sa, p.x * sa + p.y * ca);\n\n // Anisotropic tooth — squished along flow, coarse cross flow.\n float aniso = mix(0.45, 0.95, uStrokeAnisotropy);\n float scale = max(uStrokeScale * 1.6, 180.0);\n\n float t1 = vnoise(vec2(pr.x * scale * aniso, pr.y * scale));\n float t2 = vnoise(vec2(pr.x * scale * aniso * 0.4, pr.y * scale * 0.4) + 11.0);\n float t3 = vnoise(vec2(pr.x * scale * aniso * 2.1, pr.y * scale * 2.1) + 23.0);\n float tooth = 0.55 * t1 + 0.30 * t2 + 0.15 * t3;\n // Center at 0, amplify\n tooth = (tooth - 0.5) * 1.4;\n\n // Multiplicative darkening where tooth is low (pigment skipped paper valleys)\n float lay = 1.0 + tooth * 0.32 * uStrokeAmount;\n vec3 result = col * lay;\n\n // Occasional pressed-in crumbs — rare darker crumbs\n float crumbs = smoothstep(0.78, 0.95, vnoise(pr * scale * 3.0));\n result *= 1.0 - crumbs * 0.18 * uStrokeAmount;\n\n // Waxy highlight film — slight lightening on tooth peaks\n float waxy = smoothstep(0.55, 0.85, t1);\n result += waxy * 0.04 * vec3(1.0);\n\n // Paper tooth overlay (subtler than oil's canvas)\n float paperTooth = vnoise(p * 340.0) - 0.5;\n result *= 1.0 + paperTooth * 0.14 * uCanvasGrain;\n\n // Broken-color pigment: stable wax/pigment patches, not temporal flicker.\n vec2 pigmentCell = floor(pr * max(scale * 0.18, 32.0));\n float pigmentMask = smoothstep(0.28, 0.82, vnoise(pr * scale * 0.21 + 19.0));\n result = brokenColorJitter(\n result,\n hash21(pigmentCell + 17.0),\n hash21(pigmentCell * 2.1 + 31.0),\n 0.45 + 0.55 * pigmentMask\n );\n\n // Crayon is saturation-amplified\n result = saturate3(result, 1.12);\n\n return result;\n}\n\nvec3 mediumOil(vec3 col, vec2 p, float t) {\n // Mode knobs (uStrokeMode):\n // 0 oil — balanced modern-abstract/palette-knife hybrid\n // 1 knife — palette-knife impasto: razor edges, heavy bristle/shadow\n // 2 crayon — soft-edged wax smudges on tooth (no straight segments)\n // 3 brushwork — thick bristle brush\n int mode = uStrokeMode;\n\n // Per-mode parameters\n int shapeType = 0; // tapered\n float bristleAmp = 0.25; // 0..0.5\n float streakFreq = 9.0;\n float streakAmp = 0.09;\n float impastoAmp = 0.9;\n float hardness = 0.80; // edge compositing\n float toothScale = 240.0;\n float toothAmp = 0.09;\n float pigmentSat = 1.03;\n float densityBig = 0.65;\n float densityMed = 0.78;\n float densitySml = 0.90;\n\n if (mode == 1) { // palette knife\n shapeType = 3; // flat, even\n bristleAmp = 0.12;\n streakFreq = 4.0; streakAmp = 0.05;\n impastoAmp = 1.6;\n hardness = 0.95;\n toothAmp = 0.04;\n densityBig = 0.80; densityMed = 0.88; densitySml = 0.70;\n } else if (mode == 2) { // crayon — handled specially below\n return mediumOil_crayon(col, p, t);\n } else if (mode == 3) { // thick brushwork\n shapeType = 0; // tapered\n bristleAmp = 0.32;\n streakFreq = 14.0; streakAmp = 0.14;\n impastoAmp = 1.2;\n hardness = 0.85;\n toothAmp = 0.07;\n }\n\n // Scales & multipliers from uniforms\n float baseScale = max(uStrokeScale * 0.006, 0.008);\n // Three layers: big gestural, medium body, small dabs\n float sBig = baseScale * 2.4;\n float sMed = baseScale * 1.1;\n float sSml = baseScale * 0.45;\n\n float lenMulBig = mix(2.2, 3.8, uStrokeAnisotropy);\n float widMulBig = mix(0.55, 0.32, uStrokeAnisotropy);\n float lenMulMed = mix(2.0, 3.4, uStrokeAnisotropy);\n float widMulMed = mix(0.50, 0.30, uStrokeAnisotropy);\n float lenMulSml = mix(1.6, 2.6, uStrokeAnisotropy);\n float widMulSml = mix(0.45, 0.32, uStrokeAnisotropy);\n\n float jitterAmt = 0.75; // large jitter — no grid\n vec2 flow = flowField(p, t);\n\n vec3 result = col;\n\n // Layer 1 — big gestural strokes (sparse, shaping)\n StrokeHit hBig = bestOil(p, sBig, lenMulBig, widMulBig, jitterAmt * 0.55,\n densityBig, shapeType, bristleAmp, flow, t, 1.3);\n paintOver(result, hBig, streakFreq * 0.7, streakAmp,\n uImpasto * impastoAmp * uStrokeAmount, hardness, 1.3);\n\n // Layer 2 — medium body strokes\n StrokeHit hMed = bestOil(p + vec2(11.3, 3.7), sMed, lenMulMed, widMulMed,\n jitterAmt, densityMed, shapeType, bristleAmp, flow, t, 2.7);\n paintOver(result, hMed, streakFreq, streakAmp,\n uImpasto * impastoAmp * uStrokeAmount, hardness, 2.7);\n\n // Layer 3 — small dabs (more frequent, smaller)\n int smlShape = (mode == 1) ? 2 : shapeType; // knife uses dabs for sparkle\n StrokeHit hSml = bestOil(p + vec2(-5.1, 8.4), sSml, lenMulSml, widMulSml,\n jitterAmt * 1.3, densitySml, smlShape,\n bristleAmp * 0.85, flow, t, 4.1);\n paintOver(result, hSml, streakFreq * 1.4, streakAmp * 0.8,\n uImpasto * impastoAmp * 0.65 * uStrokeAmount, hardness, 4.1);\n\n // Layer 4 — fill dabs (very dense, very small) — covers bald spots\n float sFill = baseScale * 0.22;\n float lenMulFill = mix(1.4, 2.0, uStrokeAnisotropy);\n float widMulFill = mix(0.50, 0.38, uStrokeAnisotropy);\n int fillShape = (mode == 1) ? 3 : 2; // knife=even, others=dab (round fills)\n StrokeHit hFill = bestOil(p + vec2(3.9, -6.2), sFill, lenMulFill, widMulFill,\n jitterAmt * 1.5, 0.95, fillShape,\n bristleAmp * 0.6, flow, t, 8.9);\n paintOver(result, hFill, streakFreq * 1.8, streakAmp * 0.6,\n uImpasto * impastoAmp * 0.4 * uStrokeAmount, hardness * 0.9, 8.9);\n\n // Optional crosshatch layer\n if (uStrokeLayers == 2) {\n vec2 flow2 = vec2(-flow.y, flow.x);\n StrokeHit hX = bestOil(p + vec2(7.3, -2.1), sMed, lenMulMed * 0.9, widMulMed,\n jitterAmt, densityMed * 0.7, shapeType, bristleAmp, flow2, t, 6.5);\n paintOver(result, hX, streakFreq, streakAmp * 0.85,\n uImpasto * impastoAmp * 0.55 * uStrokeAmount, hardness, 6.5);\n }\n\n // Canvas tooth — linen weave\n float tooth1 = vnoise(p * toothScale);\n float tooth2 = vnoise(p * toothScale * vec2(0.6, 2.4) + 37.0);\n float tooth = (0.6 * tooth1 + 0.4 * tooth2) - 0.5;\n result *= 1.0 + tooth * toothAmp * uCanvasGrain;\n\n // Pigment saturation boost\n result = saturate3(result, pigmentSat);\n\n return result;\n}\n\n// ── Main ──────────────────────────────────────────────────────────────────\nvoid main() {\n // Normalized 0..1 coordinates for nuclei, domain warp, and medium sampling.\n vec2 uv = vUv;\n vec2 pN = uv;\n\n float t = uTime;\n\n // Warp in pN space\n vec2 p_warp = domainWarp(pN, t);\n\n // Composition\n float paletteId; float valueMod;\n nucleiField(p_warp, t, paletteId, valueMod);\n vec3 col = samplePalette(paletteId);\n col *= 1.0 + uValueVariance * valueMod;\n\n // Breath — slow global luminance wobble\n float breath = sin(t * 6.2831 / max(uBreathPeriod, 1.0));\n col *= 1.0 + uBreathDepth * breath * 0.5;\n\n // Medium\n if (uMedium == 1) col = mediumPastel(col, pN, t);\n else if (uMedium == 2) col = mediumWatercolor(col, pN, t);\n else if (uMedium == 3) col = mediumOil(col, pN, t);\n\n // Saturation trim\n col = saturate3(col, uSaturation);\n\n // Tonemap + film grain\n col = aces(col);\n float grain = hash21(gl_FragCoord.xy + t * 17.0);\n col += (grain - 0.5) * uPaperGrain;\n\n col = clamp(col * 0.985 + 0.008, 0.0, 1.0);\n fragColor = vec4(col * uAlpha, uAlpha);\n}\n";
|
|
7
|
+
var D = "#version 300 es\nin vec2 aPos;\nout vec2 vUv;\nvoid main() {\n vUv = aPos * 0.5 + 0.5;\n gl_Position = vec4(aPos, 0.0, 1.0);\n}", O = "#version 300 es\nprecision highp float;\n\nin vec2 vUv;\nout vec4 fragColor;\n\n#define MAX_NUCLEI 6\n#define MAX_STOPS 8\n\n// ── Uniforms ───────────────────────────────────────────────────────────────\nuniform float uTime;\n\n// Palette baked CPU-side to linear-sRGB\nuniform vec3 uPalette[MAX_STOPS];\nuniform int uStopCount;\n\n// Nuclei (parallel arrays)\nuniform int uNucleiCount;\nuniform vec2 uNucleiPos[MAX_NUCLEI];\nuniform float uNucleiRadius[MAX_NUCLEI];\nuniform float uNucleiPaletteBias[MAX_NUCLEI];\nuniform float uNucleiValueBias[MAX_NUCLEI];\nuniform float uNucleiDriftRadius[MAX_NUCLEI];\nuniform float uNucleiDriftPhase[MAX_NUCLEI];\n// Anisotropy: per-nucleus elongation (1.0 = isotropic) and major-axis angle (radians).\n// Defaults (1.0 / 0.0) reduce to the original circular Gaussian.\nuniform float uNucleiElong[MAX_NUCLEI];\nuniform float uNucleiAngle[MAX_NUCLEI];\nuniform float uSoftmaxBeta;\nuniform float uValueVariance;\n\n// Warp\nuniform float uWarpAmount;\nuniform float uWarpScale;\nuniform float uWarpDrift;\nuniform int uWarpMode; // 0=fbm 1=cellular 2=hybrid\nuniform int uNoiseOctaves;\n\n// Medium\n// 0 smooth, 1 pastel, 2 watercolor, 3 oil\nuniform int uMedium;\nuniform int uFlowPattern; // 0 none, 1 radial, 2 swirl, 3 diagonal, 4 multi\nuniform vec2 uFlowFocal;\nuniform float uFlowAngle;\nuniform float uFlowCurl;\nuniform vec2 uCursor; // in 0..1 screen space (matches pN)\nuniform float uCursorStrength; // 0..1 attraction amount\nuniform float uCursorRadius; // radius of influence (0.05..0.5)\nuniform float uStrokeAmount;\nuniform float uStrokeScale;\nuniform float uStrokeAnisotropy;\nuniform int uStrokeLayers; // 1 or 2 (crosshatch)\nuniform int uStrokeMode; // 0 oil (modern gestural), 1 palette-knife, 2 crayon/oil-pastel, 3 modern-chunky\nuniform float uWetEdge;\nuniform float uGranulation;\nuniform float uImpasto;\nuniform float uBrokenColor;\nuniform float uCanvasGrain;\n\n// Motion\nuniform float uNucleiDrift;\nuniform float uPaletteDrift;\nuniform float uBreathDepth;\nuniform float uBreathPeriod;\n\n// Output\nuniform float uSaturation;\nuniform float uPaperGrain;\nuniform float uAlpha;\n\n// ── Time rate ────────────────────────────────────────────────────────────────\n// The authoring coefficients (uNucleiDrift, uPaletteDrift, uWarpDrift) live in a\n// human-friendly 0..~0.05 band — that scale is what the config schema and every\n// demo preset are tuned against. But that band, multiplied straight into uTime\n// (seconds), yields rad/sec rates so small the field reads visually static (one\n// nuclei orbit took ~10 min at the old default). These K_* constants decouple\n// the AUTHORING scale from the RAD/SEC scale: each time term wraps its coefficient\n// in the matching K_, lifting the same authored value to a perceptible period\n// without touching any preset. Tuned so the field reads SLOWLY ALIVE — drift over\n// a ~5–15s window, never a frantic pan. These are downstream of uTime, which the\n// runtime FREEZES under reduced-motion (t = frozenOffset) before the shader sees\n// it, so the lift cannot leak motion into the reduced-motion path.\nconst float K_NUCLEI = 14.0; // nuclei orbit: ~one cycle per ~45s at default 0.01\nconst float K_PAL = 24.0; // palette hue breathe: ~one cycle per ~33s at default\nconst float K_WARP = 5.0; // domain warp scroll: a perceptible fbm-cell traverse\n\n// ── Noise ──────────────────────────────────────────────────────────────────\nfloat hash21(vec2 p) {\n p = fract(p * vec2(123.34, 456.21));\n p += dot(p, p + 45.32);\n return fract(p.x * p.y);\n}\n\nvec2 hash22(vec2 p) {\n p = vec2(dot(p, vec2(127.1, 311.7)),\n dot(p, vec2(269.5, 183.3)));\n return fract(sin(p) * 43758.5453);\n}\n\nfloat vnoise(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n vec2 u = f * f * (3.0 - 2.0 * f);\n float a = hash21(i);\n float b = hash21(i + vec2(1.0, 0.0));\n float c = hash21(i + vec2(0.0, 1.0));\n float d = hash21(i + vec2(1.0, 1.0));\n return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);\n}\n\nfloat fbm(vec2 p) {\n float v = 0.0;\n float a = 0.5;\n mat2 r = mat2(0.8, 0.6, -0.6, 0.8);\n for (int i = 0; i < 5; i++) {\n if (i >= uNoiseOctaves) break;\n v += a * vnoise(p);\n p = r * p * 2.02;\n a *= 0.5;\n }\n return v;\n}\n\n// Cellular / Worley f1\nfloat cellular(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n float m = 1e9;\n for (int y = -1; y <= 1; y++) {\n for (int x = -1; x <= 1; x++) {\n vec2 g = vec2(float(x), float(y));\n vec2 o = hash22(i + g);\n vec2 r = g + o - f;\n m = min(m, dot(r, r));\n }\n }\n return sqrt(m);\n}\n\n// ── Warp ──────────────────────────────────────────────────────────────────\nvec2 domainWarp(vec2 p, float t) {\n // Quilez canonical double warp\n vec2 q = vec2(fbm(p * uWarpScale + vec2(0.0, 0.0) + t * uWarpDrift * K_WARP),\n fbm(p * uWarpScale + vec2(5.2, 1.3) + t * uWarpDrift * K_WARP));\n vec2 r = vec2(fbm(p * uWarpScale + 4.0 * q + vec2(1.7, 9.2)),\n fbm(p * uWarpScale + 4.0 * q + vec2(8.3, 2.8)));\n\n vec2 warp = r;\n if (uWarpMode == 1) {\n // cellular — chunky territories (MEADOW block-like)\n float c1 = cellular(p * uWarpScale * 1.5 + vec2(t * uWarpDrift * K_WARP * 2.0, 0.0));\n float c2 = cellular(p * uWarpScale * 1.5 + vec2(11.0, 7.0 + t * uWarpDrift * K_WARP * 2.0));\n warp = vec2(c1, c2);\n } else if (uWarpMode == 2) {\n // hybrid — fbm + cellular averaged\n float c1 = cellular(p * uWarpScale * 1.2);\n float c2 = cellular(p * uWarpScale * 1.2 + vec2(11.0, 7.0));\n warp = mix(r, vec2(c1, c2), 0.5);\n }\n vec2 warped = p + uWarpAmount * warp;\n\n // Cursor swirl — rotate p around uCursor with radial falloff.\n // This warps the underlying color field so the bands sweep around the pointer.\n if (uCursorStrength > 0.001) {\n vec2 toP = p - uCursor;\n float d = length(toP);\n float r = max(uCursorRadius, 0.01);\n // Smooth falloff; strong near cursor, zero beyond ~1.5× radius.\n float w = exp(-(d * d) / (r * r * 0.45));\n // Max rotation ~120° at cursor center, scaled by strength\n float ang = w * uCursorStrength * 2.1;\n float ca = cos(ang), sa = sin(ang);\n vec2 rotated = vec2(ca * toP.x - sa * toP.y, sa * toP.x + ca * toP.y) + uCursor;\n // Also pinch slightly toward the cursor (gravity) — adds depth to swirl\n float pinch = w * uCursorStrength * 0.08;\n rotated = mix(rotated, uCursor, pinch);\n // Blend original warped position with cursor-rotated version\n warped = mix(warped, rotated + uWarpAmount * warp * 0.7, w * uCursorStrength);\n }\n\n return warped;\n}\n\n// ── Palette LUT ───────────────────────────────────────────────────────────\nvec3 samplePalette(float id) {\n id = clamp(id, 0.0, 1.0);\n float scaled = id * float(uStopCount - 1);\n int i0 = int(floor(scaled));\n int i1 = min(i0 + 1, uStopCount - 1);\n float t = fract(scaled);\n t = smoothstep(0.0, 1.0, t);\n return mix(uPalette[i0], uPalette[i1], t);\n}\n\n// ── Nuclei field ──────────────────────────────────────────────────────────\nvoid nucleiField(vec2 p, float t, out float paletteId, out float valueMod) {\n float accumBias = 0.0;\n float accumValue = 0.0;\n float accumW = 0.0;\n for (int i = 0; i < MAX_NUCLEI; i++) {\n if (i >= uNucleiCount) break;\n vec2 posI = uNucleiPos[i]\n + uNucleiDriftRadius[i] * vec2(\n cos(t * uNucleiDrift * K_NUCLEI + uNucleiDriftPhase[i]),\n sin(t * uNucleiDrift * K_NUCLEI + uNucleiDriftPhase[i] * 1.13)\n );\n vec2 diff = p - posI;\n // Anisotropic Gaussian: rotate diff into the nucleus's local frame\n // (major axis along uNucleiAngle), then scale the major-axis component by\n // 1/elongation so the squared distance describes an ellipse. Defaults\n // 1.0/0.0 reduce to the isotropic dot(diff, diff).\n float ca = cos(uNucleiAngle[i]);\n float sa = sin(uNucleiAngle[i]);\n vec2 local = vec2( ca * diff.x + sa * diff.y,\n -sa * diff.x + ca * diff.y);\n float along = local.x / max(uNucleiElong[i], 0.01);\n float across = local.y;\n float d2 = along * along + across * across;\n float r = max(uNucleiRadius[i], 0.01);\n float w = exp(-uSoftmaxBeta * d2 / (r * r));\n accumBias += w * uNucleiPaletteBias[i];\n accumValue += w * uNucleiValueBias[i];\n accumW += w;\n }\n paletteId = accumBias / max(accumW, 1e-4);\n valueMod = accumValue / max(accumW, 1e-4);\n\n // Palette drift — slow global paletteId breathe between adjacent stops. The\n // rate rides K_PAL (perceptible ~30–60s hue cycle at the default coefficient);\n // the amplitude lifts the authored coefficient into a 0.03..0.06 paletteId band\n // so the palette visibly travels rather than dithering within one stop.\n float palAmp = clamp(uPaletteDrift * 6.0, 0.0, 0.06);\n paletteId += palAmp * sin(t * uPaletteDrift * K_PAL);\n paletteId = clamp(paletteId, 0.0, 1.0);\n}\n\n// ── Flow field ────────────────────────────────────────────────────────────\nvec2 flowField(vec2 p, float t) {\n vec2 dir = vec2(1.0, 0.0);\n if (uFlowPattern == 1) {\n // radial\n dir = normalize(p - uFlowFocal + 1e-4);\n } else if (uFlowPattern == 2) {\n // swirl — tangent to radial\n vec2 rad = normalize(p - uFlowFocal + 1e-4);\n dir = vec2(-rad.y, rad.x);\n } else if (uFlowPattern == 3) {\n // diagonal\n float a = radians(uFlowAngle);\n dir = vec2(cos(a), sin(a));\n } else if (uFlowPattern == 4) {\n // multi — curl-noise driven\n float n = fbm(p * 2.0 + t * 0.02);\n float a = n * 6.2831;\n dir = vec2(cos(a), sin(a));\n }\n // curl — perturb by noise. Radial gets much less curl so rays stay clean.\n if (uFlowCurl > 0.0) {\n float n = fbm(p * 3.0) - 0.5;\n float curlAmt = uFlowCurl;\n if (uFlowPattern == 1) curlAmt *= 0.25; // radial: preserve ray clarity\n if (uFlowPattern == 2) curlAmt *= 0.55; // swirl: allow moderate curl\n float a = atan(dir.y, dir.x) + n * 3.14159 * curlAmt;\n dir = vec2(cos(a), sin(a));\n }\n // cursor influence — swirl around the cursor position\n if (uCursorStrength > 0.001) {\n vec2 toCur = uCursor - p;\n float d = length(toCur);\n float r = max(uCursorRadius, 0.01);\n float w = exp(-(d * d) / (r * r * 0.5));\n // swirl tangent\n vec2 tangent = vec2(-toCur.y, toCur.x) / max(d, 1e-4);\n float a0 = atan(dir.y, dir.x);\n float a1 = atan(tangent.y, tangent.x);\n // blend angle\n float da = a1 - a0;\n da = atan(sin(da), cos(da)); // wrap to [-pi, pi]\n float a = a0 + da * w * uCursorStrength;\n dir = vec2(cos(a), sin(a));\n }\n return dir;\n}\n\n// ── Color utils ───────────────────────────────────────────────────────────\nconst vec3 W_LUMA = vec3(0.2126, 0.7152, 0.0722);\n\nvec3 hueShift(vec3 c, float degrees) {\n float a = radians(degrees);\n float co = cos(a), si = sin(a);\n mat3 m = mat3(\n 0.299 + 0.701 * co + 0.168 * si,\n 0.587 - 0.587 * co + 0.330 * si,\n 0.114 - 0.114 * co - 0.497 * si,\n\n 0.299 - 0.299 * co - 0.328 * si,\n 0.587 + 0.413 * co + 0.035 * si,\n 0.114 - 0.114 * co + 0.292 * si,\n\n 0.299 - 0.300 * co + 1.250 * si,\n 0.587 - 0.588 * co - 1.050 * si,\n 0.114 + 0.886 * co - 0.203 * si\n );\n return m * c;\n}\n\nvec3 brokenColorJitter(vec3 c, float hueSeed, float valueSeed, float strength) {\n float amt = clamp(uBrokenColor * strength, 0.0, 1.0);\n if (amt <= 0.001) return c;\n float hueDeg = (hueSeed - 0.5) * 32.0 * amt;\n float valueMul = 1.0 + (valueSeed - 0.5) * 0.28 * amt;\n return max(hueShift(c, hueDeg) * valueMul, vec3(0.0));\n}\n\nvec3 saturate3(vec3 c, float amt) {\n float l = dot(c, W_LUMA);\n return mix(vec3(l), c, amt);\n}\n\n// ACES approximation\nvec3 aces(vec3 x) {\n float a = 2.51;\n float b = 0.03;\n float c = 2.43;\n float d = 0.59;\n float e = 0.14;\n return clamp((x * (a * x + b)) / (x * (c * x + d) + e), 0.0, 1.0);\n}\n\n// ── Medium overlays ───────────────────────────────────────────────────────\n\n// A quick re-computation of base color for edge-mask sampling\nvec3 sampleBase(vec2 p, float t) {\n vec2 pw = domainWarp(p, t);\n float id; float vm;\n nucleiField(pw, t, id, vm);\n vec3 c = samplePalette(id);\n c *= 1.0 + uValueVariance * vm;\n return c;\n}\n\nvec3 mediumWatercolor(vec3 col, vec2 p, float t) {\n // Wet-edge cauliflowers via luma-gradient magnitude\n float eps = 0.004;\n vec3 cx1 = sampleBase(p + vec2(eps, 0.0), t);\n vec3 cx2 = sampleBase(p - vec2(eps, 0.0), t);\n vec3 cy1 = sampleBase(p + vec2(0.0, eps), t);\n vec3 cy2 = sampleBase(p - vec2(0.0, eps), t);\n float gx = dot(cx1 - cx2, W_LUMA);\n float gy = dot(cy1 - cy2, W_LUMA);\n float edge = sqrt(gx * gx + gy * gy) / (2.0 * eps);\n float mask = smoothstep(0.0, 2.5, edge);\n col *= mix(1.0, 0.78, mask * uWetEdge);\n\n // Granulation — pigment settles in paper tooth\n float paper = 0.5 * vnoise(p * 160.0) + 0.5 * vnoise(p * 360.0);\n float pigLoad = 1.0 - dot(col, W_LUMA);\n col *= 1.0 - uGranulation * pigLoad * (paper - 0.5);\n\n // Wash banding — faint horizontal wet gradient\n float band = fbm(vec2(p.x * 1.5, p.y * 0.4));\n col *= 1.0 + 0.04 * (band - 0.5);\n return col;\n}\n\nvec3 mediumPastel(vec3 col, vec2 p, float t) {\n vec2 flow = flowField(p, t);\n vec2 perp = vec2(-flow.y, flow.x);\n float along = dot(p, flow) * uStrokeScale;\n float across = dot(p, perp) * uStrokeScale;\n across += 0.03 * (vnoise(p * 260.0) - 0.5);\n\n float aniso = mix(1.0, 0.18, uStrokeAnisotropy);\n float stroke = fbm(vec2(along * aniso, across));\n col *= mix(1.0, 0.82 + 0.32 * stroke, uStrokeAmount);\n\n // Pastel tooth — tiny high-frequency grain\n float tooth = vnoise(p * 800.0);\n col *= 1.0 - 0.08 * uStrokeAmount * (tooth - 0.5);\n return col;\n}\n\n// ── Curved swept brushstroke primitive ────────────────────────────────────\n// A stroke is a curved spine from A to B with quadratic bulge K (sideways offset\n// at midpoint). Width varies along length via a shape profile. Edge is ragged\n// (bristle-modulated), ends are rounded blobs, inside has streak modulation.\n//\n// For pixel p, we invert an approximate projection onto the curved spine:\n// 1) project p onto straight AB axis -> along0, cross0\n// 2) at parameter along0, spine offset = 4·K·along0·(1-along0) perpendicular\n// 3) cross = cross0 - spineOffset, refine along one iteration\n// Coverage blends paint atop col based on per-stroke color sampled from the\n// underlying base at spine midpoint — so overlapping strokes from different\n// palette regions meet at hard, ragged demarcations.\n\nstruct StrokeHit {\n float coverage; // 0..1\n vec3 color;\n float alongT; // 0..1 along spine, for internal modulation\n float crossN; // cross distance / current half-width, signed\n float edgeN; // distance to edge in half-widths (0 = at edge, 1 = at spine)\n};\n\nStrokeHit noHit() { return StrokeHit(0.0, vec3(0.0), 0.0, 0.0, 0.0); }\n\nvec2 rotateDir(vec2 dir, float angle) {\n float ca = cos(angle), sa = sin(angle);\n return vec2(dir.x * ca - dir.y * sa, dir.x * sa + dir.y * ca);\n}\n\nvec2 safeDir(vec2 dir) {\n float len = length(dir);\n return len > 1e-4 ? dir / len : vec2(1.0, 0.0);\n}\n\n// Shape profile along the stroke. type:\n// 0 tapered — thin-fat-thin (classic brush)\n// 1 load-drag — fat start, tapers to a point\n// 2 dab — ellipse-like, round center\n// 3 even — near-constant, slight end taper\nfloat strokeShape(float t, int type) {\n t = clamp(t, 0.0, 1.0);\n if (type == 1) {\n // loaded at t=0, tapering\n return pow(1.0 - t, 0.55) * smoothstep(0.0, 0.08, t);\n } else if (type == 2) {\n // dab / blob\n float d = t - 0.5;\n return exp(-d * d * 12.0);\n } else if (type == 3) {\n // mostly even, slight end softening\n return smoothstep(0.0, 0.08, t) * smoothstep(1.0, 0.92, t) * 0.95 + 0.05;\n }\n // 0 tapered\n return smoothstep(0.0, 0.22, t) * smoothstep(1.0, 0.78, t);\n}\n\n// A single curved stroke.\n// a, b — endpoints\n// halfW — base half-width (world units)\n// bulge — signed perpendicular midpoint offset, in world units\n// shapeType — 0..3\n// bristleFreq — spatial frequency of edge raggedness\n// bristleAmp — 0..0.5 fraction of halfW chewed away at edge extrema\n// streakSeed — uniqueness seed for internal streaks\n// colAtMid — pre-sampled color at midpoint\nStrokeHit curvedStroke(vec2 p, vec2 a, vec2 b, float halfW,\n float bulge, int shapeType,\n float bristleFreq, float bristleAmp,\n float streakSeed, vec3 colAtMid) {\n vec2 ab = b - a;\n float L = length(ab);\n if (L < 1e-5) return noHit();\n vec2 tang = ab / L;\n vec2 norm = vec2(-tang.y, tang.x);\n\n vec2 rel = p - a;\n float along0 = dot(rel, tang) / L; // straight projection 0..1 along AB\n float cross0 = dot(rel, norm); // signed cross\n\n // Spine sideways offset due to bulge (parabolic)\n float bend = 4.0 * bulge * along0 * (1.0 - along0);\n float cross1 = cross0 - bend;\n\n // One refinement step: as the spine bends, the closest-point along shifts.\n // Spine tangent differs from straight tangent; first-order correction:\n float dBend = 4.0 * bulge * (1.0 - 2.0 * along0); // d(bend)/d(along)\n float along1 = along0 + (cross1 * dBend) / (L * (1.0 + dBend * dBend / (L * L)));\n\n // Bristle-ragged edge: half-width gets chewed by 1D noise along the spine\n float edgeNoise = fbm(vec2(along1 * bristleFreq, streakSeed * 7.3)) - 0.5;\n float edgeNoise2 = fbm(vec2(along1 * bristleFreq * 2.3, streakSeed * 3.1 + 17.0)) - 0.5;\n float edgeMod = 1.0 - bristleAmp * (0.6 + 0.4 * edgeNoise) * (0.5 + edgeNoise2);\n\n // Width profile along the stroke\n float shape = strokeShape(along1, shapeType);\n float halfWNow = halfW * shape * edgeMod;\n\n // Inside-segment coverage\n float cov = 0.0;\n if (along1 >= 0.0 && along1 <= 1.0 && halfWNow > 1e-6) {\n float cn = abs(cross1) / halfWNow;\n // razor-hard edge with tiny aa\n cov = 1.0 - smoothstep(0.88, 1.02, cn);\n }\n\n // End-cap blobs (rounded tips, not perpendicular cuts)\n float capA = 0.0, capB = 0.0;\n {\n vec2 capCenterA = a + norm * (bulge * 0.0); // at a\n vec2 capCenterB = a + tang * L + norm * bend * 0.0 + norm * 0.0; // at b; bend is 0 at endpoints\n capCenterB = b;\n float endShapeA = strokeShape(0.02, shapeType);\n float endShapeB = strokeShape(0.98, shapeType);\n float rA = halfW * endShapeA * (0.9 + 0.2 * fbm(vec2(streakSeed * 13.0)));\n float rB = halfW * endShapeB * (0.9 + 0.2 * fbm(vec2(streakSeed * 19.0 + 5.0)));\n float dA = length(p - capCenterA);\n float dB = length(p - capCenterB);\n capA = 1.0 - smoothstep(rA * 0.85, rA * 1.05, dA);\n capB = 1.0 - smoothstep(rB * 0.85, rB * 1.05, dB);\n // Only apply caps if we're BEYOND the segment; otherwise the segment wins.\n capA *= (along1 < 0.05) ? 1.0 : 0.0;\n capB *= (along1 > 0.95) ? 1.0 : 0.0;\n }\n\n float coverage = max(cov, max(capA, capB));\n if (coverage < 0.002) return noHit();\n\n // Edge distance (for impasto later): 0 at edge, 1 at spine\n float edgeDist = halfWNow > 1e-6 ? clamp(1.0 - abs(cross1) / halfWNow, 0.0, 1.0) : 0.0;\n\n return StrokeHit(\n coverage,\n colAtMid,\n clamp(along1, 0.0, 1.0),\n halfWNow > 1e-6 ? cross1 / halfWNow : 0.0,\n edgeDist\n );\n}\n\n// Composite stroke over col with internal streaking + impasto edge highlight.\n// streakAmp — 0..0.2 how much internal streaks darken/lighten\n// impastoAmp — 0..1 edge catch-light strength\n// hardness — 0..1 how crisp the compositing transition is (1 = razor, 0 = creamy)\nvoid paintOver(inout vec3 col, StrokeHit s, float streakFreq, float streakAmp,\n float impastoAmp, float hardness, float streakSeed) {\n if (s.coverage < 0.002) return;\n float strokeOpacity = clamp(uStrokeAmount, 0.0, 1.0);\n if (strokeOpacity <= 0.001) return;\n vec3 c = s.color;\n\n // Internal streaks — fbm along spine, modulated by cross position. Gives\n // the loaded-brush look: some bristles carry more pigment than others.\n float streakA = fbm(vec2(s.alongT * streakFreq, s.crossN * 2.7 + streakSeed));\n float streakB = fbm(vec2(s.alongT * streakFreq * 0.6 + streakSeed * 3.7, s.crossN * 4.1));\n float streak = 0.6 * (streakA - 0.5) + 0.4 * (streakB - 0.5);\n c *= 1.0 + streak * streakAmp * 2.0;\n\n // Subtle value variance across width (hollow-center catch-light)\n float crossShade = smoothstep(0.0, 0.4, s.edgeN) * (1.0 - smoothstep(0.65, 1.0, s.edgeN));\n c *= 1.0 + crossShade * 0.05;\n\n // Impasto edge highlight — bright rim on one side of the stroke\n float rim = smoothstep(0.85, 1.0, 1.0 - s.edgeN) * step(0.0, s.crossN);\n c += impastoAmp * rim * vec3(0.18, 0.15, 0.11);\n // Shadow on the other side (darker, cooler)\n float shadow = smoothstep(0.85, 1.0, 1.0 - s.edgeN) * step(0.0, -s.crossN);\n c -= impastoAmp * shadow * 0.25 * vec3(0.10, 0.09, 0.07);\n\n float softLimit = mix(0.35, 0.98, hardness);\n float alpha = smoothstep(0.0, 1.0 - softLimit, s.coverage) * strokeOpacity;\n col = mix(col, c, alpha);\n}\n\n// Best-of-9-neighbor placement: sample 3x3 surrounding cells and take the\n// stroke that covers this pixel most. Breaks the grid by per-cell jitter and\n// sparse density via noise thresholding.\nStrokeHit bestOil(vec2 p, float cellSize, float lenMul, float halfWMul,\n float jitterAmt, float density, int shapeType,\n float bristleAmp, vec2 flow, float t, float seed) {\n vec2 cell = floor(p / cellSize);\n\n StrokeHit best = noHit();\n // 3x3 neighborhood\n for (int dy = -1; dy <= 1; dy++) {\n for (int dx = -1; dx <= 1; dx++) {\n vec2 cc = cell + vec2(float(dx), float(dy));\n vec2 hh = hash22(cc + seed) - 0.5;\n // Density gate — noise threshold; sparse placement.\n float gate = hash21(cc * 1.7 + seed * 0.3);\n if (gate > density) continue;\n\n vec2 center = (cc + 0.5 + hh * jitterAmt) * cellSize;\n\n // Per-stroke direction: consume the layer-provided flow, then add only\n // deterministic local perturbation so alternate stroke layers stay live.\n vec2 f = safeDir(flow);\n float angJ = (hash21(cc + seed + 11.0) - 0.5) * 0.9; // +/- 0.45 rad\n float localCurl = (fbm(center * (2.6 + seed * 0.11) + seed * 1.9) - 0.5) * 0.55 * uFlowCurl;\n vec2 dir = rotateDir(f, angJ + localCurl);\n\n float lenV = cellSize * lenMul * (0.65 + 0.55 * hash21(cc + seed + 23.0));\n float halfW = cellSize * halfWMul * (0.70 + 0.55 * hash21(cc + seed + 41.0));\n float bulge = (hash21(cc + seed + 53.0) - 0.5) * lenV * 0.35;\n\n vec2 a = center - dir * (lenV * 0.5);\n vec2 b = center + dir * (lenV * 0.5);\n\n vec3 colMid = brokenColorJitter(\n sampleBase(center, t),\n hash21(cc + seed + 89.0),\n hash21(cc * 2.3 + seed + 97.0),\n 1.0\n );\n\n StrokeHit h = curvedStroke(p, a, b, halfW, bulge, shapeType,\n 7.0, bristleAmp,\n hash21(cc + seed + 67.0), colMid);\n if (h.coverage > best.coverage) best = h;\n }\n }\n return best;\n}\n\n// ── Crayon / oil-pastel — paper tooth × wax pigment ───────────────────────\n// Crayon is not strokes. It's pigment crumbs dragged across paper tooth.\n// Model: heavy 2D tooth noise at multiple scales, anisotropically stretched\n// along flow direction, multiplied into the base color. Add a slow \"waxy\n// film\" that slightly unifies hues, and occasional darker \"pressed\" spots\n// where the crayon dug in. NO straight segments.\nvec3 mediumOil_crayon(vec3 col, vec2 p, float t) {\n vec2 flow = flowField(p, t);\n float ang = atan(flow.y, flow.x);\n float ca = cos(-ang), sa = sin(-ang);\n vec2 pr = vec2(p.x * ca - p.y * sa, p.x * sa + p.y * ca);\n\n // Anisotropic tooth — squished along flow, coarse cross flow.\n float aniso = mix(0.45, 0.95, uStrokeAnisotropy);\n float scale = max(uStrokeScale * 1.6, 180.0);\n\n float t1 = vnoise(vec2(pr.x * scale * aniso, pr.y * scale));\n float t2 = vnoise(vec2(pr.x * scale * aniso * 0.4, pr.y * scale * 0.4) + 11.0);\n float t3 = vnoise(vec2(pr.x * scale * aniso * 2.1, pr.y * scale * 2.1) + 23.0);\n float tooth = 0.55 * t1 + 0.30 * t2 + 0.15 * t3;\n // Center at 0, amplify\n tooth = (tooth - 0.5) * 1.4;\n\n // Multiplicative darkening where tooth is low (pigment skipped paper valleys)\n float lay = 1.0 + tooth * 0.32 * uStrokeAmount;\n vec3 result = col * lay;\n\n // Occasional pressed-in crumbs — rare darker crumbs\n float crumbs = smoothstep(0.78, 0.95, vnoise(pr * scale * 3.0));\n result *= 1.0 - crumbs * 0.18 * uStrokeAmount;\n\n // Waxy highlight film — slight lightening on tooth peaks\n float waxy = smoothstep(0.55, 0.85, t1);\n result += waxy * 0.04 * vec3(1.0);\n\n // Paper tooth overlay (subtler than oil's canvas)\n float paperTooth = vnoise(p * 340.0) - 0.5;\n result *= 1.0 + paperTooth * 0.14 * uCanvasGrain;\n\n // Broken-color pigment: stable wax/pigment patches, not temporal flicker.\n vec2 pigmentCell = floor(pr * max(scale * 0.18, 32.0));\n float pigmentMask = smoothstep(0.28, 0.82, vnoise(pr * scale * 0.21 + 19.0));\n result = brokenColorJitter(\n result,\n hash21(pigmentCell + 17.0),\n hash21(pigmentCell * 2.1 + 31.0),\n 0.45 + 0.55 * pigmentMask\n );\n\n // Crayon is saturation-amplified\n result = saturate3(result, 1.12);\n\n return result;\n}\n\nvec3 mediumOil(vec3 col, vec2 p, float t) {\n // Mode knobs (uStrokeMode):\n // 0 oil — balanced modern-abstract/palette-knife hybrid\n // 1 knife — palette-knife impasto: razor edges, heavy bristle/shadow\n // 2 crayon — soft-edged wax smudges on tooth (no straight segments)\n // 3 brushwork — thick bristle brush\n int mode = uStrokeMode;\n\n // Per-mode parameters\n int shapeType = 0; // tapered\n float bristleAmp = 0.25; // 0..0.5\n float streakFreq = 9.0;\n float streakAmp = 0.09;\n float impastoAmp = 0.9;\n float hardness = 0.80; // edge compositing\n float toothScale = 240.0;\n float toothAmp = 0.09;\n float pigmentSat = 1.03;\n float densityBig = 0.65;\n float densityMed = 0.78;\n float densitySml = 0.90;\n\n if (mode == 1) { // palette knife\n shapeType = 3; // flat, even\n bristleAmp = 0.12;\n streakFreq = 4.0; streakAmp = 0.05;\n impastoAmp = 1.6;\n hardness = 0.95;\n toothAmp = 0.04;\n densityBig = 0.80; densityMed = 0.88; densitySml = 0.70;\n } else if (mode == 2) { // crayon — handled specially below\n return mediumOil_crayon(col, p, t);\n } else if (mode == 3) { // thick brushwork\n shapeType = 0; // tapered\n bristleAmp = 0.32;\n streakFreq = 14.0; streakAmp = 0.14;\n impastoAmp = 1.2;\n hardness = 0.85;\n toothAmp = 0.07;\n }\n\n // Scales & multipliers from uniforms\n float baseScale = max(uStrokeScale * 0.006, 0.008);\n // Three layers: big gestural, medium body, small dabs\n float sBig = baseScale * 2.4;\n float sMed = baseScale * 1.1;\n float sSml = baseScale * 0.45;\n\n float lenMulBig = mix(2.2, 3.8, uStrokeAnisotropy);\n float widMulBig = mix(0.55, 0.32, uStrokeAnisotropy);\n float lenMulMed = mix(2.0, 3.4, uStrokeAnisotropy);\n float widMulMed = mix(0.50, 0.30, uStrokeAnisotropy);\n float lenMulSml = mix(1.6, 2.6, uStrokeAnisotropy);\n float widMulSml = mix(0.45, 0.32, uStrokeAnisotropy);\n\n float jitterAmt = 0.75; // large jitter — no grid\n vec2 flow = flowField(p, t);\n\n vec3 result = col;\n\n // Layer 1 — big gestural strokes (sparse, shaping)\n StrokeHit hBig = bestOil(p, sBig, lenMulBig, widMulBig, jitterAmt * 0.55,\n densityBig, shapeType, bristleAmp, flow, t, 1.3);\n paintOver(result, hBig, streakFreq * 0.7, streakAmp,\n uImpasto * impastoAmp * uStrokeAmount, hardness, 1.3);\n\n // Layer 2 — medium body strokes\n StrokeHit hMed = bestOil(p + vec2(11.3, 3.7), sMed, lenMulMed, widMulMed,\n jitterAmt, densityMed, shapeType, bristleAmp, flow, t, 2.7);\n paintOver(result, hMed, streakFreq, streakAmp,\n uImpasto * impastoAmp * uStrokeAmount, hardness, 2.7);\n\n // Layer 3 — small dabs (more frequent, smaller)\n int smlShape = (mode == 1) ? 2 : shapeType; // knife uses dabs for sparkle\n StrokeHit hSml = bestOil(p + vec2(-5.1, 8.4), sSml, lenMulSml, widMulSml,\n jitterAmt * 1.3, densitySml, smlShape,\n bristleAmp * 0.85, flow, t, 4.1);\n paintOver(result, hSml, streakFreq * 1.4, streakAmp * 0.8,\n uImpasto * impastoAmp * 0.65 * uStrokeAmount, hardness, 4.1);\n\n // Layer 4 — fill dabs (very dense, very small) — covers bald spots\n float sFill = baseScale * 0.22;\n float lenMulFill = mix(1.4, 2.0, uStrokeAnisotropy);\n float widMulFill = mix(0.50, 0.38, uStrokeAnisotropy);\n int fillShape = (mode == 1) ? 3 : 2; // knife=even, others=dab (round fills)\n StrokeHit hFill = bestOil(p + vec2(3.9, -6.2), sFill, lenMulFill, widMulFill,\n jitterAmt * 1.5, 0.95, fillShape,\n bristleAmp * 0.6, flow, t, 8.9);\n paintOver(result, hFill, streakFreq * 1.8, streakAmp * 0.6,\n uImpasto * impastoAmp * 0.4 * uStrokeAmount, hardness * 0.9, 8.9);\n\n // Optional crosshatch layer\n if (uStrokeLayers == 2) {\n vec2 flow2 = vec2(-flow.y, flow.x);\n StrokeHit hX = bestOil(p + vec2(7.3, -2.1), sMed, lenMulMed * 0.9, widMulMed,\n jitterAmt, densityMed * 0.7, shapeType, bristleAmp, flow2, t, 6.5);\n paintOver(result, hX, streakFreq, streakAmp * 0.85,\n uImpasto * impastoAmp * 0.55 * uStrokeAmount, hardness, 6.5);\n }\n\n // Canvas tooth — linen weave\n float tooth1 = vnoise(p * toothScale);\n float tooth2 = vnoise(p * toothScale * vec2(0.6, 2.4) + 37.0);\n float tooth = (0.6 * tooth1 + 0.4 * tooth2) - 0.5;\n result *= 1.0 + tooth * toothAmp * uCanvasGrain;\n\n // Pigment saturation boost\n result = saturate3(result, pigmentSat);\n\n return result;\n}\n\n// ── Main ──────────────────────────────────────────────────────────────────\nvoid main() {\n // Normalized 0..1 coordinates for nuclei, domain warp, and medium sampling.\n vec2 uv = vUv;\n vec2 pN = uv;\n\n float t = uTime;\n\n // Warp in pN space\n vec2 p_warp = domainWarp(pN, t);\n\n // Composition\n float paletteId; float valueMod;\n nucleiField(p_warp, t, paletteId, valueMod);\n vec3 col = samplePalette(paletteId);\n col *= 1.0 + uValueVariance * valueMod;\n\n // Breath — slow global luminance wobble\n float breath = sin(t * 6.2831 / max(uBreathPeriod, 1.0));\n col *= 1.0 + uBreathDepth * breath * 0.5;\n\n // Medium\n if (uMedium == 1) col = mediumPastel(col, pN, t);\n else if (uMedium == 2) col = mediumWatercolor(col, pN, t);\n else if (uMedium == 3) col = mediumOil(col, pN, t);\n\n // Saturation trim\n col = saturate3(col, uSaturation);\n\n // Tonemap + film grain\n col = aces(col);\n float grain = hash21(gl_FragCoord.xy + t * 17.0);\n col += (grain - 0.5) * uPaperGrain;\n\n col = clamp(col * 0.985 + 0.008, 0.0, 1.0);\n fragColor = vec4(col * uAlpha, uAlpha);\n}\n";
|
|
7
8
|
//#endregion
|
|
8
9
|
//#region src/components/custom/aurora/composables/color.ts
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
function x(e) {
|
|
13
|
-
return e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
|
|
14
|
-
}
|
|
15
|
-
function S(e) {
|
|
16
|
-
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
17
|
-
}
|
|
18
|
-
function C(e, t, n) {
|
|
19
|
-
let r = x(e), i = x(t), a = x(n), o = Math.cbrt(.4122214708 * r + .5363325363 * i + .0514459929 * a), s = Math.cbrt(.2119034982 * r + .6806995451 * i + .1073969566 * a), c = Math.cbrt(.0883024619 * r + .2817188376 * i + .6299787005 * a);
|
|
20
|
-
return [
|
|
21
|
-
.2104542553 * o + .793617785 * s - .0040720468 * c,
|
|
22
|
-
1.9779984951 * o - 2.428592205 * s + .4505937099 * c,
|
|
23
|
-
.0259040371 * o + .7827717662 * s - .808675766 * c
|
|
24
|
-
];
|
|
25
|
-
}
|
|
26
|
-
function w(e, t, n) {
|
|
27
|
-
return [
|
|
28
|
-
e,
|
|
29
|
-
Math.sqrt(t * t + n * n),
|
|
30
|
-
(Math.atan2(n, t) * 180 / Math.PI + 360) % 360
|
|
31
|
-
];
|
|
32
|
-
}
|
|
33
|
-
function T(e, t, n) {
|
|
34
|
-
let r = n * Math.PI / 180;
|
|
35
|
-
return [
|
|
36
|
-
e,
|
|
37
|
-
t * Math.cos(r),
|
|
38
|
-
t * Math.sin(r)
|
|
39
|
-
];
|
|
40
|
-
}
|
|
41
|
-
function E(e, t, n) {
|
|
42
|
-
let r = e + .3963377774 * t + .2158037573 * n, i = e - .1055613458 * t - .0638541728 * n, a = e - .0894841775 * t - 1.291485548 * n, o = r * r * r, s = i * i * i, c = a * a * a;
|
|
43
|
-
return [
|
|
44
|
-
4.0767416621 * o - 3.3077115913 * s + .2309699292 * c,
|
|
45
|
-
-1.2684380046 * o + 2.6097574011 * s - .3413193965 * c,
|
|
46
|
-
-.0041960863 * o - .7034186147 * s + 1.707614701 * c
|
|
47
|
-
];
|
|
48
|
-
}
|
|
49
|
-
function D(e, t, n) {
|
|
50
|
-
let [r, i, a] = E(e, t, n);
|
|
51
|
-
return [
|
|
52
|
-
b(Math.round(S(r) * 255), 0, 255),
|
|
53
|
-
b(Math.round(S(i) * 255), 0, 255),
|
|
54
|
-
b(Math.round(S(a) * 255), 0, 255)
|
|
55
|
-
];
|
|
56
|
-
}
|
|
57
|
-
function O(e, t, n) {
|
|
58
|
-
let [r, i, a] = C(e / 255, t / 255, n / 255);
|
|
59
|
-
return w(r, i, a);
|
|
60
|
-
}
|
|
61
|
-
function k(e, t, n) {
|
|
62
|
-
let [r, i, a] = T(e, t, n);
|
|
63
|
-
return D(r, i, a);
|
|
64
|
-
}
|
|
65
|
-
function A(e) {
|
|
66
|
-
let [t, n, r] = T(e.L, e.C, e.h), [i, a, o] = E(t, n, r);
|
|
10
|
+
function k(e) {
|
|
11
|
+
let [t, n, r] = T(e.L, e.C, e.h), [i, a, o] = x(t, n, r);
|
|
67
12
|
return [
|
|
68
13
|
Math.max(0, i),
|
|
69
14
|
Math.max(0, a),
|
|
70
15
|
Math.max(0, o)
|
|
71
16
|
];
|
|
72
17
|
}
|
|
73
|
-
function
|
|
18
|
+
function A(e, t = 8, n) {
|
|
74
19
|
let r = n ?? new Float32Array(t * 3), i = Math.min(e.length, t);
|
|
75
20
|
for (let t = 0; t < i; t++) {
|
|
76
|
-
let [n, i, a] =
|
|
21
|
+
let [n, i, a] = k(e[t]);
|
|
77
22
|
r[t * 3 + 0] = n, r[t * 3 + 1] = i, r[t * 3 + 2] = a;
|
|
78
23
|
}
|
|
79
24
|
for (let e = i; e < t; e++) r[e * 3 + 0] = 0, r[e * 3 + 1] = 0, r[e * 3 + 2] = 0;
|
|
80
25
|
return r;
|
|
81
26
|
}
|
|
82
|
-
function
|
|
27
|
+
function j(e) {
|
|
83
28
|
if (e.length === 0) return "transparent";
|
|
84
|
-
if (e.length === 1) return
|
|
29
|
+
if (e.length === 1) return M(e[0]);
|
|
85
30
|
let t = e.length;
|
|
86
31
|
return `linear-gradient(135deg, ${e.map((e, n) => {
|
|
87
32
|
let r = Math.round(n / (t - 1) * 100);
|
|
88
|
-
return `${
|
|
33
|
+
return `${M(e)} ${r}%`;
|
|
89
34
|
}).join(", ")})`;
|
|
90
35
|
}
|
|
36
|
+
function M(e) {
|
|
37
|
+
let [t, n, r] = T(e.L, e.C, e.h), [i, a, o] = S(t, n, r), s = (e) => Math.round(e).toString(16).padStart(2, "0");
|
|
38
|
+
return `#${s(i)}${s(a)}${s(o)}`;
|
|
39
|
+
}
|
|
91
40
|
function N(e) {
|
|
92
|
-
let
|
|
93
|
-
return
|
|
41
|
+
let t = e.replace("#", ""), n = parseInt(t.slice(0, 2), 16), r = parseInt(t.slice(2, 4), 16), i = parseInt(t.slice(4, 6), 16), [a, o, s] = E(n / 255, r / 255, i / 255), [c, l, u] = w(a, o, s);
|
|
42
|
+
return {
|
|
43
|
+
L: c,
|
|
44
|
+
C: l,
|
|
45
|
+
h: u
|
|
46
|
+
};
|
|
94
47
|
}
|
|
95
48
|
function P(e) {
|
|
96
|
-
let t = e
|
|
49
|
+
let t = v(C(e), "rgb").value, [n, r, i] = E(Number(t.r), Number(t.g), Number(t.b)), [a, o, s] = w(n, r, i);
|
|
97
50
|
return {
|
|
98
|
-
L:
|
|
99
|
-
C:
|
|
100
|
-
h:
|
|
51
|
+
L: a,
|
|
52
|
+
C: o,
|
|
53
|
+
h: s
|
|
101
54
|
};
|
|
102
55
|
}
|
|
103
|
-
var F =
|
|
104
|
-
function I(e) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
56
|
+
var F = [.35, .95];
|
|
57
|
+
function I(e, t = {}) {
|
|
58
|
+
let n = typeof e == "string" ? P(e) : e, { stopCount: r = 4, harmony: i = "analogous", lightnessSpread: a = .32, chromaFalloff: o = .85, hueSpread: s = 28 } = t, c = Math.max(2, Math.min(8, Math.round(r))), [l, u] = F, d = n.L - a / 2, f = n.L + a / 2;
|
|
59
|
+
d < l && (f += l - d, d = l), f > u && (d -= f - u, f = u), d = Math.max(l, d), f = Math.min(u, f);
|
|
60
|
+
let p = [];
|
|
61
|
+
for (let e = 0; e < c; e++) {
|
|
62
|
+
let t = c === 1 ? 0 : e / (c - 1), r = d + (f - d) * t, a = n.C * (1 - (1 - o) * t), l = L(n.h, i, s, t);
|
|
63
|
+
p.push(R({
|
|
64
|
+
L: r,
|
|
65
|
+
C: a,
|
|
66
|
+
h: l
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
return p;
|
|
70
|
+
}
|
|
71
|
+
function L(e, t, n, r) {
|
|
72
|
+
let i = (e) => (e % 360 + 360) % 360;
|
|
73
|
+
switch (t) {
|
|
74
|
+
case "monochrome": return i(e);
|
|
75
|
+
case "complementary": return i(e + 180 * r);
|
|
76
|
+
case "triad": return i(e + 240 * r);
|
|
77
|
+
default: return i(e + n * (r - .5) * 2);
|
|
108
78
|
}
|
|
109
|
-
F.clearRect(0, 0, 1, 1), F.fillStyle = "#808080", F.fillStyle = e, F.fillRect(0, 0, 1, 1);
|
|
110
|
-
let t = F.getImageData(0, 0, 1, 1).data;
|
|
111
|
-
return [
|
|
112
|
-
t[0],
|
|
113
|
-
t[1],
|
|
114
|
-
t[2]
|
|
115
|
-
];
|
|
116
79
|
}
|
|
117
|
-
function
|
|
118
|
-
let [t, n, r] =
|
|
80
|
+
function R(e) {
|
|
81
|
+
let [t, n, r] = T(e.L, e.C, e.h), [i, a, o] = y(t, n, r), [s, c, l] = w(i, a, o), u = c;
|
|
82
|
+
for (let e = 0; e < 6; e++) {
|
|
83
|
+
let [e, t, n] = T(s, u, l), [r, i, a] = x(e, t, n);
|
|
84
|
+
if (b(r, i, a)) break;
|
|
85
|
+
u *= .999;
|
|
86
|
+
}
|
|
119
87
|
return {
|
|
120
|
-
L:
|
|
121
|
-
C:
|
|
122
|
-
h:
|
|
88
|
+
L: s,
|
|
89
|
+
C: u,
|
|
90
|
+
h: l
|
|
123
91
|
};
|
|
124
92
|
}
|
|
125
93
|
//#endregion
|
|
126
94
|
//#region src/components/custom/aurora/composables/runtime.ts
|
|
127
|
-
var
|
|
95
|
+
var z = {
|
|
128
96
|
smooth: 0,
|
|
129
97
|
pastel: 1,
|
|
130
98
|
watercolor: 2,
|
|
131
99
|
oil: 3
|
|
132
|
-
},
|
|
100
|
+
}, B = {
|
|
133
101
|
none: 0,
|
|
134
102
|
radial: 1,
|
|
135
103
|
swirl: 2,
|
|
136
104
|
diagonal: 3,
|
|
137
105
|
multi: 4
|
|
138
|
-
},
|
|
106
|
+
}, V = {
|
|
139
107
|
fbm: 0,
|
|
140
108
|
cellular: 1,
|
|
141
109
|
hybrid: 2
|
|
142
|
-
},
|
|
110
|
+
}, H = {
|
|
143
111
|
oil: 0,
|
|
144
112
|
knife: 1,
|
|
145
113
|
crayon: 2,
|
|
146
114
|
chunky: 3
|
|
147
|
-
},
|
|
148
|
-
function
|
|
115
|
+
}, U = .22, W = .18, G = .992, K = .001;
|
|
116
|
+
function q(e) {
|
|
149
117
|
return e.mode === "capture" ? !0 : e.initStrategy === "eager";
|
|
150
118
|
}
|
|
151
|
-
function
|
|
119
|
+
function J(e) {
|
|
152
120
|
return typeof e.preserveDrawingBuffer == "boolean" ? e.preserveDrawingBuffer : e.mode === "capture";
|
|
153
121
|
}
|
|
154
|
-
function
|
|
122
|
+
function Y(e, t, n) {
|
|
155
123
|
let r = e.createShader(t);
|
|
156
124
|
if (e.shaderSource(r, n), e.compileShader(r), !e.getShaderParameter(r, e.COMPILE_STATUS)) {
|
|
157
125
|
let t = e.getShaderInfoLog(r) ?? "unknown";
|
|
@@ -159,7 +127,7 @@ function J(e, t, n) {
|
|
|
159
127
|
}
|
|
160
128
|
return r;
|
|
161
129
|
}
|
|
162
|
-
function
|
|
130
|
+
function ee(e, t, n) {
|
|
163
131
|
let r = e.createProgram();
|
|
164
132
|
if (e.attachShader(r, t), e.attachShader(r, n), e.linkProgram(r), !e.getProgramParameter(r, e.LINK_STATUS)) {
|
|
165
133
|
let t = e.getProgramInfoLog(r) ?? "unknown";
|
|
@@ -167,9 +135,9 @@ function Y(e, t, n) {
|
|
|
167
135
|
}
|
|
168
136
|
return r;
|
|
169
137
|
}
|
|
170
|
-
var
|
|
138
|
+
var te = /* @__PURE__ */ "uTime.uPalette.uStopCount.uNucleiCount.uNucleiPos.uNucleiRadius.uNucleiPaletteBias.uNucleiValueBias.uNucleiDriftRadius.uNucleiDriftPhase.uNucleiElong.uNucleiAngle.uSoftmaxBeta.uValueVariance.uWarpAmount.uWarpScale.uWarpDrift.uWarpMode.uNoiseOctaves.uMedium.uFlowPattern.uFlowFocal.uFlowAngle.uFlowCurl.uCursor.uCursorStrength.uCursorRadius.uStrokeAmount.uStrokeScale.uStrokeAnisotropy.uStrokeLayers.uStrokeMode.uWetEdge.uGranulation.uImpasto.uBrokenColor.uCanvasGrain.uNucleiDrift.uPaletteDrift.uBreathDepth.uBreathPeriod.uSaturation.uPaperGrain.uAlpha".split(".");
|
|
171
139
|
function X(e, t, n = {}) {
|
|
172
|
-
let r =
|
|
140
|
+
let r = J(n), i = t, a = /* @__PURE__ */ new Set();
|
|
173
141
|
n.mode === "capture" && a.add("manual");
|
|
174
142
|
let o = () => a.size === 0, s = typeof window < "u" && window.matchMedia ? window.matchMedia("(prefers-reduced-motion: reduce)").matches : !1, c = performance.now(), l = 0, u = null;
|
|
175
143
|
function d(e) {
|
|
@@ -194,19 +162,19 @@ function X(e, t, n = {}) {
|
|
|
194
162
|
targetStrength: 0,
|
|
195
163
|
radius: .25
|
|
196
164
|
}, g = null, _ = !1;
|
|
197
|
-
function
|
|
165
|
+
function v(e, t, n = .8) {
|
|
198
166
|
h.targetX = e, h.targetY = t, h.targetStrength = n, g?.wake();
|
|
199
167
|
}
|
|
200
|
-
function
|
|
168
|
+
function y() {
|
|
201
169
|
h.targetStrength = 0, g?.wake();
|
|
202
170
|
}
|
|
203
|
-
function
|
|
171
|
+
function b(e) {
|
|
204
172
|
h.radius = e, g?.wake();
|
|
205
173
|
}
|
|
206
|
-
function
|
|
174
|
+
function x(e) {
|
|
207
175
|
s = e, g?.wake();
|
|
208
176
|
}
|
|
209
|
-
function
|
|
177
|
+
function S() {
|
|
210
178
|
if (g || _) return;
|
|
211
179
|
let t = e.getContext("webgl2", {
|
|
212
180
|
antialias: !1,
|
|
@@ -215,7 +183,7 @@ function X(e, t, n = {}) {
|
|
|
215
183
|
preserveDrawingBuffer: r
|
|
216
184
|
});
|
|
217
185
|
if (!t) throw Error("[Aurora] WebGL2 unavailable");
|
|
218
|
-
let n =
|
|
186
|
+
let n = Y(t, t.VERTEX_SHADER, D), a = Y(t, t.FRAGMENT_SHADER, O), d = ee(t, n, a);
|
|
219
187
|
t.useProgram(d);
|
|
220
188
|
let f = t.createVertexArray();
|
|
221
189
|
t.bindVertexArray(f);
|
|
@@ -230,17 +198,17 @@ function X(e, t, n = {}) {
|
|
|
230
198
|
]), t.STATIC_DRAW);
|
|
231
199
|
let m = t.getAttribLocation(d, "aPos");
|
|
232
200
|
t.enableVertexAttribArray(m), t.vertexAttribPointer(m, 2, t.FLOAT, !1, 0, 0);
|
|
233
|
-
let
|
|
234
|
-
for (let e of
|
|
235
|
-
function
|
|
201
|
+
let v = {};
|
|
202
|
+
for (let e of te) v[e] = t.getUniformLocation(d, e);
|
|
203
|
+
function y() {
|
|
236
204
|
let n = Math.min(window.devicePixelRatio || 1, 2), r = e.clientWidth || e.parentElement?.clientWidth || 1, i = e.clientHeight || e.parentElement?.clientHeight || 1, a = Math.max(1, Math.floor(r * n)), o = Math.max(1, Math.floor(i * n));
|
|
237
205
|
e.width = a, e.height = o, t.viewport(0, 0, a, o), t.useProgram(d);
|
|
238
206
|
}
|
|
239
|
-
let
|
|
240
|
-
|
|
241
|
-
|
|
207
|
+
let b = new ResizeObserver(() => y());
|
|
208
|
+
b.observe(e), requestAnimationFrame(() => {
|
|
209
|
+
y(), requestAnimationFrame(y);
|
|
242
210
|
});
|
|
243
|
-
let
|
|
211
|
+
let x = {
|
|
244
212
|
palette: new Float32Array(24),
|
|
245
213
|
pos: new Float32Array(12),
|
|
246
214
|
rad: new Float32Array(6),
|
|
@@ -251,68 +219,68 @@ function X(e, t, n = {}) {
|
|
|
251
219
|
elong: new Float32Array(6),
|
|
252
220
|
angle: new Float32Array(6)
|
|
253
221
|
};
|
|
254
|
-
function
|
|
255
|
-
i = e, t.useProgram(d),
|
|
222
|
+
function S(e) {
|
|
223
|
+
i = e, t.useProgram(d), A(e.palette, 8, x.palette), t.uniform3fv(v.uPalette, x.palette), t.uniform1i(v.uStopCount, Math.min(e.palette.length, 8));
|
|
256
224
|
let n = Math.min(e.nuclei.length, 6);
|
|
257
|
-
t.uniform1i(
|
|
225
|
+
t.uniform1i(v.uNucleiCount, n);
|
|
258
226
|
for (let t = 0; t < n; t++) {
|
|
259
227
|
let n = e.nuclei[t];
|
|
260
|
-
|
|
228
|
+
x.pos[t * 2 + 0] = n.x, x.pos[t * 2 + 1] = 1 - n.y, x.rad[t] = n.radius, x.pb[t] = n.paletteBias, x.vb[t] = n.valueBias, x.dr[t] = n.driftRadius, x.dp[t] = n.driftPhase, x.elong[t] = n.elongation ?? 1, x.angle[t] = -(n.angle ?? 0) * Math.PI / 180;
|
|
261
229
|
}
|
|
262
|
-
for (let e = n; e < 6; e++)
|
|
263
|
-
t.uniform2fv(
|
|
230
|
+
for (let e = n; e < 6; e++) x.pos[e * 2 + 0] = 0, x.pos[e * 2 + 1] = 0, x.rad[e] = 0, x.pb[e] = 0, x.vb[e] = 0, x.dr[e] = 0, x.dp[e] = 0, x.elong[e] = 1, x.angle[e] = 0;
|
|
231
|
+
t.uniform2fv(v.uNucleiPos, x.pos), t.uniform1fv(v.uNucleiRadius, x.rad), t.uniform1fv(v.uNucleiPaletteBias, x.pb), t.uniform1fv(v.uNucleiValueBias, x.vb), t.uniform1fv(v.uNucleiDriftRadius, x.dr), t.uniform1fv(v.uNucleiDriftPhase, x.dp), t.uniform1fv(v.uNucleiElong, x.elong), t.uniform1fv(v.uNucleiAngle, x.angle), t.uniform1f(v.uSoftmaxBeta, e.softmaxBeta), t.uniform1f(v.uValueVariance, e.valueVariance), t.uniform1f(v.uWarpAmount, e.warpAmount), t.uniform1f(v.uWarpScale, e.warpScale), t.uniform1f(v.uWarpDrift, e.warpDrift), t.uniform1i(v.uWarpMode, V[e.warpMode]), t.uniform1i(v.uNoiseOctaves, e.noiseOctaves), t.uniform1i(v.uMedium, z[e.medium]), t.uniform1i(v.uFlowPattern, B[e.flow.pattern]), t.uniform2f(v.uFlowFocal, e.flow.focalX, 1 - e.flow.focalY), t.uniform1f(v.uFlowAngle, e.flow.angle), t.uniform1f(v.uFlowCurl, e.flow.curl), t.uniform2f(v.uCursor, h.x, 1 - h.y), t.uniform1f(v.uCursorStrength, h.strength), t.uniform1f(v.uCursorRadius, h.radius), t.uniform1f(v.uStrokeAmount, e.strokeAmount), t.uniform1f(v.uStrokeScale, e.strokeScale), t.uniform1f(v.uStrokeAnisotropy, e.strokeAnisotropy), t.uniform1i(v.uStrokeLayers, e.strokeLayers), t.uniform1i(v.uStrokeMode, H[e.strokeMode]), t.uniform1f(v.uWetEdge, e.wetEdge), t.uniform1f(v.uGranulation, e.granulation), t.uniform1f(v.uImpasto, e.impasto), t.uniform1f(v.uBrokenColor, e.brokenColor), t.uniform1f(v.uCanvasGrain, e.canvasGrain), t.uniform1f(v.uNucleiDrift, e.nucleiDrift), t.uniform1f(v.uPaletteDrift, e.paletteDrift), t.uniform1f(v.uBreathDepth, e.breathDepth), t.uniform1f(v.uBreathPeriod, e.breathPeriod), t.uniform1f(v.uSaturation, e.saturation), t.uniform1f(v.uPaperGrain, e.paperGrain), t.uniform1f(v.uAlpha, e.alpha);
|
|
264
232
|
}
|
|
265
|
-
|
|
266
|
-
function
|
|
267
|
-
h.x += (h.targetX - h.x) *
|
|
233
|
+
S(i), y(), t.clearColor(0, 0, 0, 0), t.disable(t.DEPTH_TEST), t.enable(t.BLEND), t.blendFunc(t.ONE, t.ONE_MINUS_SRC_ALPHA);
|
|
234
|
+
function C() {
|
|
235
|
+
h.x += (h.targetX - h.x) * U, h.y += (h.targetY - h.y) * U, h.strength += (h.targetStrength - h.strength) * W, h.targetStrength *= G;
|
|
268
236
|
}
|
|
269
|
-
function
|
|
270
|
-
t.useProgram(d), t.uniform2f(
|
|
237
|
+
function w(e) {
|
|
238
|
+
t.useProgram(d), t.uniform2f(v.uCursor, h.x, 1 - h.y), t.uniform1f(v.uCursorStrength, h.strength), t.uniform1f(v.uCursorRadius, h.radius), t.uniform1f(v.uTime, e), t.clear(t.COLOR_BUFFER_BIT), t.drawArrays(t.TRIANGLES, 0, 3);
|
|
271
239
|
}
|
|
272
|
-
function
|
|
273
|
-
return s ? !1 : i.nucleiDrift !== 0 || i.paletteDrift !== 0 || i.breathDepth !== 0 || i.warpDrift !== 0 ? !0 : h.targetStrength >
|
|
240
|
+
function T() {
|
|
241
|
+
return s ? !1 : i.nucleiDrift !== 0 || i.paletteDrift !== 0 || i.breathDepth !== 0 || i.warpDrift !== 0 ? !0 : h.targetStrength > K || h.strength > K || Math.abs(h.x - h.targetX) > K || Math.abs(h.y - h.targetY) > K;
|
|
274
242
|
}
|
|
275
|
-
function
|
|
243
|
+
function E() {
|
|
276
244
|
if (!o()) return;
|
|
277
245
|
let e = s ? 3.7 : (performance.now() - c) / 1e3;
|
|
278
|
-
|
|
246
|
+
C(), w(e), l = T() ? requestAnimationFrame(E) : 0;
|
|
279
247
|
}
|
|
280
|
-
u =
|
|
248
|
+
u = E, o() && (l = requestAnimationFrame(E));
|
|
281
249
|
function k() {
|
|
282
|
-
o() && !l && (l = requestAnimationFrame(
|
|
250
|
+
o() && !l && (l = requestAnimationFrame(E));
|
|
283
251
|
}
|
|
284
|
-
function
|
|
285
|
-
|
|
252
|
+
function j(e) {
|
|
253
|
+
w(e);
|
|
286
254
|
}
|
|
287
255
|
function M() {
|
|
288
|
-
cancelAnimationFrame(l), l = 0, u = null,
|
|
256
|
+
cancelAnimationFrame(l), l = 0, u = null, b.disconnect(), t.deleteProgram(d), t.deleteShader(n), t.deleteShader(a), t.deleteBuffer(p), t.deleteVertexArray(f);
|
|
289
257
|
let e = t.getExtension("WEBGL_lose_context");
|
|
290
258
|
e && e.loseContext();
|
|
291
259
|
}
|
|
292
260
|
g = {
|
|
293
|
-
setConfig:
|
|
294
|
-
renderAt:
|
|
261
|
+
setConfig: S,
|
|
262
|
+
renderAt: j,
|
|
295
263
|
wake: k,
|
|
296
264
|
dispose: M
|
|
297
265
|
};
|
|
298
266
|
}
|
|
299
|
-
function
|
|
267
|
+
function C() {
|
|
300
268
|
p && document.removeEventListener("visibilitychange", m), a.clear();
|
|
301
269
|
}
|
|
302
|
-
return
|
|
303
|
-
arm:
|
|
270
|
+
return q(n) && S(), {
|
|
271
|
+
arm: S,
|
|
304
272
|
update: (e) => {
|
|
305
273
|
i = e, g?.setConfig(e), g?.wake();
|
|
306
274
|
},
|
|
307
|
-
setCursor:
|
|
308
|
-
clearCursor:
|
|
309
|
-
setCursorRadius:
|
|
310
|
-
setReducedMotion:
|
|
275
|
+
setCursor: v,
|
|
276
|
+
clearCursor: y,
|
|
277
|
+
setCursorRadius: b,
|
|
278
|
+
setReducedMotion: x,
|
|
311
279
|
pause: (e = "manual") => d(e),
|
|
312
280
|
resume: (e = "manual") => f(e),
|
|
313
281
|
renderAt: (e) => g?.renderAt(e),
|
|
314
282
|
dispose: () => {
|
|
315
|
-
g ? g.dispose() : _ = !0,
|
|
283
|
+
g ? g.dispose() : _ = !0, C();
|
|
316
284
|
}
|
|
317
285
|
};
|
|
318
286
|
}
|
|
@@ -323,7 +291,7 @@ function Z(e) {
|
|
|
323
291
|
}
|
|
324
292
|
//#endregion
|
|
325
293
|
//#region src/components/custom/aurora/composables/useAurora.ts
|
|
326
|
-
function
|
|
294
|
+
function ne(e) {
|
|
327
295
|
if (typeof window > "u") return () => {};
|
|
328
296
|
if (typeof window.requestIdleCallback == "function") {
|
|
329
297
|
let t = window.requestIdleCallback(() => e(), { timeout: 2e3 });
|
|
@@ -387,7 +355,7 @@ function Q(e, t, n = {}, r = {}) {
|
|
|
387
355
|
}, { pauseWhenHidden: !1 });
|
|
388
356
|
let r = p.isIntersecting;
|
|
389
357
|
l = _(r, (e) => {
|
|
390
|
-
!e || v || u || (u =
|
|
358
|
+
!e || v || u || (u = ne(() => {
|
|
391
359
|
u = null, r.value && C();
|
|
392
360
|
}));
|
|
393
361
|
}, { immediate: !0 });
|
|
@@ -413,7 +381,7 @@ function $(e) {
|
|
|
413
381
|
}
|
|
414
382
|
//#endregion
|
|
415
383
|
//#region src/components/custom/aurora/Aurora.vue
|
|
416
|
-
var
|
|
384
|
+
var re = /* @__PURE__ */ e(/* @__PURE__ */ c({
|
|
417
385
|
__name: "Aurora",
|
|
418
386
|
props: {
|
|
419
387
|
config: { default: () => r },
|
|
@@ -426,7 +394,7 @@ var ne = /* @__PURE__ */ e(/* @__PURE__ */ c({
|
|
|
426
394
|
let n = e, r = $(n.renderMode), i = a(() => Math.max(0, Math.min(1, n.opacityCeiling))), c = h(null), d = Q(c, () => n.config, a(() => ({
|
|
427
395
|
...n.runtimeOptions ?? {},
|
|
428
396
|
...n.onInitError ? { onInitError: n.onInitError } : {}
|
|
429
|
-
})).value, { renderMode: r }), f = a(() =>
|
|
397
|
+
})).value, { renderMode: r }), f = a(() => j(n.config.palette));
|
|
430
398
|
return t({
|
|
431
399
|
config: n.config,
|
|
432
400
|
canvasRef: c,
|
|
@@ -454,7 +422,7 @@ var ne = /* @__PURE__ */ e(/* @__PURE__ */ c({
|
|
|
454
422
|
}), [["__scopeId", "data-v-80ea8f7d"]]);
|
|
455
423
|
//#endregion
|
|
456
424
|
//#region src/components/custom/aurora/composables/useCursorInteraction.ts
|
|
457
|
-
function
|
|
425
|
+
function ie(e, t, n) {
|
|
458
426
|
let r = Z(t), i = n.hitFraction ?? .35, a = null, o = null;
|
|
459
427
|
function s(e, t) {
|
|
460
428
|
let n = t.getBoundingClientRect();
|
|
@@ -551,4 +519,4 @@ function re(e, t, n) {
|
|
|
551
519
|
}), { isDragging: () => a };
|
|
552
520
|
}
|
|
553
521
|
//#endregion
|
|
554
|
-
export {
|
|
522
|
+
export { re as Aurora, r as DEFAULT_AURORA_CONFIG, t as MAX_NUCLEI, n as MAX_STOPS, X as createAurora, P as cssToOklch, I as deriveAurora, A as flattenPalette, N as hexToOklchStop, M as oklchStopToHex, k as oklchToLinear, j as paletteToCssGradient, $ as resolveRenderMode, Q as useAurora, ie as useCursorInteraction };
|
package/dist/badge.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, t } from "./badge-
|
|
1
|
+
import { n as e, t } from "./badge-Cl6JZ1B7.js";
|
|
2
2
|
export { e as Badge, t as badgeVariants };
|
package/dist/button.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, t } from "./button-
|
|
1
|
+
import { n as e, t } from "./button-DS3ULf5i.js";
|
|
2
2
|
export { e as Button, t as buttonVariants };
|
package/dist/card.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as e, i as t, n, o as r, r as i, t as a } from "./CardFooter-
|
|
1
|
+
import { a as e, i as t, n, o as r, r as i, t as a } from "./CardFooter-3-VGho1J.js";
|
|
2
2
|
export { r as Card, n as CardContent, i as CardDescription, a as CardFooter, e as CardHeader, t as CardTitle };
|