npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@l8b/screen

v1.0.11

Published

**LootiScript API Binding** - 2D rendering system with primitives, sprites, text, and 3D triangle support.

Downloads

2,778

Readme

@l8b/screen

LootiScript API Binding - 2D rendering system with primitives, sprites, text, and 3D triangle support.

Note: This package is used as an API binding for LootiScript in the l8b engine.

API Reference

Properties

// Screen dimensions (logical coordinates)
local w = screen.width
local h = screen.height

// Canvas context (for advanced usage)
local ctx = screen.context

Drawing State

screen.clear()

Clear the screen with a color.

// Clear to black
screen.clear("#000000")

// Clear to custom color
screen.clear("#FF0000")
screen.clear("red")

screen.setColor()

Set the current drawing color.

screen.setColor("#FFFFFF")
screen.setColor("red")
screen.setColor(999)  // Numeric color (RGB)

screen.setAlpha()

Set transparency level.

screen.setAlpha(1.0)   // Fully opaque
screen.setAlpha(0.5)   // 50% transparent
screen.setAlpha(0.0)   // Fully transparent

screen.setPixelated()

Set pixelation mode.

screen.setPixelated(1)  // Pixelated (nearest neighbor)
screen.setPixelated(0)  // Smooth (linear filtering)

screen.setBlending()

Set blend mode.

screen.setBlending("normal")
screen.setBlending("additive")
screen.setBlending("multiply")
screen.setBlending("screen")

Transformations

screen.setTranslation()

Translate the coordinate system.

screen.setTranslation(100, 50)
// All subsequent draws are offset by (100, 50)

// Reset
screen.setTranslation(0, 0)

screen.setScale()

Scale the coordinate system.

screen.setScale(2, 2)    // 2x scale
screen.setScale(1, -1)   // Flip vertically

// Reset
screen.setScale(1, 1)

screen.setRotation()

Rotate the coordinate system.

screen.setRotation(45)   // Rotate 45 degrees
screen.setRotation(0)    // Reset

screen.setDrawAnchor()

Set anchor point for object transformations.

screen.setDrawAnchor(0.5, 0.5)  // Center anchor
screen.setDrawAnchor(0, 0)      // Top-left anchor

screen.setDrawRotation()

Set rotation for individual objects.

screen.setDrawRotation(45)
screen.drawSprite("player", 100, 100)
screen.setDrawRotation(0)  // Reset

screen.setDrawScale()

Set scale for individual objects.

screen.setDrawScale(2, 2)      // 2x scale
screen.setDrawScale(1, -1)     // Flip vertically
screen.setDrawScale(1, 1)      // Reset

Rectangles

screen.fillRect()

Draw a filled rectangle.

screen.fillRect(10, 10, 50, 50)
screen.fillRect(10, 10, 50, 50, "#FF0000")

screen.drawRect()

Draw a rectangle outline.

screen.drawRect(10, 10, 50, 50)
screen.drawRect(10, 10, 50, 50, "#00FF00")

screen.fillRoundRect()

Draw a filled rounded rectangle.

screen.fillRoundRect(10, 10, 50, 50, 10)  // 10px radius
screen.fillRoundRect(10, 10, 50, 50, 10, "#FF0000")

screen.drawRoundRect()

Draw a rounded rectangle outline.

screen.drawRoundRect(10, 10, 50, 50, 10)
screen.drawRoundRect(10, 10, 50, 50, 10, "#00FF00")

screen.fillRound()

Draw a filled circle/ellipse.

screen.fillRound(100, 100, 30, 30)  // Circle
screen.fillRound(100, 100, 50, 30, "#FF0000")  // Ellipse

screen.drawRound()

Draw a circle/ellipse outline.

screen.drawRound(100, 100, 30, 30)
screen.drawRound(100, 100, 50, 30, "#00FF00")

Lines and Shapes

screen.setLineWidth()

Set line width for strokes.

screen.setLineWidth(2)
screen.setLineWidth(5)

screen.setLineDash()

Set line dash pattern.

screen.setLineDash({5, 5})  // 5px dash, 5px gap
screen.setLineDash({10, 5, 2, 5})  // Complex pattern
screen.setLineDash(null)  // Solid line

screen.drawLine()

Draw a line.

screen.drawLine(0, 0, 100, 100)
screen.drawLine(0, 0, 100, 100, "#FFFFFF")

screen.drawPolyline()

Draw connected lines.

screen.drawPolyline(10, 10, 50, 50, 100, 10)
screen.drawPolyline(10, 10, 50, 50, 100, 10, "#FF0000")

screen.drawPolygon()

Draw a polygon outline.

screen.drawPolygon(10, 10, 50, 50, 100, 10)
screen.drawPolygon(10, 10, 50, 50, 100, 10, "#00FF00")

