SpritePixels

A 2D pixel buffer used as the output of the software 3D rasterizer. Holds RGBA pixels in ABGR format (matching Simba’s PColorBGRA / TImage), with width and height matching the target buffer size (36 × 32 for items).

Methods: DrawBorder(color) — draws an outline around non-transparent pixels. DrawShadow(color) — draws a drop shadow behind non-transparent pixels. ToImage() — converts the buffer to a Simba TImage with full alpha.


SpritePixels.Create

function TSpritePixels.Create(w, h: Integer): TSpritePixels; static;

An empty, fully transparent pixel buffer.


SpritePixels.DrawBorder

procedure TSpritePixels.DrawBorder(color: Integer);

Outlines the drawn pixels, colouring every transparent pixel that touches one of them on any of its four sides.

It builds a second buffer rather than writing in place, so that the outline it is adding does not itself count as a neighbour and grow outwards.


SpritePixels.DrawShadow

procedure TSpritePixels.DrawShadow(color: Integer);

Casts a one pixel shadow down and to the right of the drawn pixels.

This one does work in place, walking from the bottom right corner backwards so that a pixel it writes is never read again as a source.


SpritePixels.Overlay

procedure TSpritePixels.Overlay(const sprite: TSpritePixels);

Draws sprite on top of this buffer, skipping its transparent pixels. Both buffers must be the same size and both must have had TSpritePixels.DrawBorder called on them.

Border and Mask follow what ends up visible: every pixel sprite covers takes sprite’s border in place of this buffer’s, and becomes part of the mask if it was not already.


SpritePixels.DrawAtOn

procedure TSpritePixels.DrawAtOn(var graphics: TGraphics3D; x, y: Integer);

Copies this buffer onto a rasterizer’s buffer at x, y, clipped to its draw region and skipping transparent pixels.


SpritePixels.ToImage

function TSpritePixels.ToImage(): TImage;

The buffer as an image with proper transparency.

Nothing has to be converted here. The rasterizer draws through ColorUtils.Palette, whose entries are already in the order TImage.FromData reads and already carry a full alpha byte, so a pixel that was drawn is opaque and a pixel that was never touched is still zero - transparent, which is exactly how the original client turns its buffers into images.


SpritePixels.BorderImage

function TSpritePixels.BorderImage(): TImage;

Get an image of the sprite border.


SpritePixels.MaskImage

function TSpritePixels.MaskImage(): TImage;

Get an image of the sprite mask. Basically an image of the item fully white to mask it’s background.