<!DOCTYPE html><htmlclass="default"lang="en"><head><metacharSet="utf-8"/><metahttp-equiv="x-ua-compatible"content="IE=edge"/><title>draw | @vladmandic/face-api - v1.7.13</title><metaname="description"content="Documentation for @vladmandic/face-api"/><metaname="viewport"content="width=device-width, initial-scale=1"/><linkrel="stylesheet"href="../assets/style.css"/><linkrel="stylesheet"href="../assets/highlight.css"/><scriptdefersrc="../assets/main.js"></script><scriptasyncsrc="../assets/search.js"id="tsd-search-script"></script><scriptasyncsrc="../assets/navigation.js"id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme=localStorage.getItem("tsd-theme")||"os"</script><headerclass="tsd-page-toolbar"><divclass="tsd-toolbar-contents container"><divclass="table-cell"id="tsd-search"data-base=".."><divclass="field"><labelfor="tsd-search-field"class="tsd-widget tsd-toolbar-icon search no-caption"><svgwidth="16"height="16"viewBox="0 0 16 16"fill="none"><usehref="#icon-search"></use></svg></label><inputtype="text"id="tsd-search-field"aria-label="Search"/></div><divclass="field"><divid="tsd-toolbar-links"></div></div><ulclass="results"><liclass="state loading">Preparing search index...</li><liclass="state failure">The search index is not available</li></ul><ahref="../index.html"class="title">@vladmandic/face-api - v1.7.13</a></div><divclass="table-cell"id="tsd-widgets"><ahref="#"class="tsd-widget tsd-toolbar-icon menu no-caption"data-toggle="menu"aria-label="Menu"><svgwidth="16"height="16"viewBox="0 0 16 16"fill="none"><usehref="#icon-menu"></use></svg></a></div></div></header><divclass="container container-main"><divclass="col-content"><divclass="tsd-page-title"><ulclass="tsd-breadcrumb"><li><ahref="../index.html">@vladmandic/face-api</a></li><li><ahref="../modules/tf.html">tf</a></li><li><ahref="../modules/tf.browser.html">browser</a></li><li><ahref="tf.browser.draw.html">draw</a></li></ul><h1>Function draw</h1></div><sectionclass="tsd-panel"><ulclass="tsd-signatures"><liclass="tsd-signature tsd-anchor-link"><aid="draw"class="tsd-anchor"></a><spanclass="tsd-kind-call-signature">draw</span><spanclass="tsd-signature-symbol">(</span><spanclass="tsd-kind-parameter">image</span>, <spanclass="tsd-kind-parameter">canvas</span>, <spanclass="tsd-kind-parameter">options</span><spanclass="tsd-signature-symbol">?</span><spanclass="tsd-signature-symbol">)</span><spanclass="tsd-signature-symbol">: </span><spanclass="tsd-signature-type">void</span><ahref="#draw"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"><usehref="#icon-anchor"></use></svg></a></li><liclass="tsd-description"><divclass="tsd-comment tsd-typography"><p>Draws a <code>tf.Tensor</code> to a canvas.</p>
<p>When the dtype of the input is 'float32', we assume values in the range
[0-1]. Otherwise, when input is 'int32', we assume values in the range
[0-255].</p>
</div><divclass="tsd-parameters"><h4class="tsd-parameters-title">Parameters</h4><ulclass="tsd-parameter-list"><li><h5><spanclass="tsd-kind-parameter">image</span>: <ahref="../types/tf.Tensor2D.html"class="tsd-signature-type tsd-kind-type-alias">Tensor2D</a><spanclass="tsd-signature-symbol"> | </span><ahref="../types/tf.TensorLike.html"class="tsd-signature-type tsd-kind-type-alias">TensorLike</a><spanclass="tsd-signature-symbol"> | </span><ahref="../types/tf.Tensor3D.html"class="tsd-signature-type tsd-kind-type-alias">Tensor3D</a></h5><divclass="tsd-comment tsd-typography"><p>The tensor to draw on the canvas. Must match one of
these shapes:</p>
<ul>
<li>Rank-2 with shape <code>[height, width</code>]: Drawn as grayscale.</li>
<li>Rank-3 with shape <code>[height, width, 1]</code>: Drawn as grayscale.</li>
<li>Rank-3 with shape <code>[height, width, 3]</code>: Drawn as RGB with alpha set in
<code>imageOptions</code> (defaults to 1, which is opaque).</li>
<li>Rank-3 with shape <code>[height, width, 4]</code>: Drawn as RGBA.</li>
</ul>
</div><divclass="tsd-comment tsd-typography"></div></li><li><h5><spanclass="tsd-kind-parameter">canvas</span>: <spanclass="tsd-signature-type">HTMLCanvasElement</span></h5><divclass="tsd-comment tsd-typography"><p>The canvas to draw to.</p>
</div><divclass="tsd-comment tsd-typography"></div></li><li><h5><codeclass="tsd-tag ts-flagOptional">Optional</code><spanclass="tsd-kind-parameter">options</span>: <spanclass="tsd-signature-type">DrawOptions</span></h5><divclass="tsd-comment tsd-typography"><p>The configuration arguments for image to be drawn and the