screen.fillPolygon()

Draw a filled polygon.

screen.fillPolygon(10, 10, 50, 50, 100, 10)
screen.fillPolygon(10, 10, 50, 50, 100, 10, "#FF0000")

screen.drawArc()

Draw an arc outline.

// x, y, radius, startAngle, endAngle, counterclockwise
screen.drawArc(100, 100, 50, 0, 180, false)
screen.drawArc(100, 100, 50, 0, 180, false, "#FFFFFF")

screen.fillArc()

Draw a filled arc.

screen.fillArc(100, 100, 50, 0, 180, false)
screen.fillArc(100, 100, 50, 0, 180, false, "#FF0000")

Sprites and Images

screen.drawSprite()

Draw a sprite.

// Draw at position
screen.drawSprite("player", 100, 100)

// Draw with size
screen.drawSprite("player", 100, 100, 32, 32)

screen.drawImage()

Alias for drawSprite.

screen.drawImage("background", 0, 0, 320, 240)

screen.drawSpritePart()

Draw part of a sprite (spritesheet).

// sourceX, sourceY, sourceW, sourceH, destX, destY, destW, destH
screen.drawSpritePart("tiles", 0, 0, 16, 16, 100, 100, 32, 32)

screen.drawImagePart()

Alias for drawSpritePart.

screen.drawImagePart("atlas", 32, 0, 16, 16, 50, 50, 16, 16)

Maps

screen.drawMap()

Draw a tile map.

// map, x, y, width, height
screen.drawMap(myMap, 0, 0, 320, 240)

Text

screen.setFont()

Set the current font.

screen.setFont("BitCell")
screen.setFont("Arial")

screen.loadFont()

Load a font.

screen.loadFont("CustomFont")

screen.isFontReady()

Check if a font is loaded.

if screen.isFontReady("CustomFont") == 1 then
  // Font is ready
end

screen.drawText()

Draw text.

screen.drawText("Hello World", 10, 10, 16)
screen.drawText("Score: 100", 10, 30, 12, "#FFFF00")

screen.drawTextOutline()

Draw outlined text.

screen.drawTextOutline("Game Over", 100, 100, 24)
screen.drawTextOutline("Level Up!", 100, 100, 20, "#00FF00")

screen.textWidth()

Get text width.

local width = screen.textWidth("Hello", 16)

Gradients

screen.setLinearGradient()

Set a linear gradient.

// x1, y1, x2, y2, color1, color2
screen.setLinearGradient(0, 0, 100, 0, "#FF0000", "#0000FF")
screen.fillRect(0, 0, 100, 50)

screen.setRadialGradient()

Set a radial gradient.

// x, y, radius, color1, color2
screen.setRadialGradient(50, 50, 50, "#FFFFFF", "#000000")
screen.fillRound(50, 50, 50, 50)

3D Triangles

screen.tri()

Draw a filled triangle.

// x1, y1, x2, y2, x3, y3
screen.tri(10, 10, 50, 10, 30, 50)
screen.tri(10, 10, 50, 10, 30, 50, "#FF0000")

screen.trib()

Draw a triangle outline.

screen.trib(10, 10, 50, 10, 30, 50)
screen.trib(10, 10, 50, 10, 30, 50, "#00FF00")

screen.ttri()

Draw a textured triangle (3D).

// x1, y1, x2, y2, x3, y3, u1, v1, u2, v2, u3, v3, texture
screen.ttri(
  10, 10, 50, 10, 30, 50,  // Vertices
  0, 0, 1, 0, 0.5, 1,      // UV coordinates
  "wall_texture"            // Texture
)

// With depth (z-buffering)
screen.ttri(
  10, 10, 50, 10, 30, 50,
  0, 0, 1, 0, 0.5, 1,
  "texture",
  null,  // textureSource
  0, 0, 0,  // z1, z2, z3
  true  // useDepth
)

Cursor

screen.setCursorVisible()

Show or hide the mouse cursor.

screen.setCursorVisible(false)  // Hide cursor
screen.setCursorVisible(true)   // Show cursor

Example Usage

function draw()
  // Clear screen
  screen.clear("#000000")
  
  // Draw background
  screen.setColor("#333333")
  screen.fillRect(0, 0, screen.width, screen.height)
  
  // Draw player
  screen.drawSprite("player", playerX, playerY, 32, 32)
  
  // Draw UI
  screen.setFont("BitCell")
  screen.setColor("#FFFFFF")
  screen.drawText("Score: " .. score, 10, 10, 12)
  
  // Draw health bar
  screen.setColor("#FF0000")
  screen.fillRect(10, 30, health * 2, 10)
  screen.setColor("#FFFFFF")
  screen.drawRect(10, 30, 200, 10)
end