Panel Graphics Primitives
These routines draw 2-D vector primitives: lines, line strips, line loops, filled polygons, and quad strips.
Line-based primitives (Lines, LineStrip, LineLoop) have four variants:
- Base variant: uniform color, default line width.
- WithWidth variant: uniform color, caller-specified line width.
- "c" variant: per-vertex color (using XPLMVertexColor_t), default line width.
- "c" + WithWidth variant: per-vertex color and caller-specified line width.
They also have a Stipple variant that draws dashed lines with a caller-specified dash length and line width.
Filled primitives (Polygon, Quadstrip) have no line width, so they come in only the base and "c" variants.
XPLMVertex_t
struct
A 2-D vertex with an x and y position in panel coordinates.
local My_Vertex_t = {
x = 0.0, -- float
y = 0.0, -- float
}
XPLMVertexColor_t
struct
A 2-D vertex with an x and y position in panel coordinates and a per-vertex color. Use this struct with the "c" drawing variants to assign a different color to each vertex; colors are interpolated across the primitive.
local My_VertexColor_t = {
x = 0.0, -- float
y = 0.0, -- float
color = nil, -- see uint32_t / XPLMMakeColor
}
XPLMMakeColor
function
This function packs four floating-point color components into a single uint32_t suitable for use with all panel graphics drawing routines. Each component is in the range 0.0 to 1.0 and is clamped before packing. The returned value is in ABGR byte order (alpha in the high byte, red in the low byte).
-- returns uint32_t -> assign to local/var
local my_result = XPLMMakeColor(
red, -- float
green, -- float
blue, -- float
alpha -- float
)
XPLMLines
function
This function draws disconnected line segments. Every pair of vertices defines one segment: the first segment runs from vertices[0] to vertices[1], the second from vertices[2] to vertices[3], and so on.
- count: the number of vertices. Should be even; an odd trailing vertex is ignored.
XPLMLines(
color, -- see uint32_t / XPLMMakeColor
vertices, -- see XPLMVertex_t
count -- ArraySize
)
See associated types:
XPLMLinesWithWidth
function
This function draws disconnected line segments with a caller-specified line width. Vertex interpretation is the same as XPLMLines.
- lineWidth: the line width in pixels.
XPLMLinesWithWidth(
color, -- see uint32_t / XPLMMakeColor
lineWidth, -- float
vertices, -- see XPLMVertex_t
count -- ArraySize
)
See associated types:
XPLMLinesc
function
This function draws disconnected line segments with per-vertex colors. Vertex interpretation is the same as XPLMLines; colors are interpolated along each segment.
XPLMLinesc(
vertices, -- see XPLMVertexColor_t
count -- ArraySize
)
See associated types:
XPLMLinescWithWidth
function
This function draws disconnected line segments with per-vertex colors and a caller-specified line width.
- lineWidth: the line width in pixels.
XPLMLinescWithWidth(
lineWidth, -- float
vertices, -- see XPLMVertexColor_t
count -- ArraySize
)
See associated types:
XPLMLinesStipple
function
This function draws disconnected dashed line segments. Vertex interpretation is the same as XPLMLines. The dash pattern alternates between drawn and undrawn segments of equal length.
- dashLength: the length of each dash and gap, in pixels.
- lineWidth: the line width in pixels.
XPLMLinesStipple(
color, -- see uint32_t / XPLMMakeColor
pts, -- see XPLMVertex_t
count, -- ArraySize
dashLength, -- float
lineWidth -- float
)
See associated types:
XPLMLineStrip
function
This function draws a connected line strip. Vertices are connected in order: a segment from vertices[0] to vertices[1], then from vertices[1] to vertices[2], and so on. The last vertex is not connected back to the first.
XPLMLineStrip(
color, -- see uint32_t / XPLMMakeColor
pts, -- see XPLMVertex_t
count -- ArraySize
)
See associated types:
XPLMLineStripWithWidth
function
This function draws a connected line strip with a caller-specified line width. Vertex interpretation is the same as XPLMLineStrip.
- lineWidth: the line width in pixels.
XPLMLineStripWithWidth(
color, -- see uint32_t / XPLMMakeColor
lineWidth, -- float
pts, -- see XPLMVertex_t
count -- ArraySize
)
See associated types:
XPLMLineStripc
function
This function draws a connected line strip with per-vertex colors. Vertex interpretation is the same as XPLMLineStrip; colors are interpolated along each segment.
XPLMLineStripc(
pts, -- see XPLMVertexColor_t
count -- ArraySize
)
See associated types:
XPLMLineStripcWithWidth
function
This function draws a connected line strip with per-vertex colors and a caller-specified line width.
- lineWidth: the line width in pixels.
XPLMLineStripcWithWidth(
lineWidth, -- float
pts, -- see XPLMVertexColor_t
count -- ArraySize
)
See associated types:
XPLMLineStripStipple
function
This function draws a connected dashed line strip. Vertex interpretation is the same as XPLMLineStrip. The dash pattern alternates between drawn and undrawn segments of equal length.
- dashLength: the length of each dash and gap, in pixels.
- lineWidth: the line width in pixels.
XPLMLineStripStipple(
color, -- see uint32_t / XPLMMakeColor
pts, -- see XPLMVertex_t
count, -- ArraySize
dashLength, -- float
lineWidth -- float
)
See associated types:
XPLMLineLoop
function
This function draws a closed line loop. Vertices are connected in order, and the last vertex is automatically connected back to the first, forming a closed shape. The interior is not filled.
XPLMLineLoop(
color, -- see uint32_t / XPLMMakeColor
pts, -- see XPLMVertex_t
count -- ArraySize
)
See associated types:
XPLMLineLoopWithWidth
function
This function draws a closed line loop with a caller-specified line width. Vertex interpretation is the same as XPLMLineLoop.
- lineWidth: the line width in pixels.
XPLMLineLoopWithWidth(
color, -- see uint32_t / XPLMMakeColor
lineWidth, -- float
pts, -- see XPLMVertex_t
count -- ArraySize
)
See associated types:
XPLMLineLoopc
function
This function draws a closed line loop with per-vertex colors. Vertex interpretation is the same as XPLMLineLoop; colors are interpolated along each segment.
XPLMLineLoopc(
pts, -- see XPLMVertexColor_t
count -- ArraySize
)
See associated types:
XPLMLineLoopcWithWidth
function
This function draws a closed line loop with per-vertex colors and a caller-specified line width.
- lineWidth: the line width in pixels.
XPLMLineLoopcWithWidth(
lineWidth, -- float
pts, -- see XPLMVertexColor_t
count -- ArraySize
)
See associated types:
XPLMLineLoopStipple
function
This function draws a closed dashed line loop. Vertex interpretation is the same as XPLMLineLoop. The dash pattern alternates between drawn and undrawn segments of equal length.
- dashLength: the length of each dash and gap, in pixels.
- lineWidth: the line width in pixels.
XPLMLineLoopStipple(
color, -- see uint32_t / XPLMMakeColor
pts, -- see XPLMVertex_t
count, -- ArraySize
dashLength, -- float
lineWidth -- float
)
See associated types:
XPLMPolygon
function
This function draws a filled convex polygon. The vertices define the outline of the polygon, and the interior is filled with the specified color.
- count: the number of vertices. You must provide at least 3 vertices.
XPLMPolygon(
color, -- see uint32_t / XPLMMakeColor
vertices, -- see XPLMVertex_t
count -- ArraySize
)
See associated types:
XPLMPolygonc
function
This function draws a filled convex polygon with per-vertex colors. Colors are interpolated across the polygon interior.
XPLMPolygonc(
vertices, -- see XPLMVertexColor_t
count -- ArraySize
)
See associated types:
XPLMQuadstrip
function
This function draws a series of connected filled quadrilaterals. Vertices are taken in pairs: the first quad is formed by vertices[0], vertices[1], vertices[2], vertices[3]; the next quad shares its leading edge with the previous one, formed by vertices[2], vertices[3], vertices[4], vertices[5]; and so on.
- count: the number of vertices. Must be even and at least 4.
XPLMQuadstrip(
color, -- see uint32_t / XPLMMakeColor
vertices, -- see XPLMVertex_t
count -- ArraySize
)
See associated types:
XPLMQuadstripc
function
This function draws a quad strip with per-vertex colors. Vertex interpretation is the same as XPLMQuadstrip; colors are interpolated across each quad.
XPLMQuadstripc(
vertices, -- see XPLMVertexColor_t
count -- ArraySize
)
See associated types: