ludic/annot-clearcolor.html
2026-09-17 22:10:03 +00:00

35 lines
No EOL
2.5 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>"@ClearColor" — Ludic</title>
<meta name="description" content="Declare a clear colour so the Render phase auto-clears + auto-presents for you.">
<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="api.html#annotations">Annotations</a> <span>›</span> <span class="here">"@ClearColor"</span></div>
<div class="item-head">
<span class="kind-badge kind-annotation">annotation</span>
<h1 id="top">"@ClearColor"</h1>
</div>
<code class="sig">"@ClearColor(0xRRGGBB) handler Draw phase Render { … }"</code>
<div class="desc"><p><code>@ClearColor(N)</code> declares the framebuffer clear colour (a <code>0x00RRGGBB</code> integer) so the engine owns the per-frame clear and present: at the top of the Render phase it clears the framebuffer to <code>N</code>, and after all Render handlers run it presents the frame — so a game's Render handler carries no <code>Screen.clear</code> / <code>Screen.show</code> boilerplate, and the colour is configured declaratively rather than written in the handler body. It is opt-in: a program with no <code>@ClearColor</code> is byte-for-byte identical (it clears and presents itself, or the light system owns the present). Place it on the program's Render handler (or any declaration — it is program-wide). The argument is any constant expression — a hex literal, a <code>Color.*</code> name, or a <code>const</code> from your palette.</p></div>
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program ClearColorDemo {
property Tag { n: int = 0 }
model P { Tag }
@ClearColor(0x102030)
handler Draw phase Render {
Screen.fill_rectangle(10, 10, 4, 4, 0xffffff)
}
}</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>