62 lines
1.9 KiB
TypeScript
62 lines
1.9 KiB
TypeScript
import * as core from "graphics-core";
|
|
|
|
/**
|
|
* Clear the screen.
|
|
*
|
|
* @param r - The red component of the color to clear to, from 0 to 1.
|
|
* @param g - The green component of the color to clear to, from 0 to 1.
|
|
* @param b - The blue component of the color to clear to, from 0 to 1.
|
|
*/
|
|
export function cls(r: number, g: number, b: number) {
|
|
core.cls(r, g, b);
|
|
}
|
|
|
|
/**
|
|
* Print a message to the console.
|
|
*
|
|
* @remarks
|
|
* The specified arguments will be printed to the console, one at a time,
|
|
* separated by spaces. If you want them separated by something else,
|
|
* format the string yourself.
|
|
*
|
|
* @param args - Arguments to print to the console.
|
|
*/
|
|
export function print(...args: unknown[]) {
|
|
core.print(args.join(" "));
|
|
}
|
|
|
|
/**
|
|
* Draw a sprite.
|
|
*
|
|
* @param x - The x coordinate of the upper-left pixel of the sprite.
|
|
* @param y - The y coordinate of the upper-left pixel of the sprite.
|
|
* @param w - The width of the target rectangle, in pixels.
|
|
* @param h - The height of the target rectangle, in pixels.
|
|
* @param sx - The x offset of the upper-left pixel of the sprite in the current sheet, in pixels.
|
|
* @param sy - The y offset of the upper-left pixel of the sprite in the current sheet, in pixels.
|
|
* @param sw - The width of the sprite, in pixels. If null or not specified, defaults to the width of the target rectangle.
|
|
* @param sh - The height of the sprite, in pixels. If null or not specified, defaults to the height of the target rectangle.
|
|
*/
|
|
export function spr(
|
|
x: number,
|
|
y: number,
|
|
w: number,
|
|
h: number,
|
|
sx: number,
|
|
sy: number,
|
|
sw: number | null = null,
|
|
sh: number | null = null
|
|
) {
|
|
sw = sw || w;
|
|
sh = sh || h;
|
|
core.spr(x, y, w, h, sx, sy, sw, sh);
|
|
}
|
|
|
|
/**
|
|
* Set the specified texture as the current texture for calls to e.g. spr().
|
|
*
|
|
* @param id - The identifier of the texture to use.
|
|
*/
|
|
export function use_texture(id: number) {
|
|
core.use_texture(id);
|
|
}
|