LWXGL’s primitive drawing functions write palette-indexed color values directly into anDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/DRESSedAlarm184/LWXGL/llms.txt
Use this file to discover all available pages before exploring further.
ImageElement’s pixel data buffer. Because they operate on raw memory rather than the X11 display, they are fast to call in tight loops and let you build up complex scenes pixel-by-pixel. Once you have finished drawing, call UpdateImage(id) to detect changed pixels and flush them to the backing X11 pixmap — changes are not visible on screen until that call is made. All coordinates are relative to the top-left corner of the image element, and every function silently clips pixels that fall outside the element’s bounds.
PrimitiveRect
Draws a filled rectangle with an optional border into an image element.
fg; every interior pixel uses bg. At the start of the function, if fg == -1 the implementation sets fg = bg before drawing — so passing CLR_NONE for fg causes the border to be drawn in the same color as the fill, making it visually indistinguishable from a solid filled rectangle. Only passing CLR_NONE for bg actually skips filling the interior.
Passing
CLR_NONE (-1) for fg does not omit the border — it redirects the border color to bg, producing a uniformly filled solid rectangle. To draw a border without fill, pass a valid fg and CLR_NONE for bg. Passing CLR_NONE for both is a no-op.ID of the target image element (previously created with
CreateImage).X coordinate of the rectangle’s top-left corner, relative to the image element origin.
Y coordinate of the rectangle’s top-left corner, relative to the image element origin.
Width of the rectangle in pixels.
Height of the rectangle in pixels.
Palette index (0–15) for the border color. Passing
CLR_NONE (-1) causes the border to be drawn in the same color as bg rather than omitting it.Palette index (0–15) for the fill color, or
CLR_NONE (-1) to omit the fill.PrimitiveCircle
Draws a filled circle centered at a given point.
|dx² + dy² − r²| < r, giving a one-pixel-wide anti-aliased ring without floating-point math. Interior pixels (where dx² + dy² ≤ r²) receive bg. If fg and bg overlap on the same pixel, fg takes priority.
ID of the target image element.
X coordinate of the circle center.
Y coordinate of the circle center.
Radius in pixels.
Palette index for the border, or
CLR_NONE to omit.Palette index for the fill, or
CLR_NONE to omit.PrimitiveLine
Draws a straight line between two points using a DDA (Digital Differential Analyzer) algorithm.
|dx| or |dy| is larger) and steps one pixel at a time, interpolating the minor axis linearly. Each computed pixel coordinate is rounded to the nearest integer before being written. Pixels that fall outside the image bounds are skipped without error.
ID of the target image element.
X coordinate of the line start point.
Y coordinate of the line start point.
X coordinate of the line end point.
Y coordinate of the line end point.
Palette index (0–15) for the line color.
PrimitiveTriangle
Draws a filled triangle defined by three vertices, with an optional outline.
fg is not CLR_NONE, the three edges are drawn on top of the fill using PrimitiveLine.
ID of the target image element.
X coordinate of the first vertex.
Y coordinate of the first vertex.
X coordinate of the second vertex.
Y coordinate of the second vertex.
X coordinate of the third vertex.
Y coordinate of the third vertex.
Palette index for the border lines, or
CLR_NONE to omit.Palette index for the filled interior, or
CLR_NONE to omit.PrimitiveSprite
Renders an RLE-encoded monochrome sprite into an image element at a given position and scale.
scale × scale block, so a scale of 2 produces a sprite twice as wide and tall as its definition. The foreground color index is supplied via color; background pixels ('.') are always written as palette index 0 (CLR_BLACK).
ID of the target image element.
X coordinate of the top-left pixel of the sprite.
Y coordinate of the top-left pixel of the sprite.
Palette index for foreground (
'#') pixels.Null-terminated RLE sprite string (see format table below).
Integer pixel scale factor.
1 = 1:1, 2 = 2× magnification, etc.Sprite RLE format
| Token | Meaning |
|---|---|
# | Draw one foreground pixel (palette index color) and advance X by scale. |
. | Draw one background pixel (palette index 0 / CLR_BLACK) and advance X by scale. |
$ | Move X back to sx and advance Y by runs × scale (1 row by default; a digit prefix N$ skips N rows). |
> | Skip (advance X) without drawing — useful for transparent gaps. |
0–9 | Prefix digit(s) — sets the repeat count for the following token. |
[…] | Group: repeat the bracketed sub-expression. A numeric prefix sets the repeat count (default 1). Groups may be nested. |
| RLE string | Result |
|---|---|
3# | Three consecutive foreground pixels. |
2. | Two consecutive background pixels. |
3#2.$ | Three foreground pixels, two background pixels, then newline. |
2[3#.] | The sequence 3#. repeated twice → 3#.3#.. |
5> | Advance five pixels without drawing (transparent gap). |
The
> token with a numeric prefix (5>) advances count × scale pixels, making it efficient for transparent horizontal gaps in icons or HUD sprites.