36 lines
No EOL
2.7 KiB
HTML
36 lines
No EOL
2.7 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>Camera.zoom — Ludic</title>
|
||
<meta name="description" content="Scale the whole view about the screen centre by a Q16.16 factor (1.0 = none).">
|
||
<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-camera.html">Camera</a> <span>›</span> <span class="here">Camera.zoom</span></div>
|
||
<div class="item-head">
|
||
<span class="kind-badge kind-method">method</span>
|
||
<h1 id="top">Camera.zoom</h1>
|
||
</div>
|
||
<code class="sig">Camera.zoom(scale)</code>
|
||
<div class="desc"><p>Sets a render-time zoom: every draw is scaled about the screen centre by <code>scale</code>, a Q16.16 <code>fixed</code> factor. <code>1.0</code> is no zoom (and turns the zoom path back off, restoring the byte-identical un-zoomed blit); <code>2.0</code> is 2x in; <code>0.5</code> is 2x out. It composes with <a href="camera-set"><code>Camera.set</code></a> / <a href="camera-follow"><code>Camera.follow</code></a> (which move the view) and <a href="camera-shake"><code>Camera.shake</code></a>.</p><p>Zoom is a *render-time transform*, not a change to the world coordinate types — those stay integer pixels + Q16.16 velocity so lockstep, replay and <code>world_save</code> hold (see the position-types RFC, #78). Because it rides on fixed-point, the zoom is itself deterministic: the same <code>scale</code> produces the same pixels on every machine and headless.</p></div>
|
||
<div class="params"><h2>Parameters</h2><div class="param" id="param-scale"><code class="pname">scale</code><span class="pdesc">the zoom factor (<code>fixed</code>); <code>1.0</code> = no zoom, <code>>1</code> zooms in, <code><1</code> zooms out</span></div></div>
|
||
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||
property Cam { z: fixed = 1.0 }
|
||
model View { Cam }
|
||
handler DrawWorld phase Render {
|
||
Camera.zoom(2.0)
|
||
Screen.fill_rectangle(150, 110, 20, 20, 0xffcc00)
|
||
Screen.show()
|
||
}
|
||
}</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> |