@expofp/floorplan
Version:
Interactive floor plan library for expos and events
80 lines • 3.37 kB
TypeScript
import { type LayerDef, type ShapeDef, type TextDef } from '@expofp/renderer';
import { type Booth, RegularBooth } from '../../../../store/BoothStore';
export declare function createBoothBadge(booth: RegularBooth): {
bg: ShapeDef;
text: TextDef;
dispose: () => void;
};
/**
* Lays a booth's badge out as the plan zooms: the background rect, and the booth number inside it.
*
* One instance per badge, holding the geometry the layout reads — where the badge is anchored inside
* the booth's footprint, its size at scale 1, and the scale beyond which it would spill out of the
* polygon. The defs' `onScale` closures delegate to the two methods here.
*/
export declare class BoothBadgeDrawer {
private readonly placement;
/**
* @param placement - Everything the layout reads: the booth, where the badge is anchored, its size
* at scale 1, the booth's rotation, the scale it may not exceed, the pixel ratio its font is
* authored against, and the two defs it writes.
*/
constructor(placement: BadgePlacement);
/**
* Lays the background rect out for a new pixel size.
* @param pixelSize - Plan units per device pixel.
* @returns The background unless its floor is switched off — the rect is kept current either
* way, so showing it draws the right size straight away.
*/
layOutBg(pixelSize: number): ShapeDef[];
/**
* Lays the booth number out for a new pixel size. The font stops growing at the scale the badge
* itself stops growing, so the text never outgrows the rect around it.
* @param pixelSize - Plan units per device pixel.
* @returns The text unless its floor is switched off, as for the background.
*/
layOutText(pixelSize: number): TextDef[];
/**
* The badge's rect at a pixel size, clamped to what fits inside the booth.
*
* The anchor is in world space and names the badge's top-left corner, so the center is
* `anchor + R(rotation) · (w/2, h/2)`; the renderer then rotates the badge about that center, which
* lands it where the anchor says.
* @param pixelSize - Plan units per device pixel.
* @returns The rect.
*/
private rectScaled;
/**
* Whether the badge's floor is switched off, which hides it wherever it sits.
* @returns Whether to hide it.
*/
private isHidden;
}
/** Everything {@link BoothBadgeDrawer} needs to place a badge, gathered once when it is built. */
export interface BadgePlacement {
/** The booth the badge belongs to; its layer's visibility decides whether the badge is drawn. */
booth: RegularBooth;
/** Where the badge's top-left corner sits on the plan, before rotation. */
anchor: {
x: number;
y: number;
};
/** The badge's width and height at scale 1. */
source: {
x: number;
y: number;
};
/** The booth's rotation, in radians. */
rotation: number;
/** The largest scale that still fits inside the booth's footprint. */
maxScale: number;
/** The badge's background rect. */
bg: ShapeDef;
/** The booth number drawn inside it. */
text: TextDef;
}
export declare function configBoothsBadges(layerName: string, booths: Booth[]): {
layer: LayerDef | null;
cleanup: () => void;
};
//# sourceMappingURL=config-booth-badge.d.ts.map