Skip to main content

Pixel

Pixel is the 2D renderer that's built into Posthoc. It's designed for large-scale pathfinding search problems. It stays performant when there are millions of elements.

Alt text

Coordinate system

In Pixel, the x axis is horizontal, spanning left to right, and the y axis is vertical, spanning top to bottom. Lengths are measured in px units.

Performance

Pixel uses multi-threaded, tile-based rendering with viewport culling. You can zoom in and out infinitely without loss in quality. It also uses dynamic resolution, dropping the resolution down when the framerate decreases to help make playback smoother.

Alt text

If you find that Pixel is starting to get laggy, here are some tips to improve rendering performance.

  • Turn off acrylic
    The Settings > General > Acrylic option can decrease general UI performance. You can turn this off to make Pixel faster.
  • Combine elements
    Pixel's performance declines roughly linearly with the amount of elements. You can try to minimise the amount of elements by combining them. For example, draw a single large rectangle rather than several small rectangles.
  • Avoid text
    Text rendering is considerably slower than shapes. Consider storing additional information in $info instead.

API

Primitives

rect

PropertyTypeDescription
xnumber (px)Required. Horizontal position of the top left corner of this rectangle.
ynumber (px)Required. Vertical position of the top left corner of this rectangle.
widthnumber (px)Required. Width of this rectangle.
heightnumber (px)Required. Height of the rectangle.
fillCSSColorRequired. Color of this rect.
alphanumber (0-1)Opaqueness of this rect.
labelstringDisplay a label on top of this element. By default, its baseline left-aligned to the top left corner of the rectangle.
label-xnumber (px)Offset the label by this amount horizontally.
label-ynumber (px)Offset the label by this amount vertically.
label-sizenumber (px)Required if a label is defined. The font size of the label. 1px makes the label about 1px tall.
label-colorCSSColorRequired if a label is defined. The color of the label.

circle

PropertyTypeDescription
xnumberRequired. The horizontal position of this circle's center.
ynumberRequired. The vertical position of this circle's center.
radiusnumberRequired. The radius of this circle.
fillCSSColorRequired. Color of this circle.
alphanumber (0-1)Opaqueness of this circle.
labelstringDisplay a label on top of this element. By default, its baseline left-aligned to the center of the circle.
label-xnumber (px)Offset the label by this amount horizontally.
label-ynumber (px)Offset the label by this amount vertically.
label-sizenumber (px)Required if a label is defined. The font size of the label. 1px makes the label about 1px tall.
label-colorCSSColorRequired if a label is defined. The color of the label.

path

PropertyTypeDescription
points{ x: number, y: number }[]Required. The points on the path.
fillCSSColorRequired. Color of this path.
line-widthnumber (px)The width of this path.
alphanumber (0-1)Opaqueness of this path.

polygon

PropertyTypeDescription
points{ x: number, y: number }[]Required. The points on this polygon.
fillCSSColorRequired. Color of this polygon.
alphanumber (0-1)Opaqueness of this polygon.

Pixel standalone

warning

This section is incomplete.

You can use the Pixel renderer without Posthoc.