Perspective

Methods
13
Fields
14

Methods

MethodReturnsDescription
localToCanvas(Client, LocalPoint, number)Point?(Client, LocalPoint, number) -> Point?: The canvas point of a ground point on plane, or nil behind the camera or outside the scene.
localToCanvas(Client, LocalPoint, number, number)Point?
localToCanvas(Client, number, number, number)Point?
localToCanvas(Client, number, number, number, number)Point?
localPathToCanvas(Client, GeneralPath, number)GeneralPathAlternative to Geometry.filterPath keeping the lines whose ends both project, then Geometry.transformPath moving each point to its `loc…
worldPathToLocal(Client, GeneralPath)GeneralPathAlternative to Geometry.transformPath moving each point to its LocalPoint.fromWorld less LOCAL_TILE_SIZE / 2 on each axis, a plugin's…
getCanvasTilePoly(Client, LocalPoint)Polygon?(Client, LocalPoint) -> Polygon?: The tile's outline on the canvas (south-west, then clockwise), or nil when a corner does not project.
getCanvasTilePoly(Client, LocalPoint, number)Polygon?
getCanvasTileAreaPoly(Client, LocalPoint, number)Polygon?(Client, LocalPoint, number) -> Polygon?: The outline of a size by size area centred on the point (a 3x3 area is size 3).
getCanvasTileAreaPoly(Client, LocalPoint, number, number, number, number)Polygon?
getTileHeight(Client, LocalPoint, number)numberThe ground height (negative up) at the point, interpolated from its tile's corners; a bridge tile reads the level above; 0 outside the scen…
getFootprintTileHeight(Client, LocalPoint, number, number)numberThe lowest ground height under a square footprint footprintSize local units across, centred on the point.
getCanvasTextLocation(Client, Graphics2D, LocalPoint, string?, number)Point?Where to draw text (its baseline's left end) so it is centred over the point, zOffset up, measured in graphics' font; nil for a `ni…
getCanvasImageLocation(Client, LocalPoint, BufferedImage, number)Point?The top-left corner that centres image over the point, zOffset up.
getCanvasSpriteLocation(Client, LocalPoint, SpritePixels, number)Point?The top-left corner that centres sprite over the point, zOffset up.
localToMinimap(Client, LocalPoint)Point?(Client, LocalPoint) -> Point?: The canvas point of a local point on the minimap, or nil past the cut-off (20 tiles at the default zoom…
localToMinimap(Client, LocalPoint, number)Point?
getMiniMapImageLocation(Client, LocalPoint, BufferedImage)Point?The top-left corner that centres image on the point's minimap position.
getCanvasTextMiniMapLocation(Client, Graphics2D, LocalPoint, string)Point?Where to draw text (its baseline's left end) so it is centred on the point's minimap position, measured in graphics' font; nil off th…

Fields

FieldTypeDescription
LOCAL_COORD_BITSnumberBits of a local coordinate below the tile: 7.
LOCAL_TILE_SIZEnumberA tile in local units: 128.
LOCAL_HALF_TILE_SIZEnumberHalf a tile in local units: 64.
SCENE_SIZEnumberThe scene's size in tiles: 104. The live world view's size is client:getTopLevelWorldView():getSizeX().
UNITnumberRadians per 2048th of a turn (about pi / 1024).
UNIT14numberRadians per 16384th of a turn (about pi / 8192).
SINE{number}The sine of each 2048th of a turn times 65536, truncated: a frozen 1-based array (the sine of angle a is Perspective.SINE[a + 1]).
COSINE{number}The cosine of each 2048th of a turn times 65536, truncated (1-based, as SINE).
SINE14{number}The sine of each 16384th of a turn times 65536, truncated (1-based, as SINE).
COSINE14{number}The cosine of each 16384th of a turn times 65536, truncated (1-based, as SINE).
SINEF{number}The sine of each 2048th of a turn as a 32-bit float (1-based, as SINE).
COSINEF{number}The cosine of each 2048th of a turn as a 32-bit float (1-based, as SINE).
SINEF14{number}The sine of each 16384th of a turn as a 32-bit float (1-based, as SINE).
COSINEF14{number}The cosine of each 16384th of a turn as a 32-bit float (1-based, as SINE).

Method details

localToCanvas

localToCanvas: ((Client, LocalPoint, number) -> Point?) & ((Client, LocalPoint, number, number) -> Point?) & ((Client, number, number, number) -> Point?) & ((Client, number, number, number, number) -> Point?)

(Client, LocalPoint, number) -> Point?: The canvas point of a ground point on plane, or nil behind the camera or outside the scene.

(Client, LocalPoint, number, number) -> Point?: The canvas point heightOffset above a ground point on plane.

(Client, number, number, number) -> Point?: The canvas point of a top-level local point at height z (negative is up), or nil behind the camera or outside the extended scene.

(Client, number, number, number, number) -> Point?: As the four-argument form, for a point in world view worldId; another world view than the top level answers nil.

localPathToCanvas

localPathToCanvas: (Client, GeneralPath, number) -> GeneralPath

Alternative to Geometry.filterPath keeping the lines whose ends both project, then Geometry.transformPath moving each point to its localToCanvas, an overlay's projection of a path of local points: the same canvas path, in one Rust pass with each point projected once and no Luau function per point. A lone move to a point that does not project is left out (it draws nothing). With no scene (logged out, loading) nothing projects and the path is empty.

worldPathToLocal

worldPathToLocal: (Client, GeneralPath) -> GeneralPath

Alternative to Geometry.transformPath moving each point to its LocalPoint.fromWorld less LOCAL_TILE_SIZE / 2 on each axis, a plugin's conversion of a path of world tiles to local units (after a clipPath to the scene): the same path in one Rust pass, with no Luau function per point. A point outside the scene raises NullPointerException.

getCanvasTilePoly

getCanvasTilePoly: ((Client, LocalPoint) -> Polygon?) & ((Client, LocalPoint, number) -> Polygon?)

(Client, LocalPoint) -> Polygon?: The tile's outline on the canvas (south-west, then clockwise), or nil when a corner does not project.

(Client, LocalPoint, number) -> Polygon?: The tile's outline raised by zOffset.

getCanvasTileAreaPoly

getCanvasTileAreaPoly: ((Client, LocalPoint, number) -> Polygon?) & ((Client, LocalPoint, number, number, number, number) -> Polygon?)

(Client, LocalPoint, number) -> Polygon?: The outline of a size by size area centred on the point (a 3x3 area is size 3).

(Client, LocalPoint, number, number, number, number) -> Polygon?: The outline of a sizeX by sizeY area centred on the point, on level (-1: the world view's plane), raised by heightOffset.

getTileHeight

getTileHeight: (Client, LocalPoint, number) -> number

The ground height (negative up) at the point, interpolated from its tile's corners; a bridge tile reads the level above; 0 outside the scene.

getFootprintTileHeight

getFootprintTileHeight: (Client, LocalPoint, number, number) -> number

The lowest ground height under a square footprint footprintSize local units across, centred on the point.

getCanvasTextLocation

getCanvasTextLocation: (Client, Graphics2D, LocalPoint, string?, number) -> Point?

Where to draw text (its baseline's left end) so it is centred over the point, zOffset up, measured in graphics' font; nil for a nil text or a point that does not project.

localToMinimap

localToMinimap: ((Client, LocalPoint) -> Point?) & ((Client, LocalPoint, number) -> Point?)

(Client, LocalPoint) -> Point?: The canvas point of a local point on the minimap, or nil past the cut-off (20 tiles at the default zoom) or with the minimap hidden.

(Client, LocalPoint, number) -> Point?: As the two-argument form, within distance local units of the camera focus.