{"route":"/en-US-v0.13.1/reference/visualize/gradient/","title":"Gradient","description":"Documentation for the Gradient type.","part":null,"outline":[{"id":"summary","name":"Summary","children":[]},{"id":"examples","name":"Examples","children":[]},{"id":"stops","name":"Stops","children":[]},{"id":"relativeness","name":"Relativeness","children":[]},{"id":"color-spaces-and-interpolation","name":"Color spaces and interpolation","children":[]},{"id":"direction","name":"Direction","children":[]},{"id":"presets","name":"Presets","children":[]},{"id":"note-on-file-sizes","name":"Note on file sizes","children":[]},{"id":"definitions","name":"Definitions","children":[{"id":"definitions-linear","name":"Linear Gradient","children":[{"id":"definitions-linear-stops","name":"stops","children":[]},{"id":"definitions-linear-space","name":"space","children":[]},{"id":"definitions-linear-relative","name":"relative","children":[]},{"id":"definitions-linear-dir","name":"dir","children":[]},{"id":"definitions-linear-angle","name":"angle","children":[]}]},{"id":"definitions-radial","name":"Radial","children":[{"id":"definitions-radial-stops","name":"stops","children":[]},{"id":"definitions-radial-space","name":"space","children":[]},{"id":"definitions-radial-relative","name":"relative","children":[]},{"id":"definitions-radial-center","name":"center","children":[]},{"id":"definitions-radial-radius","name":"radius","children":[]},{"id":"definitions-radial-focal-center","name":"focal-center","children":[]},{"id":"definitions-radial-focal-radius","name":"focal-radius","children":[]}]},{"id":"definitions-conic","name":"Conic","children":[{"id":"definitions-conic-stops","name":"stops","children":[]},{"id":"definitions-conic-angle","name":"angle","children":[]},{"id":"definitions-conic-space","name":"space","children":[]},{"id":"definitions-conic-relative","name":"relative","children":[]},{"id":"definitions-conic-center","name":"center","children":[]}]},{"id":"definitions-sharp","name":"Sharp","children":[{"id":"definitions-sharp-steps","name":"steps","children":[]},{"id":"definitions-sharp-smoothness","name":"smoothness","children":[]}]},{"id":"definitions-repeat","name":"Repeat","children":[{"id":"definitions-repeat-repetitions","name":"repetitions","children":[]},{"id":"definitions-repeat-mirror","name":"mirror","children":[]}]},{"id":"definitions-kind","name":"Kind","children":[]},{"id":"definitions-stops","name":"Stops","children":[]},{"id":"definitions-space","name":"Space","children":[]},{"id":"definitions-relative","name":"Relative","children":[]},{"id":"definitions-angle","name":"Angle","children":[]},{"id":"definitions-center","name":"Center","children":[]},{"id":"definitions-radius","name":"Radius","children":[]},{"id":"definitions-focal-center","name":"Focal Center","children":[]},{"id":"definitions-focal-radius","name":"Focal Radius","children":[]},{"id":"definitions-sample","name":"Sample","children":[{"id":"definitions-sample-t","name":"t","children":[]}]},{"id":"definitions-samples","name":"Samples","children":[{"id":"definitions-samples-ts","name":"ts","children":[]}]}]}],"body":{"kind":"type","content":{"name":"gradient","title":"Gradient","keywords":[],"oneliner":"A color gradient.","details":"<p>A color gradient.</p>\n<p>Typst supports linear gradients through the\n<a href=\"/en-US-v0.13.1/reference/visualize/gradient/#definitions-linear\"><code>gradient.linear</code> function</a>, radial gradients through\nthe <a href=\"/en-US-v0.13.1/reference/visualize/gradient/#definitions-radial\"><code>gradient.radial</code> function</a>, and conic gradients\nthrough the <a href=\"/en-US-v0.13.1/reference/visualize/gradient/#definitions-conic\"><code>gradient.conic</code> function</a>.</p>\n<p>A gradient can be used for the following purposes:</p>\n<ul>\n<li>As a fill to paint the interior of a shape:\n<code><span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> gradient<span class=\"typ-punct\">.</span><span class=\"typ-func\">linear</span><span class=\"typ-punct\">(</span><span class=\"typ-op\">..</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span></code></li>\n<li>As a stroke to paint the outline of a shape:\n<code><span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span>stroke<span class=\"typ-punct\">:</span> <span class=\"typ-num\">1pt</span> <span class=\"typ-op\">+</span> gradient<span class=\"typ-punct\">.</span><span class=\"typ-func\">linear</span><span class=\"typ-punct\">(</span><span class=\"typ-op\">..</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span></code></li>\n<li>As the fill of text:\n<code><span class=\"typ-key\">set</span> <span class=\"typ-func\">text</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> gradient<span class=\"typ-punct\">.</span><span class=\"typ-func\">linear</span><span class=\"typ-punct\">(</span><span class=\"typ-op\">..</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span></code></li>\n<li>As a color map you can <a href=\"/en-US-v0.13.1/reference/visualize/gradient/#definitions-sample\">sample</a> from:\n<code>gradient<span class=\"typ-punct\">.</span><span class=\"typ-func\">linear</span><span class=\"typ-punct\">(</span><span class=\"typ-op\">..</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">.</span><span class=\"typ-func\">sample</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">50%</span><span class=\"typ-punct\">)</span></code></li>\n</ul>\n<h2 id=\"examples\">Examples</h2>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-func\">#</span><span class=\"typ-func\">stack</span><span class=\"typ-punct\">(</span>\n  dir<span class=\"typ-punct\">:</span> ltr<span class=\"typ-punct\">,</span>\n  spacing<span class=\"typ-punct\">:</span> <span class=\"typ-num\">1fr</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-func\">square</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> gradient<span class=\"typ-punct\">.</span><span class=\"typ-func\">linear</span><span class=\"typ-punct\">(</span><span class=\"typ-op\">..</span>color<span class=\"typ-punct\">.</span>map<span class=\"typ-punct\">.</span>rainbow<span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-func\">square</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> gradient<span class=\"typ-punct\">.</span><span class=\"typ-func\">radial</span><span class=\"typ-punct\">(</span><span class=\"typ-op\">..</span>color<span class=\"typ-punct\">.</span>map<span class=\"typ-punct\">.</span>rainbow<span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-func\">square</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> gradient<span class=\"typ-punct\">.</span><span class=\"typ-func\">conic</span><span class=\"typ-punct\">(</span><span class=\"typ-op\">..</span>color<span class=\"typ-punct\">.</span>map<span class=\"typ-punct\">.</span>rainbow<span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/ff29eecb918a915ec00ed5fcec2f4488.png\" alt=\"Preview\"></div></div>\n<p>Gradients are also supported on text, but only when setting the\n<a href=\"/en-US-v0.13.1/reference/visualize/gradient/#definitions-relative\">relativeness</a> to either <code><span class=\"typ-key\">auto</span></code> (the default value) or\n<code><span class=\"typ-str\">&quot;parent&quot;</span></code>. To create word-by-word or glyph-by-glyph gradients, you can\nwrap the words or characters of your text in <a href=\"/en-US-v0.13.1/reference/layout/box/\">boxes</a> manually or\nthrough a <a href=\"/en-US-v0.13.1/reference/styling/#show-rules\">show rule</a>.</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">text</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> gradient<span class=\"typ-punct\">.</span><span class=\"typ-func\">linear</span><span class=\"typ-punct\">(</span>red<span class=\"typ-punct\">,</span> blue<span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-key\">#</span><span class=\"typ-key\">let</span> <span class=\"typ-func\">rainbow</span><span class=\"typ-punct\">(</span>content<span class=\"typ-punct\">)</span> <span class=\"typ-op\">=</span> <span class=\"typ-punct\">{</span>\n  <span class=\"typ-key\">set</span> <span class=\"typ-func\">text</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> gradient<span class=\"typ-punct\">.</span><span class=\"typ-func\">linear</span><span class=\"typ-punct\">(</span><span class=\"typ-op\">..</span>color<span class=\"typ-punct\">.</span>map<span class=\"typ-punct\">.</span>rainbow<span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span>\n  <span class=\"typ-func\">box</span><span class=\"typ-punct\">(</span>content<span class=\"typ-punct\">)</span>\n<span class=\"typ-punct\">}</span>\n\nThis is a gradient on text, but with a <span class=\"typ-func\">#</span><span class=\"typ-func\">rainbow</span><span class=\"typ-punct\">[</span>twist<span class=\"typ-punct\">]</span>!\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/721d0b00b502c2e4285439f1ac4fd467.png\" alt=\"Preview\"></div></div>\n<h2 id=\"stops\">Stops</h2>\n<p>A gradient is composed of a series of stops. Each of these stops has a color\nand an offset. The offset is a <a href=\"/en-US-v0.13.1/reference/layout/ratio/\">ratio</a> between <code><span class=\"typ-num\">0%</span></code> and <code><span class=\"typ-num\">100%</span></code> or\nan angle between <code><span class=\"typ-num\">0deg</span></code> and <code><span class=\"typ-num\">360deg</span></code>. The offset is a relative position\nthat determines how far along the gradient the stop is located. The stop's\ncolor is the color of the gradient at that position. You can choose to omit\nthe offsets when defining a gradient. In this case, Typst will space all\nstops evenly.</p>\n<h2 id=\"relativeness\">Relativeness</h2>\n<p>The location of the <code><span class=\"typ-num\">0%</span></code> and <code><span class=\"typ-num\">100%</span></code> stops depends on the dimensions\nof a container. This container can either be the shape that it is being\npainted on, or the closest surrounding container. This is controlled by the\n<code>relative</code> argument of a gradient constructor. By default, gradients are\nrelative to the shape they are being painted on, unless the gradient is\napplied on text, in which case they are relative to the closest ancestor\ncontainer.</p>\n<p>Typst determines the ancestor container as follows:</p>\n<ul>\n<li>For shapes that are placed at the root/top level of the document, the\nclosest ancestor is the page itself.</li>\n<li>For other shapes, the ancestor is the innermost <a href=\"/en-US-v0.13.1/reference/layout/block/\" title=\"`block`\"><code>block</code></a> or <a href=\"/en-US-v0.13.1/reference/layout/box/\" title=\"`box`\"><code>box</code></a> that\ncontains the shape. This includes the boxes and blocks that are implicitly\ncreated by show rules and elements. For example, a <a href=\"/en-US-v0.13.1/reference/layout/rotate/\" title=\"`rotate`\"><code>rotate</code></a> will not\naffect the parent of a gradient, but a <a href=\"/en-US-v0.13.1/reference/layout/grid/\" title=\"`grid`\"><code>grid</code></a> will.</li>\n</ul>\n<h2 id=\"color-spaces-and-interpolation\">Color spaces and interpolation</h2>\n<p>Gradients can be interpolated in any color space. By default, gradients are\ninterpolated in the <a href=\"/en-US-v0.13.1/reference/visualize/color/#definitions-oklab\">Oklab</a> color space, which is a\n<a href=\"https://programmingdesignsystems.com/color/perceptually-uniform-color-spaces/index.html\">perceptually uniform</a>\ncolor space. This means that the gradient will be perceived as having a\nsmooth progression of colors. This is particularly useful for data\nvisualization.</p>\n<p>However, you can choose to interpolate the gradient in any supported color\nspace you want, but beware that some color spaces are not suitable for\nperceptually interpolating between colors. Consult the table below when\nchoosing an interpolation space.</p>\n<table><thead><tr><th>Color space</th><th>Perceptually uniform?</th></tr></thead><tbody>\n<tr><td><a href=\"/en-US-v0.13.1/reference/visualize/color/#definitions-oklab\">Oklab</a></td><td><em>Yes</em></td></tr>\n<tr><td><a href=\"/en-US-v0.13.1/reference/visualize/color/#definitions-oklch\">Oklch</a></td><td><em>Yes</em></td></tr>\n<tr><td><a href=\"/en-US-v0.13.1/reference/visualize/color/#definitions-rgb\">sRGB</a></td><td><em>No</em></td></tr>\n<tr><td><a href=\"/en-US-v0.13.1/reference/visualize/color/#definitions-linear-rgb\">linear-RGB</a></td><td><em>Yes</em></td></tr>\n<tr><td><a href=\"/en-US-v0.13.1/reference/visualize/color/#definitions-cmyk\">CMYK</a></td><td><em>No</em></td></tr>\n<tr><td><a href=\"/en-US-v0.13.1/reference/visualize/color/#definitions-luma\">Grayscale</a></td><td><em>Yes</em></td></tr>\n<tr><td><a href=\"/en-US-v0.13.1/reference/visualize/color/#definitions-hsl\">HSL</a></td><td><em>No</em></td></tr>\n<tr><td><a href=\"/en-US-v0.13.1/reference/visualize/color/#definitions-hsv\">HSV</a></td><td><em>No</em></td></tr>\n</tbody></table>\n<div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/843ca1977fec8b1ba77fb5fc0adc7e84.png\" alt=\"Preview\"></div>\n<h2 id=\"direction\">Direction</h2>\n<p>Some gradients are sensitive to direction. For example, a linear gradient\nhas an angle that determines its direction. Typst uses a clockwise angle,\nwith 0° being from left to right, 90° from top to bottom, 180° from right to\nleft, and 270° from bottom to top.</p>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-func\">#</span><span class=\"typ-func\">stack</span><span class=\"typ-punct\">(</span>\n  dir<span class=\"typ-punct\">:</span> ltr<span class=\"typ-punct\">,</span>\n  spacing<span class=\"typ-punct\">:</span> <span class=\"typ-num\">1fr</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-func\">square</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> gradient<span class=\"typ-punct\">.</span><span class=\"typ-func\">linear</span><span class=\"typ-punct\">(</span>red<span class=\"typ-punct\">,</span> blue<span class=\"typ-punct\">,</span> angle<span class=\"typ-punct\">:</span> <span class=\"typ-num\">0deg</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-func\">square</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> gradient<span class=\"typ-punct\">.</span><span class=\"typ-func\">linear</span><span class=\"typ-punct\">(</span>red<span class=\"typ-punct\">,</span> blue<span class=\"typ-punct\">,</span> angle<span class=\"typ-punct\">:</span> <span class=\"typ-num\">90deg</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-func\">square</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> gradient<span class=\"typ-punct\">.</span><span class=\"typ-func\">linear</span><span class=\"typ-punct\">(</span>red<span class=\"typ-punct\">,</span> blue<span class=\"typ-punct\">,</span> angle<span class=\"typ-punct\">:</span> <span class=\"typ-num\">180deg</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-func\">square</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> gradient<span class=\"typ-punct\">.</span><span class=\"typ-func\">linear</span><span class=\"typ-punct\">(</span>red<span class=\"typ-punct\">,</span> blue<span class=\"typ-punct\">,</span> angle<span class=\"typ-punct\">:</span> <span class=\"typ-num\">270deg</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/71783179a4cfd9c8bb34bd7a6b7ac1fe.png\" alt=\"Preview\"></div></div>\n<h2 id=\"presets\">Presets</h2>\n<p>Typst predefines color maps that you can use with your gradients. See the\n<a href=\"/en-US-v0.13.1/reference/visualize/color/#predefined-color-maps\"><code>color</code></a> documentation for more details.</p>\n<h2 id=\"note-on-file-sizes\">Note on file sizes</h2>\n<p>Gradients can be quite large, especially if they have many stops. This is\nbecause gradients are stored as a list of colors and offsets, which can\ntake up a lot of space. If you are concerned about file sizes, you should\nconsider the following:</p>\n<ul>\n<li>SVG gradients are currently inefficiently encoded. This will be improved\nin the future.</li>\n<li>PDF gradients in the <a href=\"/en-US-v0.13.1/reference/visualize/color/#definitions-oklab\"><code>color.oklab</code></a>, <a href=\"/en-US-v0.13.1/reference/visualize/color/#definitions-hsv\"><code>color.hsv</code></a>,\n<a href=\"/en-US-v0.13.1/reference/visualize/color/#definitions-hsl\"><code>color.hsl</code></a>, and <a href=\"/en-US-v0.13.1/reference/visualize/color/#definitions-oklch\"><code>color.oklch</code></a> color spaces\nare stored as a list of <a href=\"/en-US-v0.13.1/reference/visualize/color/#definitions-rgb\"><code>color.rgb</code></a> colors with extra stops\nin between. This avoids needing to encode these color spaces in your PDF\nfile, but it does add extra stops to your gradient, which can increase\nthe file size.</li>\n</ul>","constructor":null,"scope":[{"path":["gradient"],"name":"linear","title":"Linear Gradient","keywords":[],"oneliner":"Creates a new linear gradient, in which colors transition along a","element":false,"contextual":false,"deprecation":null,"details":"<p>Creates a new linear gradient, in which colors transition along a\nstraight line.</p>","example":"<div class=\"previewed-code\"><pre><code><span class=\"typ-func\">#</span><span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span>\n  width<span class=\"typ-punct\">:</span> <span class=\"typ-num\">100%</span><span class=\"typ-punct\">,</span>\n  height<span class=\"typ-punct\">:</span> <span class=\"typ-num\">20pt</span><span class=\"typ-punct\">,</span>\n  fill<span class=\"typ-punct\">:</span> gradient<span class=\"typ-punct\">.</span><span class=\"typ-func\">linear</span><span class=\"typ-punct\">(</span>\n    <span class=\"typ-op\">..</span>color<span class=\"typ-punct\">.</span>map<span class=\"typ-punct\">.</span>viridis<span class=\"typ-punct\">,</span>\n  <span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/def0956800e63dc52a60e2e66b8fb072.png\" alt=\"Preview\"></div></div>","self":false,"params":[{"name":"stops","details":"<p>The color <a href=\"#stops\">stops</a> of the gradient.</p>","example":null,"types":["color","array"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":true,"settable":false},{"name":"space","details":"<p>The color space in which to interpolate the gradient.</p>\n<p>Defaults to a perceptually uniform color space called\n<a href=\"/en-US-v0.13.1/reference/visualize/color/#definitions-oklab\">Oklab</a>.</p>","example":null,"types":["any"],"strings":[],"default":"<code>oklab</code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false},{"name":"relative","details":"<p>The <a href=\"#relativeness\">relative placement</a> of the gradient.</p>\n<p>For an element placed at the root/top level of the document, the\nparent is the page itself. For other elements, the parent is the\ninnermost block, box, column, grid, or stack that contains the\nelement.</p>","example":null,"types":["auto","str"],"strings":[{"string":"self","details":"<p>The gradient is relative to itself (its own bounding box).</p>"},{"string":"parent","details":"<p>The gradient is relative to its parent (the parent's bounding box).</p>"}],"default":"<code><span class=\"typ-key\">auto</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false},{"name":"dir","details":"<p>The direction of the gradient.</p>","example":null,"types":["direction"],"strings":[],"default":"<code>ltr</code>","positional":true,"named":false,"required":false,"variadic":false,"settable":false},{"name":"angle","details":"<p>The angle of the gradient.</p>","example":null,"types":["angle"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["gradient"],"scope":[]},{"path":["gradient"],"name":"radial","title":"Radial","keywords":[],"oneliner":"Creates a new radial gradient, in which colors radiate away from an","element":false,"contextual":false,"deprecation":null,"details":"<p>Creates a new radial gradient, in which colors radiate away from an\norigin.</p>\n<p>The gradient is defined by two circles: the focal circle and the end\ncircle. The focal circle is a circle with center <code>focal-center</code> and\nradius <code>focal-radius</code>, that defines the points at which the gradient\nstarts and has the color of the first stop. The end circle is a circle\nwith center <code>center</code> and radius <code>radius</code>, that defines the points at\nwhich the gradient ends and has the color of the last stop. The gradient\nis then interpolated between these two circles.</p>\n<p>Using these four values, also called the focal point for the starting\ncircle and the center and radius for the end circle, we can define a\ngradient with more interesting properties than a basic radial gradient.</p>","example":"<div class=\"previewed-code\"><pre><code><span class=\"typ-func\">#</span><span class=\"typ-func\">stack</span><span class=\"typ-punct\">(</span>\n  dir<span class=\"typ-punct\">:</span> ltr<span class=\"typ-punct\">,</span>\n  spacing<span class=\"typ-punct\">:</span> <span class=\"typ-num\">1fr</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-func\">circle</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> gradient<span class=\"typ-punct\">.</span><span class=\"typ-func\">radial</span><span class=\"typ-punct\">(</span>\n    <span class=\"typ-op\">..</span>color<span class=\"typ-punct\">.</span>map<span class=\"typ-punct\">.</span>viridis<span class=\"typ-punct\">,</span>\n  <span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-func\">circle</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> gradient<span class=\"typ-punct\">.</span><span class=\"typ-func\">radial</span><span class=\"typ-punct\">(</span>\n    <span class=\"typ-op\">..</span>color<span class=\"typ-punct\">.</span>map<span class=\"typ-punct\">.</span>viridis<span class=\"typ-punct\">,</span>\n    focal-center<span class=\"typ-punct\">:</span> <span class=\"typ-punct\">(</span><span class=\"typ-num\">10%</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">40%</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n    focal-radius<span class=\"typ-punct\">:</span> <span class=\"typ-num\">5%</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/21f904edb21c2e1ac7db89749e4d2c21.png\" alt=\"Preview\"></div></div>","self":false,"params":[{"name":"stops","details":"<p>The color <a href=\"#stops\">stops</a> of the gradient.</p>","example":null,"types":["color","array"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":true,"settable":false},{"name":"space","details":"<p>The color space in which to interpolate the gradient.</p>\n<p>Defaults to a perceptually uniform color space called\n<a href=\"/en-US-v0.13.1/reference/visualize/color/#definitions-oklab\">Oklab</a>.</p>","example":null,"types":["any"],"strings":[],"default":"<code>oklab</code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false},{"name":"relative","details":"<p>The <a href=\"#relativeness\">relative placement</a> of the gradient.</p>\n<p>For an element placed at the root/top level of the document, the parent\nis the page itself. For other elements, the parent is the innermost block,\nbox, column, grid, or stack that contains the element.</p>","example":null,"types":["auto","str"],"strings":[{"string":"self","details":"<p>The gradient is relative to itself (its own bounding box).</p>"},{"string":"parent","details":"<p>The gradient is relative to its parent (the parent's bounding box).</p>"}],"default":"<code><span class=\"typ-key\">auto</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false},{"name":"center","details":"<p>The center of the end circle of the gradient.</p>\n<p>A value of <code><span class=\"typ-punct\">(</span><span class=\"typ-num\">50%</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">50%</span><span class=\"typ-punct\">)</span></code> means that the end circle is\ncentered inside of its container.</p>","example":null,"types":["array"],"strings":[],"default":"<code><span class=\"typ-punct\">(</span><span class=\"typ-num\">50%</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">50%</span><span class=\"typ-punct\">)</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false},{"name":"radius","details":"<p>The radius of the end circle of the gradient.</p>\n<p>By default, it is set to <code><span class=\"typ-num\">50%</span></code>. The ending radius must be bigger\nthan the focal radius.</p>","example":null,"types":["ratio"],"strings":[],"default":"<code><span class=\"typ-num\">50%</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false},{"name":"focal-center","details":"<p>The center of the focal circle of the gradient.</p>\n<p>The focal center must be inside of the end circle.</p>\n<p>A value of <code><span class=\"typ-punct\">(</span><span class=\"typ-num\">50%</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">50%</span><span class=\"typ-punct\">)</span></code> means that the focal circle is\ncentered inside of its container.</p>\n<p>By default it is set to the same as the center of the last circle.</p>","example":null,"types":["auto","array"],"strings":[],"default":"<code><span class=\"typ-key\">auto</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false},{"name":"focal-radius","details":"<p>The radius of the focal circle of the gradient.</p>\n<p>The focal center must be inside of the end circle.</p>\n<p>By default, it is set to <code><span class=\"typ-num\">0%</span></code>. The focal radius must be smaller\nthan the ending radius`.</p>","example":null,"types":["ratio"],"strings":[],"default":"<code><span class=\"typ-num\">0%</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false}],"returns":["gradient"],"scope":[]},{"path":["gradient"],"name":"conic","title":"Conic","keywords":[],"oneliner":"Creates a new conic gradient, in which colors change radially around a","element":false,"contextual":false,"deprecation":null,"details":"<p>Creates a new conic gradient, in which colors change radially around a\ncenter point.</p>\n<p>You can control the center point of the gradient by using the <code>center</code>\nargument. By default, the center point is the center of the shape.</p>","example":"<div class=\"previewed-code\"><pre><code><span class=\"typ-func\">#</span><span class=\"typ-func\">stack</span><span class=\"typ-punct\">(</span>\n  dir<span class=\"typ-punct\">:</span> ltr<span class=\"typ-punct\">,</span>\n  spacing<span class=\"typ-punct\">:</span> <span class=\"typ-num\">1fr</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-func\">circle</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> gradient<span class=\"typ-punct\">.</span><span class=\"typ-func\">conic</span><span class=\"typ-punct\">(</span>\n    <span class=\"typ-op\">..</span>color<span class=\"typ-punct\">.</span>map<span class=\"typ-punct\">.</span>viridis<span class=\"typ-punct\">,</span>\n  <span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-func\">circle</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> gradient<span class=\"typ-punct\">.</span><span class=\"typ-func\">conic</span><span class=\"typ-punct\">(</span>\n    <span class=\"typ-op\">..</span>color<span class=\"typ-punct\">.</span>map<span class=\"typ-punct\">.</span>viridis<span class=\"typ-punct\">,</span>\n    center<span class=\"typ-punct\">:</span> <span class=\"typ-punct\">(</span><span class=\"typ-num\">20%</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">30%</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/32a99c7b0b1cb9e924d91b259fba0aca.png\" alt=\"Preview\"></div></div>","self":false,"params":[{"name":"stops","details":"<p>The color <a href=\"#stops\">stops</a> of the gradient.</p>","example":null,"types":["color","array"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":true,"settable":false},{"name":"angle","details":"<p>The angle of the gradient.</p>","example":null,"types":["angle"],"strings":[],"default":"<code><span class=\"typ-num\">0deg</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false},{"name":"space","details":"<p>The color space in which to interpolate the gradient.</p>\n<p>Defaults to a perceptually uniform color space called\n<a href=\"/en-US-v0.13.1/reference/visualize/color/#definitions-oklab\">Oklab</a>.</p>","example":null,"types":["any"],"strings":[],"default":"<code>oklab</code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false},{"name":"relative","details":"<p>The <a href=\"#relativeness\">relative placement</a> of the gradient.</p>\n<p>For an element placed at the root/top level of the document, the parent\nis the page itself. For other elements, the parent is the innermost block,\nbox, column, grid, or stack that contains the element.</p>","example":null,"types":["auto","str"],"strings":[{"string":"self","details":"<p>The gradient is relative to itself (its own bounding box).</p>"},{"string":"parent","details":"<p>The gradient is relative to its parent (the parent's bounding box).</p>"}],"default":"<code><span class=\"typ-key\">auto</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false},{"name":"center","details":"<p>The center of the last circle of the gradient.</p>\n<p>A value of <code><span class=\"typ-punct\">(</span><span class=\"typ-num\">50%</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">50%</span><span class=\"typ-punct\">)</span></code> means that the end circle is\ncentered inside of its container.</p>","example":null,"types":["array"],"strings":[],"default":"<code><span class=\"typ-punct\">(</span><span class=\"typ-num\">50%</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">50%</span><span class=\"typ-punct\">)</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false}],"returns":["gradient"],"scope":[]},{"path":["gradient"],"name":"sharp","title":"Sharp","keywords":[],"oneliner":"Creates a sharp version of this gradient.","element":false,"contextual":false,"deprecation":null,"details":"<p>Creates a sharp version of this gradient.</p>\n<p>Sharp gradients have discrete jumps between colors, instead of a\nsmooth transition. They are particularly useful for creating color\nlists for a preset gradient.</p>","example":"<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span>width<span class=\"typ-punct\">:</span> <span class=\"typ-num\">100%</span><span class=\"typ-punct\">,</span> height<span class=\"typ-punct\">:</span> <span class=\"typ-num\">20pt</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-key\">#</span><span class=\"typ-key\">let</span> grad <span class=\"typ-op\">=</span> gradient<span class=\"typ-punct\">.</span><span class=\"typ-func\">linear</span><span class=\"typ-punct\">(</span><span class=\"typ-op\">..</span>color<span class=\"typ-punct\">.</span>map<span class=\"typ-punct\">.</span>rainbow<span class=\"typ-punct\">)</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> grad<span class=\"typ-punct\">)</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> grad<span class=\"typ-punct\">.</span><span class=\"typ-func\">sharp</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">5</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> grad<span class=\"typ-punct\">.</span><span class=\"typ-func\">sharp</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">5</span><span class=\"typ-punct\">,</span> smoothness<span class=\"typ-punct\">:</span> <span class=\"typ-num\">20%</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/93522b26f5475bd0d38d77f01dd7e1fd.png\" alt=\"Preview\"></div></div>","self":true,"params":[{"name":"steps","details":"<p>The number of stops in the gradient.</p>","example":null,"types":["int"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false},{"name":"smoothness","details":"<p>How much to smooth the gradient.</p>","example":null,"types":["ratio"],"strings":[],"default":"<code><span class=\"typ-num\">0%</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false}],"returns":["gradient"],"scope":[]},{"path":["gradient"],"name":"repeat","title":"Repeat","keywords":[],"oneliner":"Repeats this gradient a given number of times, optionally mirroring it","element":false,"contextual":false,"deprecation":null,"details":"<p>Repeats this gradient a given number of times, optionally mirroring it\nat each repetition.</p>","example":"<div class=\"previewed-code\"><pre><code><span class=\"typ-func\">#</span><span class=\"typ-func\">circle</span><span class=\"typ-punct\">(</span>\n  radius<span class=\"typ-punct\">:</span> <span class=\"typ-num\">40pt</span><span class=\"typ-punct\">,</span>\n  fill<span class=\"typ-punct\">:</span> gradient\n    <span class=\"typ-punct\">.</span><span class=\"typ-func\">radial</span><span class=\"typ-punct\">(</span>aqua<span class=\"typ-punct\">,</span> white<span class=\"typ-punct\">)</span>\n    <span class=\"typ-punct\">.</span><span class=\"typ-func\">repeat</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">4</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/c9d6c600cc20c2f18c089a5f32cd7000.png\" alt=\"Preview\"></div></div>","self":true,"params":[{"name":"repetitions","details":"<p>The number of times to repeat the gradient.</p>","example":null,"types":["int"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false},{"name":"mirror","details":"<p>Whether to mirror the gradient at each repetition.</p>","example":null,"types":["bool"],"strings":[],"default":"<code><span class=\"typ-key\">false</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false}],"returns":["gradient"],"scope":[]},{"path":["gradient"],"name":"kind","title":"Kind","keywords":[],"oneliner":"Returns the kind of this gradient.","element":false,"contextual":false,"deprecation":null,"details":"<p>Returns the kind of this gradient.</p>","example":null,"self":true,"params":[],"returns":["function"],"scope":[]},{"path":["gradient"],"name":"stops","title":"Stops","keywords":[],"oneliner":"Returns the stops of this gradient.","element":false,"contextual":false,"deprecation":null,"details":"<p>Returns the stops of this gradient.</p>","example":null,"self":true,"params":[],"returns":["array"],"scope":[]},{"path":["gradient"],"name":"space","title":"Space","keywords":[],"oneliner":"Returns the mixing space of this gradient.","element":false,"contextual":false,"deprecation":null,"details":"<p>Returns the mixing space of this gradient.</p>","example":null,"self":true,"params":[],"returns":["any"],"scope":[]},{"path":["gradient"],"name":"relative","title":"Relative","keywords":[],"oneliner":"Returns the relative placement of this gradient.","element":false,"contextual":false,"deprecation":null,"details":"<p>Returns the relative placement of this gradient.</p>","example":null,"self":true,"params":[],"returns":["auto","str"],"scope":[]},{"path":["gradient"],"name":"angle","title":"Angle","keywords":[],"oneliner":"Returns the angle of this gradient.","element":false,"contextual":false,"deprecation":null,"details":"<p>Returns the angle of this gradient.</p>\n<p>Returns <code><span class=\"typ-key\">none</span></code> if the gradient is neither linear nor conic.</p>","example":null,"self":true,"params":[],"returns":["none","angle"],"scope":[]},{"path":["gradient"],"name":"center","title":"Center","keywords":[],"oneliner":"Returns the center of this gradient.","element":false,"contextual":false,"deprecation":null,"details":"<p>Returns the center of this gradient.</p>\n<p>Returns <code><span class=\"typ-key\">none</span></code> if the gradient is neither radial nor conic.</p>","example":null,"self":true,"params":[],"returns":["none","array"],"scope":[]},{"path":["gradient"],"name":"radius","title":"Radius","keywords":[],"oneliner":"Returns the radius of this gradient.","element":false,"contextual":false,"deprecation":null,"details":"<p>Returns the radius of this gradient.</p>\n<p>Returns <code><span class=\"typ-key\">none</span></code> if the gradient is not radial.</p>","example":null,"self":true,"params":[],"returns":["none","ratio"],"scope":[]},{"path":["gradient"],"name":"focal-center","title":"Focal Center","keywords":[],"oneliner":"Returns the focal-center of this gradient.","element":false,"contextual":false,"deprecation":null,"details":"<p>Returns the focal-center of this gradient.</p>\n<p>Returns <code><span class=\"typ-key\">none</span></code> if the gradient is not radial.</p>","example":null,"self":true,"params":[],"returns":["none","array"],"scope":[]},{"path":["gradient"],"name":"focal-radius","title":"Focal Radius","keywords":[],"oneliner":"Returns the focal-radius of this gradient.","element":false,"contextual":false,"deprecation":null,"details":"<p>Returns the focal-radius of this gradient.</p>\n<p>Returns <code><span class=\"typ-key\">none</span></code> if the gradient is not radial.</p>","example":null,"self":true,"params":[],"returns":["none","ratio"],"scope":[]},{"path":["gradient"],"name":"sample","title":"Sample","keywords":[],"oneliner":"Sample the gradient at a given position.","element":false,"contextual":false,"deprecation":null,"details":"<p>Sample the gradient at a given position.</p>\n<p>The position is either a position along the gradient (a <a href=\"/en-US-v0.13.1/reference/layout/ratio/\" title=\"ratio\">ratio</a> between\n<code><span class=\"typ-num\">0%</span></code> and <code><span class=\"typ-num\">100%</span></code>) or an <a href=\"/en-US-v0.13.1/reference/layout/angle/\" title=\"angle\">angle</a>. Any value outside of this range will\nbe clamped.</p>","example":null,"self":true,"params":[{"name":"t","details":"<p>The position at which to sample the gradient.</p>","example":null,"types":["angle","ratio"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["color"],"scope":[]},{"path":["gradient"],"name":"samples","title":"Samples","keywords":[],"oneliner":"Samples the gradient at multiple positions at once and returns the","element":false,"contextual":false,"deprecation":null,"details":"<p>Samples the gradient at multiple positions at once and returns the\nresults as an array.</p>","example":null,"self":true,"params":[{"name":"ts","details":"<p>The positions at which to sample the gradient.</p>","example":null,"types":["angle","ratio"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":true,"settable":false}],"returns":["array"],"scope":[]}]}}}