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

41 lines
No EOL
3.1 KiB
HTML
Raw 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_text — Ludic</title>
<meta name="description" content="Draw a string with the built-in font at an integer scale.">
<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_text</span></div>
<div class="item-head">
<span class="kind-badge kind-method">method</span>
<h1 id="top">Screen.draw_text</h1>
</div>
<code class="sig">Screen.draw_text(x, y, text, color, scale)</code>
<div class="desc"><p>Draws a string using Ludic's built-in bitmap font, starting at the top-left pixel <code>(x, y)</code>. The <code>scale</code> is an integer multiplier: <code>1</code> is the native font size, <code>2</code> is double-height and double-width, and so on — there are no fractional sizes. Use it for labels, menus, and messages such as titles or "GAME OVER"; for numbers that change every frame prefer <code>Screen.draw_number</code>, which needs no string conversion. The text is drawn in the given color over whatever is already on screen.</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 character, in pixels</span></div><div class="param" id="param-y"><code class="pname">y</code><span class="pdesc">the top edge of the text, in pixels</span></div><div class="param" id="param-text"><code class="pname">text</code><span class="pdesc">the string to draw</span></div><div class="param" id="param-color"><code class="pname">color</code><span class="pdesc">the text 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 TitleScreen {
var elapsed_frames: int = 0
handler CountFrames phase Update {
elapsed_frames = elapsed_frames + 1
}
handler DrawWorld phase Render {
Screen.clear(Color.MidnightBlue)
Screen.draw_text(x: 40, y: 60, text: "CHRONORIFT", color: Color.Gold, scale: 3)
Screen.draw_text(x: 64, y: 120, text: "PRESS ANY KEY", color: Color.White, 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>