# packages/core/src/features/textures/lib/gray-scott.ts
This is the source snapshot used to build these API details. [View this revision on GitHub](https://github.com/benlesh/pibbl/blob/a1dcf8ea5a3d3e01f6a79ac298dd3087f25b8b52/packages/core/src/features/textures/lib/gray-scott.ts#L26).

[Back to reference](/reference/types/textures/)

<pre class="api-source"><code><span id="L1"><a href="#L1" aria-label="Line 1">1</a> import { validateSeed } from &quot;./palette.js&quot;;</span>
<span id="L2"><a href="#L2" aria-label="Line 2">2</a> /** Curated immutable Gray–Scott feed/kill pairs. Appearance also depends on seed and elapsed steps. @see {@link ReactionDiffusionOptions} */</span>
<span id="L3"><a href="#L3" aria-label="Line 3">3</a> export const grayScottPresets = Object.freeze({</span>
<span id="L4"><a href="#L4" aria-label="Line 4">4</a>   /** Existing isolated spots. See {@link grayScottPresets}. */</span>
<span id="L5"><a href="#L5" aria-label="Line 5">5</a>   spots: Object.freeze({ feed: 0.0367, kill: 0.0649 }),</span>
<span id="L6"><a href="#L6" aria-label="Line 6">6</a>   /** Existing connected stripes. See {@link grayScottPresets}. */</span>
<span id="L7"><a href="#L7" aria-label="Line 7">7</a>   stripes: Object.freeze({ feed: 0.029, kill: 0.057 }),</span>
<span id="L8"><a href="#L8" aria-label="Line 8">8</a>   /** Branching coral-like fronts. See {@link grayScottPresets}. */</span>
<span id="L9"><a href="#L9" aria-label="Line 9">9</a>   coral: Object.freeze({ feed: 0.0545, kill: 0.062 }),</span>
<span id="L10"><a href="#L10" aria-label="Line 10">10</a>   /** Elongated worm-like structures. See {@link grayScottPresets}. */</span>
<span id="L11"><a href="#L11" aria-label="Line 11">11</a>   worms: Object.freeze({ feed: 0.078, kill: 0.061 }),</span>
<span id="L12"><a href="#L12" aria-label="Line 12">12</a>   /** Dense connected labyrinths. See {@link grayScottPresets}. */</span>
<span id="L13"><a href="#L13" aria-label="Line 13">13</a>   labyrinths: Object.freeze({ feed: 0.037, kill: 0.06 }),</span>
<span id="L14"><a href="#L14" aria-label="Line 14">14</a>   /** Growing and dividing spots in suitable seeded conditions. See {@link grayScottPresets}. */</span>
<span id="L15"><a href="#L15" aria-label="Line 15">15</a>   mitosis: Object.freeze({ feed: 0.028, kill: 0.062 }),</span>
<span id="L16"><a href="#L16" aria-label="Line 16">16</a> });</span>
<span id="L17"><a href="#L17" aria-label="Line 17">17</a> /** Named configurations of the same Gray–Scott solver and message contract. @see {@link grayScottPresets} */</span>
<span id="L18"><a href="#L18" aria-label="Line 18">18</a> export type ReactionDiffusionPreset = keyof typeof grayScottPresets;</span>
<span id="L19"><a href="#L19" aria-label="Line 19">19</a> /** Seed, chemistry, and initialization controls for Gray–Scott textures. @see {@link grayScottPresets} */</span>
<span id="L20"><a href="#L20" aria-label="Line 20">20</a> export interface ReactionDiffusionOptions {</span>
<span id="L21"><a href="#L21" aria-label="Line 21">21</a>   /** Unsigned 32-bit initialization seed; default 42. See {@link ReactionDiffusionOptions}. */</span>
<span id="L22"><a href="#L22" aria-label="Line 22">22</a>   readonly seed?: number;</span>
<span id="L23"><a href="#L23" aria-label="Line 23">23</a>   /** Curated feed/kill configuration; default spots. See {@link ReactionDiffusionPreset}. */</span>
<span id="L24"><a href="#L24" aria-label="Line 24">24</a>   readonly preset?: ReactionDiffusionPreset;</span>
<span id="L25"><a href="#L25" aria-label="Line 25">25</a>   /** Feed-rate override, finite 0–0.1. Changes reset the field. See {@link ReactionDiffusionOptions}. */</span>
<span id="L26"><a href="#L26" aria-label="Line 26">26</a>   readonly feed?: number;</span>
<span id="L27"><a href="#L27" aria-label="Line 27">27</a>   /** Kill-rate override, finite 0–0.1. Changes reset the field. See {@link ReactionDiffusionOptions}. */</span>
<span id="L28"><a href="#L28" aria-label="Line 28">28</a>   readonly kill?: number;</span>
<span id="L29"><a href="#L29" aria-label="Line 29">29</a>   /** Initial numerical steps, integer 0–4096; default 0. Runs once per initialization. See {@link ReactionDiffusionOptions}. */</span>
<span id="L30"><a href="#L30" aria-label="Line 30">30</a>   readonly warmupSteps?: number;</span>
<span id="L31"><a href="#L31" aria-label="Line 31">31</a> }</span>
<span id="L32"><a href="#L32" aria-label="Line 32">32</a> export function grayScottConfig(options: ReactionDiffusionOptions) {</span>
<span id="L33"><a href="#L33" aria-label="Line 33">33</a>   const preset = options.preset ?? &quot;spots&quot;;</span>
<span id="L34"><a href="#L34" aria-label="Line 34">34</a>   if (!Object.hasOwn(grayScottPresets, preset))</span>
<span id="L35"><a href="#L35" aria-label="Line 35">35</a>     throw new TypeError(&quot;Unknown reaction-diffusion preset.&quot;);</span>
<span id="L36"><a href="#L36" aria-label="Line 36">36</a>   const feed = options.feed ?? grayScottPresets[preset].feed;</span>
<span id="L37"><a href="#L37" aria-label="Line 37">37</a>   const kill = options.kill ?? grayScottPresets[preset].kill;</span>
<span id="L38"><a href="#L38" aria-label="Line 38">38</a>   if (!(</span>
<span id="L39"><a href="#L39" aria-label="Line 39">39</a>     Number.isFinite(feed) &amp;&amp;</span>
<span id="L40"><a href="#L40" aria-label="Line 40">40</a>     feed &gt;= 0 &amp;&amp;</span>
<span id="L41"><a href="#L41" aria-label="Line 41">41</a>     feed &lt;= 0.1 &amp;&amp;</span>
<span id="L42"><a href="#L42" aria-label="Line 42">42</a>     Number.isFinite(kill) &amp;&amp;</span>
<span id="L43"><a href="#L43" aria-label="Line 43">43</a>     kill &gt;= 0 &amp;&amp;</span>
<span id="L44"><a href="#L44" aria-label="Line 44">44</a>     kill &lt;= 0.1</span>
<span id="L45"><a href="#L45" aria-label="Line 45">45</a>   ))</span>
<span id="L46"><a href="#L46" aria-label="Line 46">46</a>     throw new RangeError(</span>
<span id="L47"><a href="#L47" aria-label="Line 47">47</a>       &quot;Gray–Scott feed and kill must be finite values in [0, 0.1].&quot;,</span>
<span id="L48"><a href="#L48" aria-label="Line 48">48</a>     );</span>
<span id="L49"><a href="#L49" aria-label="Line 49">49</a>   const warmupSteps = options.warmupSteps ?? 0;</span>
<span id="L50"><a href="#L50" aria-label="Line 50">50</a>   if (!Number.isInteger(warmupSteps) || warmupSteps &lt; 0 || warmupSteps &gt; 4096)</span>
<span id="L51"><a href="#L51" aria-label="Line 51">51</a>     throw new RangeError(</span>
<span id="L52"><a href="#L52" aria-label="Line 52">52</a>       &quot;Gray–Scott warmupSteps must be an integer in [0, 4096].&quot;,</span>
<span id="L53"><a href="#L53" aria-label="Line 53">53</a>     );</span>
<span id="L54"><a href="#L54" aria-label="Line 54">54</a>   return { seed: validateSeed(options.seed), preset, feed, kill, warmupSteps };</span>
<span id="L55"><a href="#L55" aria-label="Line 55">55</a> }</span>
<span id="L56"><a href="#L56" aria-label="Line 56">56</a> </span></code></pre>

## Documentation version

Documentation built with @pibbl/core 0.0.2, revision a1dcf8e. ALPHA — NOT FOR PRODUCTION USE.
