ludic/screen-draw_number.html
2026-09-17 22:10:03 +00:00

41 lines
No EOL
3 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>Screen.draw_number — Ludic</title>
<meta name="description" content="Draw an integer directly, with no string allocation or conversion.">
<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-screen.html">Screen — drawing</a> <span>›</span> <span class="here">Screen.draw_number</span></div>
<div class="item-head">
<span class="kind-badge kind-method">method</span>
<h1 id="top">Screen.draw_number</h1>
</div>
<code class="sig">Screen.draw_number(x, y, value, color, scale)</code>
<div class="desc"><p>Draws an integer as digits using the built-in font, without first turning it into a string — so it never allocates and is safe to call every frame for constantly-changing values. Use it for scores, timers, frame counts, health totals, and any HUD number, while reserving <code>Screen.draw_text</code> for fixed labels. It takes the same top-left position, color, and integer <code>scale</code> as <code>draw_text</code>. Negative values are drawn with a leading minus sign.</p></div>
<div class="params"><h2>Parameters</h2><div class="param" id="param-x"><code class="pname">x</code><span class="pdesc">the left edge of the first digit, in pixels</span></div><div class="param" id="param-y"><code class="pname">y</code><span class="pdesc">the top edge of the number, in pixels</span></div><div class="param" id="param-value"><code class="pname">value</code><span class="pdesc">the integer to draw</span></div><div class="param" id="param-color"><code class="pname">color</code><span class="pdesc">the digit color, e.g. a <code>Color.*</code> name or a <code>0xRRGGBB</code> literal</span></div><div class="param" id="param-scale"><code class="pname">scale</code><span class="pdesc">integer size multiplier (<code>1</code> = native size)</span></div></div>
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program ScoreHud {
var score: int = 0
handler EarnPoints phase Update {
score = score + 1
}
handler DrawWorld phase Render {
Screen.clear(Color.MidnightBlue)
Screen.draw_text(x: 6, y: 4, text: "SCORE", color: Color.White, scale: 1)
Screen.draw_number(x: 52, y: 4, value: score, color: Color.Gold, scale: 1)
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>