ludic/ns-sprite.html
2026-09-17 22:10:03 +00:00

22 lines
No EOL
4.1 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>Sprite — Ludic</title>
<meta name="description" content="A namespaced spritesheet / atlas API.">
<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> <span class="here">Sprite</span></div>
<div class="item-head"><span class="kind-badge kind-namespace">namespace</span><h1 id="top">Sprite</h1></div>
<p class="ns-blurb">A namespaced spritesheet / atlas API. <a href="sprite-sheet"><code>Sprite.sheet</code></a> loads one image and remembers its cell grid; <a href="sprite-cell"><code>Sprite.cell</code></a> addresses a cell by grid coords and <a href="sprite-cell_span"><code>Sprite.cell_span</code></a> a sprite that spans more than one cell; <a href="sprite-define"><code>Sprite.define</code></a> / <a href="sprite-named"><code>Sprite.named</code></a> name and look up a cell; <a href="sprite-draw"><code>Sprite.draw</code></a> / <a href="sprite-draw_scaled"><code>Sprite.draw_scaled</code></a> blit it (through the camera / zoom / clip). It stands on the variable-size image loader, so a cell can be any size — not just 16x16. (Distinct from the <code>Sprite</code> engine component of the sprite-render system.)</p>
<div class="ns-methods"><a class="ns-method" href="sprite-sheet.html"><code class="nm-sig">Sprite.sheet(path, cellw, cellh) -&gt; int</code><span class="nm-tip">Load a spritesheet and remember its cell grid; returns a sheet handle.</span></a><a class="ns-method" href="sprite-cell.html"><code class="nm-sig">Sprite.cell(sheet, col, row) -&gt; int</code><span class="nm-tip">One cell of a sheet, by grid coords; returns a sprite id.</span></a><a class="ns-method" href="sprite-cell_span.html"><code class="nm-sig">Sprite.cell_span(sheet, col, row, cols, rows) -&gt; int</code><span class="nm-tip">A sprite spanning cols x rows cells (tall/wide art).</span></a><a class="ns-method" href="sprite-define.html"><code class="nm-sig">Sprite.define(name, sheet, col, row) -&gt; int</code><span class="nm-tip">Name a cell for later lookup; returns its sprite id.</span></a><a class="ns-method" href="sprite-named.html"><code class="nm-sig">Sprite.named(name) -&gt; int</code><span class="nm-tip">Look up a named sprite's id, or -1.</span></a><a class="ns-method" href="sprite-draw.html"><code class="nm-sig">Sprite.draw(id, x, y)</code><span class="nm-tip">Blit an atlas sprite at (x, y) through the camera/zoom/clip.</span></a><a class="ns-method" href="sprite-draw_scaled.html"><code class="nm-sig">Sprite.draw_scaled(id, x, y, scale)</code><span class="nm-tip">Blit an atlas sprite scaled by an integer factor.</span></a><a class="ns-method" href="sprite-width.html"><code class="nm-sig">Sprite.width(id) -&gt; int</code><span class="nm-tip">The atlas sprite's width in pixels.</span></a><a class="ns-method" href="sprite-height.html"><code class="nm-sig">Sprite.height(id) -&gt; int</code><span class="nm-tip">The atlas sprite's height in pixels.</span></a><a class="ns-method" href="sprite-strip.html"><code class="nm-sig">Sprite.strip(sheet, col, row, count, rows) -&gt; int</code><span class="nm-tip">A run of animation frames as consecutive sprite ids.</span></a><a class="ns-method" href="sprite-draw_meter.html"><code class="nm-sig">Sprite.draw_meter(x:, y:, value:, max:, per_icon:, spacing:, full:, half:, empty:)</code><span class="nm-tip">A value as a row of full / half / empty icons.</span></a></div>
<a class="back" href="api.html">← All symbols</a>
</main>
<script src="ludic-highlight.js"></script>
<script>Ludic.installCards(); Ludic.flashTarget();</script>
</body></html>