docs: regenerate site from f094acfdb5
This commit is contained in:
commit
63c5ed9baf
975 changed files with 55427 additions and 0 deletions
37
math-remap.html
Normal file
37
math-remap.html
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Math.remap — Ludic</title>
|
||||
<meta name="description" content="Rescale a value from one range into another.">
|
||||
<link rel="stylesheet" href="base.css">
|
||||
<link rel="stylesheet" href="docs.css">
|
||||
</head>
|
||||
<body>
|
||||
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||
<main class="wrap item">
|
||||
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-math.html">Math</a> <span>›</span> <span class="here">Math.remap</span></div>
|
||||
<div class="item-head">
|
||||
<span class="kind-badge kind-method">method</span>
|
||||
<h1 id="top">Math.remap</h1>
|
||||
</div>
|
||||
<code class="sig">Math.remap(v, in0, in1, out0, out1) -> fixed</code>
|
||||
<div class="desc"><p>Maps <code>v</code> from the input range <code>in0</code>..<code>in1</code> onto the output range <code>out0</code>..<code>out1</code>, keeping its relative position — equivalent to <code>Math.lerp(out0, out1, Math.inverse_lerp(in0, in1, v))</code>. All arguments are <code>fixed</code>. It is the one call that converts between units: a health value into a bar width, a noise sample in <code>-1..1</code> into a <code>0..255</code> shade, or a mouse position into a world coordinate. Swap the output ends to invert the mapping.</p></div>
|
||||
<div class="params"><h2>Parameters</h2><div class="param" id="param-v"><code class="pname">v</code><span class="pdesc">the value to rescale</span></div><div class="param" id="param-in0"><code class="pname">in0</code><span class="pdesc">the start of the input range</span></div><div class="param" id="param-in1"><code class="pname">in1</code><span class="pdesc">the end of the input range</span></div><div class="param" id="param-out0"><code class="pname">out0</code><span class="pdesc">the start of the output range</span></div><div class="param" id="param-out1"><code class="pname">out1</code><span class="pdesc">the end of the output range</span></div></div>
|
||||
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program HealthBar {
|
||||
const MAX_HP: fixed = 200.0
|
||||
const BAR_WIDTH: fixed = 64.0
|
||||
|
||||
var hp: fixed = 150.0
|
||||
|
||||
handler Draw phase Render {
|
||||
let width = Math.remap(hp, 0.0, MAX_HP, 0.0, BAR_WIDTH) # 48.0
|
||||
}
|
||||
}</pre></div>
|
||||
|
||||
<a class="back" href="api.html">← All symbols</a>
|
||||
</main>
|
||||
<script src="ludic-highlight.js"></script>
|
||||
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||
</body></html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue