@expofp/floorplan
Version:
Interactive floor plan library for expos and events
65 lines • 3.48 kB
TypeScript
/**
* How a count is written on a cluster marker: the count itself up to 99, and `99+` above that.
*
* Three characters is the most the counter circle holds, and the font size is chosen for three, so
* a longer label would have to be drawn smaller or clipped.
* @param count - How many points the cluster holds.
* @returns The label.
*/
export declare function clusterCountText(count: number): string;
/**
* The counter circle inside a cluster pin, in CSS pixels from the pin's top-left corner. The pin
* fills its canvas, so this is also the canvas's CSS coordinate space.
* @param widthPx - The pin's width in CSS pixels.
* @returns The circle's center and radius.
*/
export declare function clusterCounterCircle(widthPx: number): {
cx: number;
cy: number;
r: number;
};
/**
* The count's em height, chosen once so that `99+` — the widest label — fits inside the circle, and
* used for every count so a marker does not change size as its membership changes.
*
* The label's half-diagonal is what has to fit, not its half-width: a box inscribed in a circle
* touches at its corners.
* @param radiusPx - The counter circle's radius in CSS pixels.
* @returns The font size in CSS pixels.
*/
export declare function clusterCountFontPx(radiusPx: number): number;
/**
* The teardrop's height as a fraction of its width, for every pin drawn from `createPinCanvas`.
* Here rather than in `canvases.ts`, so a pin's height is computable without loading a module that
* builds a canvas.
*/
export declare const PIN_ASPECT: number;
/** The pin head's radius as a fraction of the pin's width, for the PoI pin and the cluster pin. */
export declare const PIN_HEAD_FACTOR = 0.37;
/** The edge stroke's width in CSS pixels, which `createPinCanvas` also takes as its inset. */
export declare const PIN_EDGE_PX = 1.4;
/** The counter circle's radius as a fraction of the pin head's radius. */
export declare const CLUSTER_CIRCLE_FACTOR = 0.78;
/**
* One character's advance width as a fraction of the font size, for the SDK's condensed face.
*
* An estimate, like {@link CLUSTER_COUNT_CAP_EM} and {@link CLUSTER_COUNT_FIT}, rather than a
* computation: the count is laid out by the renderer's text engine and not by a 2D context, so
* there is nothing here to call `measureText` on. Nothing automated checks the three against the
* shipped font. The renderer's `ClusterCounts` baselines draw a fixture font, so they check the
* layout, not these numbers. The real check is visual: run the app and look at a `99+` marker.
*/
export declare const CLUSTER_COUNT_ADVANCE_EM = 0.58;
/**
* How far below a `top`-aligned line's top edge the digits' ink center sits, in em. Troika anchors
* the line at the block's top, ascender space included, so this lifts the glyphs from that edge onto
* the circle's center. Measured in the running app with the shipped font (device ratios 1 and 2, one
* to three characters), not half the block, which was the 0.5 it replaced. The name keeps the old
* "half block" wording. The renderer story `ClusterCounts` keeps its own value for its fixture font.
*/
export declare const COUNT_BLOCK_HALF_EM = 0.61;
/** A digit's cap height as a fraction of the font size, measured the same way. */
export declare const CLUSTER_COUNT_CAP_EM = 0.72;
/** How much of the circle the label claims, leaving a visible ring of white around it. */
export declare const CLUSTER_COUNT_FIT = 0.88;
//# sourceMappingURL=pin-geometry.d.ts.map