Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/spatialillusions/milsymbol/llms.txt

Use this file to discover all available pages before exploring further.

milsymbol exposes a small set of global configuration functions that control behavior shared across all subsequently created symbols. These settings act as global defaults — for example, the active military standard (MIL-STD-2525 vs. STANAG APP-6), the pixel length of headquarters staff lines, and the SVG stroke-dasharray patterns used for pending, anticipated, and feint/dummy status modifiers. Individual symbols can override some of these values through their own options (e.g. hqStaffLength and standard), but the global settings provide the baseline for any symbol that does not specify its own.

ms.setStandard()

Sets the preferred military symbology standard used when rendering symbols. APP-6 (NATO) and MIL-STD-2525 (US) occasionally differ in how certain symbols are drawn; this function selects which convention milsymbol follows by default.
function setStandard(standard: "2525" | "APP6"): boolean;
standard
"2525" | "APP6"
required
The standard to activate. Use "2525" for MIL-STD-2525 (default) or "APP6" for STANAG APP-6.
Returns true if the standard was set successfully, false otherwise.
All SIDCs will always produce some symbol regardless of which standard is active. The setting only affects symbols where APP-6 and 2525 genuinely differ in their visual output. Individual symbols can also override the global setting by passing standard: "2525" or standard: "APP6" in their options.

Example

import ms from "milsymbol";

// Switch to NATO APP-6 rendering globally
const ok = ms.setStandard("APP6");
console.log(ok); // true

// All symbols created after this point follow APP-6 conventions
const symbol = new ms.Symbol("SFG-UCI----D", { size: 60 });

// Override for a single symbol
const symbol2525 = new ms.Symbol("SFG-UCI----D", {
  size: 60,
  standard: "2525"  // per-symbol override — ignores the global APP6 setting
});

ms.getVersion()

Returns the current version string of the loaded milsymbol library.
function getVersion(): string;
Returns a string with the semantic version, e.g. "2.2.0".

Example

import ms from "milsymbol";

console.log(ms.getVersion()); // e.g. "2.2.0"

ms.getHqStaffLength() / ms.setHqStaffLength()

Headquarters symbols include a vertical staff line extending below the symbol frame. These functions read and write the global pixel length of that staff line.

ms.getHqStaffLength()

function getHqStaffLength(): number;
Returns the current HQ staff length in pixels as a number.

ms.setHqStaffLength()

function setHqStaffLength(staff_length: number): number;
staff_length
number
required
The desired staff length in pixels. This value is applied to the symbol coordinate system where the icon octagon is 100 units wide.
Returns the newly set staff length as a number.
You can override the global staff length for a single symbol by passing hqStaffLength: number in its options object. The per-symbol value takes precedence over the global setting.

Example

import ms from "milsymbol";

// Read the current default
console.log(ms.getHqStaffLength()); // e.g. 100

// Set a new global default
ms.setHqStaffLength(120);

// All HQ symbols created after this use a 120px staff
const hqSymbol = new ms.Symbol("SFG-UCI----D--HQ", { size: 60 });

// Override for one symbol only
const shortStaff = new ms.Symbol("SFG-UCI----D--HQ", {
  size: 60,
  hqStaffLength: 60  // per-symbol override
});

ms.getDashArrays() / ms.setDashArrays()

Pending, anticipated, and feint/dummy symbol modifiers are rendered with dashed SVG strokes. These functions read and write the stroke-dasharray string used for each status type.

ms.getDashArrays()

function getDashArrays(): DashObject;
Returns a DashObject:
interface DashObject {
  pending: string;     // stroke-dasharray for Pending status
  anticipated: string; // stroke-dasharray for Anticipated status
  feintDummy: string;  // stroke-dasharray for the Feint/Dummy modifier
}

ms.setDashArrays()

function setDashArrays(
  pending: string,
  anticipated: string,
  feintDummy: string
): DashObject;
pending
string
required
The SVG stroke-dasharray value for symbols with Pending status (e.g. "4,4").
anticipated
string
required
The SVG stroke-dasharray value for symbols with Anticipated status (e.g. "8,12").
feintDummy
string
required
The SVG stroke-dasharray value for the Feint/Dummy modifier (e.g. "8,8").
Returns the new DashObject with all three values set.

Example

import ms from "milsymbol";

// Read current dash arrays
const current = ms.getDashArrays();
console.log(current.pending);     // default pending dash pattern
console.log(current.anticipated); // default anticipated dash pattern
console.log(current.feintDummy);  // default feint/dummy dash pattern

// Override with custom dash patterns
const dashObj = ms.setDashArrays("4,4", "8,12", "8,8");
console.log(dashObj);
// { pending: "4,4", anticipated: "8,12", feintDummy: "8,8" }

ms.outline()

A utility function that takes one or more draw instructions and returns stroke-only (outline) versions of them. All fill properties are removed and the stroke is widened to create a halo or outline effect. This is useful for adding contrast behind symbol parts — for instance, rendering a white outline behind dark icon lines on a complex map background.
ms.outline() is a JavaScript-only internal utility. It is not included in the TypeScript type declarations (index.d.ts) and has no exported type signature. It is available at runtime on the ms namespace object but will not be recognised by TypeScript’s type checker.
// JavaScript signature (not exported in TypeScript types)
ms.outline(drawInstruction, outline, stroke, color)
drawInstruction
DrawInstruction | DrawInstruction[]
required
The draw instruction(s) to convert into outline form. Accepts both a single DrawInstruction object and an array of them.
outline
number
required
The width (in pixels, in symbol coordinate space) to add around each existing stroke. The new total stroke width will be originalStrokeWidth + 2 * outline.
stroke
number
required
The original stroke width of the draw instructions, used as the baseline when computing the enlarged outline stroke width.
color
string
required
The CSS color string to use for the outline stroke (e.g. "white", "rgb(239,239,239)").
Returns an Array or Object of draw instructions that render only the outline stroke, with fills removed.

Example

import ms from "milsymbol";

ms.addSymbolPart(function myOutlinedPart(ms) {
  const iconPath = {
    type: "path",
    d: "M 85,60 L 115,60 L 115,140 L 85,140 Z",
    fill: "rgb(0,0,0)",
    stroke: "rgb(0,0,0)",
    strokewidth: 3
  };

  // Create an outline version to draw behind the main path
  const outlinePath = ms.outline(iconPath, 2, 3, "white");

  return {
    pre: [],
    post: [outlinePath, iconPath],  // outline drawn first, then the solid path on top
    bbox: new ms.BBox({ x1: 85, y1: 60, x2: 115, y2: 140 })
  };
});

Build docs developers (and LLMs) love