/** * Pattern and image fills. * * A flat fill is one attribute. Anything else is a document-level resource: SVG * paints texture through `` in ``, referenced by id, so a textured * map is no longer "colour per feature" but "a small set of paints, shared". That * shape is the whole design here. * * **Paints are deduplicated by what they look like.** Five classes across three * thousand features is five `` elements, because the key is the resolved * spec and identical specs land on the same def. Image fills are the exception and * are inherently per-feature: the tile is positioned on the feature's own bounding * box, so a hundred flags really are a hundred defs. * * **Texture holds its size on screen; imagery does not.** A pattern resolves in * the user space of the element referencing it, and that element sits under the * camera transform, so an untouched tile grows with the zoom. Texture is rescaled * per camera frame by the inverse (`applyScale`), on the same reasoning as * `vector-effect: non-scaling-stroke` on borders: dots that swell into blobs stop * reading as a fill. An image fill is left alone deliberately, because there the * scaling is the point: the picture is pinned to the ground it describes and the * reader zooms into it. * * **Ids are namespaced per registry.** Two maps on one page, or one map exported * next to another, would otherwise collide on `#p0` and each would paint with * whichever def the document happened to define last. * * @module renderers/Paint */ import type { PatternFillOptions, ResolvedPattern, WorldBounds } from '../types'; export interface ResolvedImage { src: string; fit: 'cover' | 'contain' | 'fill'; background: string; opacity: number; } /** * What a series asks the renderer to paint a feature with. `color` rides along so * the caller keeps the flat fill for the places that need a colour rather than a * paint: hover, the legend, and the seed a drilldown develops out of. */ export type FeaturePaint = { kind: 'pattern'; color: string; pattern: ResolvedPattern; } | { kind: 'image'; color: string; image: ResolvedImage; }; /** * Ink for a tile whose colour the caller left to us. * * Exported because the tile is not the only thing that has to make this call: a * legend swatch drawing the same pattern has to reach the same answer. */ export declare function patternInk(background: string): string; /** * Apply the defaults, resolving ink and background against the colour the scale * chose. Lives here rather than in the series because it is the same decision the * tile geometry below is made of. */ export declare function resolvePattern(options: PatternFillOptions, color: string): ResolvedPattern; /** * A self-contained swatch for a legend entry: the tile the map is painted with. * * The legend is HTML, and the obvious route is a CSS `background-image` holding an * encoded tile. This returns an inline `` instead, so the tile comes off the * same builder as the map's. A patterned map whose legend shows flat colour is * telling the reader the pattern means nothing. * * The tile is shown at whatever scale fits two repeats across, not at its size on * the map. Correct spacing on a map is spacing that leaves the colour dominant, and * a 10px tile in a 14px swatch is one dot and a crop: the reader cannot tell dots * from squares, which is the one thing the swatch is for. Two repeats is the * smallest count that reads as a repeat. */ export declare function patternSwatch(pattern: ResolvedPattern, size?: number): SVGSVGElement; /** * `` for one renderer: builds paints on demand, shares identical ones, * rescales texture with the camera, and drops what a redraw stopped asking for. */ export declare class PaintRegistry { private readonly defs; private readonly uid; /** Resolved spec -> the def serving it, so identical paints share one element. */ private readonly byKey; private seq; /** Camera scale last written, so an unchanged camera writes nothing. */ private scale; constructor(defs: SVGDefsElement); /** * The `fill` value for a paint, creating the def if it is new. * * Returns null when the paint cannot be honoured (an image fill on a feature * that projects to nothing), which the caller reads as "use the flat colour". * * @param seen Keys touched this pass, for {@link pruneSeries}. */ resolve(paint: FeaturePaint, { seriesId, bounds, seen, }: { seriesId: string; bounds?: WorldBounds | null; seen?: Set; }): string | null; /** * A one-tile pattern pinned to the feature's projected box. * * A pattern rather than a `` plus ``: the clip route needs an * extra element per feature *and* a second copy of the geometry, while this * keeps the feature a single path whose `fill` happens to be a picture. Hover, * selection, hit-testing and the export all keep working with no special case. */ private buildImage; /** Hold texture at its authored screen size for a new camera scale. */ applyScale(k: number): void; /** Drop this series' paints that the pass just finished did not ask for. */ pruneSeries(seriesId: string, seen: Set): void; clearSeries(seriesId: string): void; clear(): void; } //# sourceMappingURL=Paint.d.ts.map