Reference · Rockets, variants, parts and the fit check
scaleBarfunction
A scale bar for a sheet: a round length in metres that fits maxPixels at the scale pixelsPerMetre, with ticks, and the ratio when the sheet is dpi dots to an inch.
Import it
import { scaleBar } from "@johnmorrisdotca/uchusen-rockets";
Definition
function scaleBar(pixelsPerMetre: number, maxPixels: number, dpi?: number): ScaleBar
Parameters
| Name | Type | Description |
|---|---|---|
pixelsPerMetre | number | The sheet's scale. |
maxPixels | number | The longest bar the sheet has room for. |
dpi (optional) | number | The sheet's dots to the inch, for the ratio (default 96). |
Returns
ScaleBar
The bar: its metres, its pixels, its ticks and the ratio as text.
Examples
import { scaleBar } from "@johnmorrisdotca/uchusen-rockets";
const bar = scaleBar(2, 300);
console.log(bar.metres, bar.pixels, bar.ticks.length, bar.ratio);100 200 6 1:1890What it prints (run when this page was built)