1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
<?xml version="1.0"?>
<page xmlns="http://projectmallard.org/1.0/" id="color.blend" type="topic" style="xslt-template"><info><link type="guide" xref="color" group="templates"/><link type="guide" xref="templates" group="color"/><revision version="3.28" date="2016-01-03" status="final"/><desc>Blend two colors together at a specified mix level.</desc></info><title>color.blend</title><p>Blend two colors together at a specified mix level.</p>
<synopsis><title>Parameters</title><terms>
<item>
<title><code>bg</code></title>
<p>A color specified in hexidecimal, <code>rgb()</code>, or <code>rgba()</code>.</p>
</item>
<item>
<title><code>fg</code></title>
<p>A color specified in hexidecimal, <code>rgb()</code>, or <code>rgba()</code>.</p>
</item>
<item>
<title><code>mix</code></title>
<p>The mix level, between 0.0 and 1.0.</p>
</item>
</terms></synopsis>
<p>This template calculates a color by selecting a midpoint between <code style="xslt-param">bg</code> and <code style="xslt-param">fg</code>, where the <code style="xslt-param">mix</code> parameter specifies how far to move from <code style="xslt-param">bg</code> to <code style="xslt-param">fg</code>. For opaque colors, setting <code style="xslt-param">mix</code> to 0.0 will result in <code style="xslt-param">bg</code>, and setting <code style="xslt-param">mix</code> to 1.0 will result in <code style="xslt-param">fg</code>.</p>
<p>This template takes the alpha values of <code style="xslt-param">bg</code> and <code style="xslt-param">fg</code> into account, so that specifying 1.0 for <code style="xslt-param">mix</code> will result in a color that is the result of overlaying <code style="xslt-param">fg</code> on top of <code style="xslt-param">bg</code>. In effect, <code style="xslt-param">mix</code> acts as a multiplier on the alpha channels of the colors.</p>
<p>This template calls <code style="xslt-template" xref="color.r">color.r</code>, <code style="xslt-template" xref="color.g">color.g</code>, <code style="xslt-template" xref="color.b">color.b</code>, and <code style="xslt-template" xref="color.a">color.a</code> to get the components of <code style="xslt-param">bg</code> and <code style="xslt-param">fg</code>. It accepts six-digit and three-digit hexidecimal color codes, colors specified with <code>rgb()</code>, and colors specified with <code>rgba()</code>. It does not accept HSL or named HTML colors.</p>
<p>If the return color is fully opaque, this template returns the color using the <code>rgb()</code> scheme. Otherwise, it uses the <code>rgba()</code> scheme.</p>
<list style="compact"><title>Calls Templates</title><item><p><link xref="color.r"/></p></item></list></page>
|