[{"data":1,"prerenderedAt":496,"buildId":497},["ShallowReactive",2],{"doc-\u002Fdocs\u002Fprimitives\u002Fsimulate\u002Fparticles":3,"github-stars":404,"guide-nav":406},{"id":4,"title":5,"body":6,"categoryId":63,"categorySlug":63,"categoryTitle":390,"curated":391,"description":15,"editUrl":392,"extension":393,"group":394,"groupTitle":395,"kind":396,"meta":397,"navigation":398,"path":399,"seo":400,"sourceUrl":401,"stem":402,"wordCount":392,"__hash__":403},"primitives\u002Fdocs\u002Fprimitives\u002F46.simulate\u002F2.particles.md","particles",{"type":7,"value":8,"toc":386},"minimark",[9,12,16,58,73,244,249,286,290,382],[10,11,5],"h1",{"id":5},[13,14,15],"p",{},"Thousands of moving points drawn into a texture, read by name in WGSL.",[17,18,23],"pre",{"className":19,"code":20,"language":21,"meta":22,"style":22},"language-ts shiki shiki-themes github-dark","particles(opts: Parameters\u003Ctypeof particlesInput>[0]): ParticlesInput\n","ts","",[24,25,26],"code",{"__ignoreMap":22},[27,28,31,34,38,42,45,48,51,55],"span",{"class":29,"line":30},"line",1,[27,32,5],{"class":33},"svObZ",[27,35,37],{"class":36},"s95oV","(opts: Parameters",[27,39,41],{"class":40},"snl16","\u003Ctypeof",[27,43,44],{"class":36}," particlesInput",[27,46,47],{"class":40},">",[27,49,50],{"class":36},"[",[27,52,54],{"class":53},"sDLfK","0",[27,56,57],{"class":36},"]): ParticlesInput\n",[13,59,60,61,64,65,68,69,72],{},"Import ",[24,62,63],{},"simulate"," from ",[24,66,67],{},"shaders\u002Fstd"," and use ",[24,70,71],{},"simulate.particles",".",[74,75,76],"ul",{},[77,78,79,82,83,86,87,90,91,94,95,98,99,102,103,106,107,110,111,102,114,117,118,121,122,125,126,129,130,133,134,102,137,102,140,143,144,147,148,151,152,102,155,102,158,102,161,164,165,168,169,172,173,176,177,180,181,184,185,188,189,102,191,194,195,198,199,202,203,206,207,176,209,211,212,214,215,147,218,221,222,225,226,229,230,233,234,236,237,176,240,243],"li",{},[24,80,81],{},"count"," (number or prop) up to ",[24,84,85],{},"max","; ",[24,88,89],{},"mobile: {max}"," caps it on phones. - ",[24,92,93],{},"forces",": data, e.g. ",[24,96,97],{},"[{gravity: 0.3}, {drag: 0.5}, {cursor: 1}, {wind: 0.4}]",". Every strength (and ",[24,100,101],{},"radius",", ",[24,104,105],{},"scale",") takes a number or a prop, ",[24,108,109],{},"{spring: p('pull')}",", read live, so sliders drive the physics. Forces: ",[24,112,113],{},"gravity",[24,115,116],{},"drag"," (settling), ",[24,119,120],{},"spring"," (back to the spawn point), ",[24,123,124],{},"cursor"," (pushed from the pointer while one is over the canvas), ",[24,127,128],{},"wander"," (each particle jiggles on its own), ",[24,131,132],{},"wind"," (a shared flow), ",[24,135,136],{},"vortex",[24,138,139],{},"orbit",[24,141,142],{},"separate",". - ",[24,145,146],{},"spawn",": ",[24,149,150],{},"'scatter'"," (default), ",[24,153,154],{},"'ring'",[24,156,157],{},"'edge'",[24,159,160],{},"'atPointer'",[24,162,163],{},"{fromShape: source}"," (a texture's opaque area, e.g. ",[24,166,167],{},"samplePoints"," or a layer prop), or a WGSL body returning a ",[24,170,171],{},"Particle"," (it sees ",[24,174,175],{},"index"," and ",[24,178,179],{},"rand: vec4f","). - ",[24,182,183],{},"step",": WGSL run per particle per frame with ",[24,186,187],{},"var p: Particle"," in scope (and ",[24,190,175],{},[24,192,193],{},"rand","). Forces are applied before it; position integrates after it. - ",[24,196,197],{},"lifetime: {seconds, jitter}"," respawns particles as they age out. - ",[24,200,201],{},"draw",": WGSL returning ",[24,204,205],{},"Point(pos, sizePx, color)"," per particle (it sees ",[24,208,13],{},[24,210,175],{},"). Without a state (no spawn, step or forces) it sees only ",[24,213,175],{},": the formula-driven mode. - ",[24,216,217],{},"splat",[24,219,220],{},"'point'"," (1 px) or ",[24,223,224],{},"'soft'"," (a round footprint ",[24,227,228],{},"size"," pixels wide). - ",[24,231,232],{},"neighbors: {radius}"," lets ",[24,235,183],{}," read ",[24,238,239],{},"crowd(p)",[24,241,242],{},"crowdSlope(p)",": how crowded a spot is.",[245,246,248],"h2",{"id":247},"parameters","Parameters",[250,251,252,268],"table",{},[253,254,255],"thead",{},[256,257,258,262,265],"tr",{},[259,260,261],"th",{},"Name",[259,263,264],{},"Type",[259,266,267],{},"Notes",[269,270,271],"tbody",{},[256,272,273,279,284],{},[274,275,276],"td",{},[24,277,278],{},"opts",[274,280,281],{},[24,282,283],{},"Parameters\u003Ctypeof particlesInput>[0]",[274,285],{},[245,287,289],{"id":288},"example","Example",[17,291,293],{"className":19,"code":292,"language":21,"meta":22,"style":22},"inputs: {\n  motes: simulate.particles({count: 20000, forces: [{wind: 0.4}, {cursor: 1}, {drag: 0.6}], lifetime: {seconds: 6, jitter: 0.5}, splat: 'soft'}),\n},\npaint: wgsl`return motes(uv);`,\n",[24,294,295,303,359,365],{"__ignoreMap":22},[27,296,297,300],{"class":29,"line":30},[27,298,299],{"class":33},"inputs",[27,301,302],{"class":36},": {\n",[27,304,306,309,312,314,317,320,323,326,329,332,335,338,341,344,347,350,353,356],{"class":29,"line":305},2,[27,307,308],{"class":33},"  motes",[27,310,311],{"class":36},": simulate.",[27,313,5],{"class":33},[27,315,316],{"class":36},"({count: ",[27,318,319],{"class":53},"20000",[27,321,322],{"class":36},", forces: [{wind: ",[27,324,325],{"class":53},"0.4",[27,327,328],{"class":36},"}, {cursor: ",[27,330,331],{"class":53},"1",[27,333,334],{"class":36},"}, {drag: ",[27,336,337],{"class":53},"0.6",[27,339,340],{"class":36},"}], lifetime: {seconds: ",[27,342,343],{"class":53},"6",[27,345,346],{"class":36},", jitter: ",[27,348,349],{"class":53},"0.5",[27,351,352],{"class":36},"}, splat: ",[27,354,224],{"class":355},"sU2Wk",[27,357,358],{"class":36},"}),\n",[27,360,362],{"class":29,"line":361},3,[27,363,364],{"class":36},"},\n",[27,366,368,371,373,376,379],{"class":29,"line":367},4,[27,369,370],{"class":33},"paint",[27,372,147],{"class":36},[27,374,375],{"class":33},"wgsl",[27,377,378],{"class":355},"`return motes(uv);`",[27,380,381],{"class":36},",\n",[383,384,385],"style",{},"html pre.shiki code .svObZ, html code.shiki .svObZ{--shiki-default:#B392F0}html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}",{"title":22,"searchDepth":305,"depth":305,"links":387},[388,389],{"id":247,"depth":305,"text":248},{"id":288,"depth":305,"text":289},"Simulate",false,null,"md","simulation","Simulation","function",{},true,"\u002Fdocs\u002Fprimitives\u002Fsimulate\u002Fparticles",{"title":5,"description":15},"https:\u002F\u002Fgithub.com\u002Fshader-effects-inc\u002Fshaders\u002Fblob\u002Fmain\u002Fpackages\u002Fcore\u002Fsrc\u002Fstd\u002Fsimulate.ts#L84","docs\u002Fprimitives\u002F46.simulate\u002F2.particles","RmgkMCwLPNlDa9Li5Ee4PbJ5jIlhELkIHjcoFeiYc5o",{"stars":405},6080,[407,411,415,419,423,427,431,435,439,443,447,451,455,459,463,467,471,476,480,484,488,492],{"path":408,"title":409,"description":410,"category":24},"\u002Fdocs\u002Fguide","Getting started","Shaders is a desktop app where your AI agent designs interactive effects on an infinite canvas, and you shape them by hand.",{"path":412,"title":413,"description":414,"category":24},"\u002Fdocs\u002Fguide\u002Fquickstart","Quickstart","Install Shaders, render your first effect, and drive a prop from state.",{"path":416,"title":417,"description":418,"category":24},"\u002Fdocs\u002Fguide\u002Fcomposing-effects","Composing effects","Stack components as layers and nest them to control which layers an effect touches.",{"path":420,"title":421,"description":422,"category":24},"\u002Fdocs\u002Fguide\u002Fblending-masking","Blending and masking","Control how a layer mixes with the layers below it, and reveal one layer through another.",{"path":424,"title":425,"description":426,"category":24},"\u002Fdocs\u002Fguide\u002Fprops-reactivity","Props and reactivity","Bind props to your framework's state so effects update when it changes, and animate props with an animation library.",{"path":428,"title":429,"description":430,"category":24},"\u002Fdocs\u002Fguide\u002Fanimation","Animating a shader","Tween a shader's props with Motion, GSAP or anything else that animates a number.",{"path":432,"title":433,"description":434,"category":24},"\u002Fdocs\u002Fguide\u002Fdynamic-props","Dynamic props","Drive any numeric or position prop from time, the cursor, or another layer, without writing animation code.",{"path":436,"title":437,"description":438,"category":24},"\u002Fdocs\u002Fguide\u002Flayout-positioning","Layout and positioning","Size and place a shader in your page with CSS, as a background, a fill, or an inline block.",{"path":440,"title":441,"description":442,"category":24},"\u002Fdocs\u002Fguide\u002Fsizing-and-units","Sizing and units","Size and place layers in CSS units (px, %, vw, rem, and canvas units) that stay correct as the canvas and window resize.",{"path":444,"title":445,"description":446,"category":24},"\u002Fdocs\u002Fguide\u002Ftransforms","Transforms","Position, size, and rotate any layer inside the canvas with a bounding box, in any CSS unit.",{"path":448,"title":449,"description":450,"category":24},"\u002Fdocs\u002Fguide\u002Fshape-effects","Shape effects","Pick the 2D, 3D or custom SVG shape that Glass, Neon, Emboss and other shape effects draw inside.",{"path":452,"title":453,"description":454,"category":24},"\u002Fdocs\u002Fguide\u002Fcolor-space","Color space","Match colors to your design tool with the output color space, and keep bright layers from clipping with tone mapping.",{"path":456,"title":457,"description":458,"category":24},"\u002Fdocs\u002Fguide\u002Fhooks-events","Hooks and events","Run code when an effect is ready to show, and show a fallback when the GPU can't run it.",{"path":460,"title":461,"description":462,"category":24},"\u002Fdocs\u002Fguide\u002Fperformance","Performance","Learn what makes an effect expensive on the GPU and how to keep it inside the frame budget.",{"path":464,"title":465,"description":466,"category":24},"\u002Fdocs\u002Fguide\u002Fcustom-shaders","Custom components","Write your own component in TypeScript, use it like any component in the library, and write WGSL by hand when you need to.",{"path":468,"title":469,"description":470,"category":24},"\u002Fdocs\u002Fguide\u002Ftelemetry","Telemetry","The `\u003CShader>` component occasionally sends an anonymous performance report to help us improve the engine over time.",{"path":472,"title":473,"description":474,"category":475},"\u002Fdocs\u002Fguide\u002Fmcp","Working with your agent","The Shaders MCP connects your AI agent to the desktop app, so it can design shaders on your canvas and install them in your project.","workflows",{"path":477,"title":478,"description":479,"category":475},"\u002Fdocs\u002Fguide\u002Fcli","Working with the CLI","The Shaders CLI installs shaders from your projects and the Pro library into your codebase as component files, and keeps them in sync as you keep designing.",{"path":481,"title":482,"description":483,"category":475},"\u002Fdocs\u002Fguide\u002Fframeworks","Supported frameworks","Shaders runs in any web project that renders in a browser with WebGPU, with components for React, Vue, Svelte and Solid and a JavaScript API for everything else.",{"path":485,"title":486,"description":487,"category":24},"\u002Fdocs\u002Fguide\u002Fagent-skill","Agent skill for the engine","Teach your coding agent to write Shaders code with the open-source engine, for when it's working in your codebase instead of on the canvas.",{"path":489,"title":490,"description":491,"category":24},"\u002Fdocs\u002Fguide\u002Fvideo-rendering","Rendering to video","Render a shader effect to video frame by frame, from Remotion, Hyperframes or your own headless Chrome script.",{"path":493,"title":494,"description":495,"category":24},"\u002Fdocs\u002Fguide\u002Fssr","Server rendering","Render Shaders in Next.js, Nuxt, SvelteKit, SolidStart and other SSR apps by keeping each shader on the client.",1796051186186,"06e02370-81a6-4d74-9931-661d71414be1"]