s2maps-gpu
Version:
S2 Maps GPU - An open source, high-performance, and GPU-accelerated map engine for rendering large-scale, interactive maps.
55 lines (54 loc) • 2.58 kB
TypeScript
import type { MapGlyphSource } from '../imageStore.js';
import type { GlyphPath, GlyphPoint } from './glyph.spec.js';
/**
* Quads
* - BOX: [s, t, xOffset, yOffset, xPos, yPos, width, height, texX, texY, texWidth, texHeight]
* - CIRCLE: [s, t, xOffset, yOffset, path1X, path1Y, path2X, path2Y, path3X, path3Y, path4X, path4Y, distance, texX, texY, texWidth, texHeight]
*
* the xPos and yPos are for the 0->1 ratio placement. This is computed internally with size
* meanwhile xOffset and yOffset are where to start from the s, t position (the pixel based offset)
*/
export type Quad = number[];
/**
* BOX: [s, t, anchorOffsetX, anchorOffsetY, offsetX, offsetY, paddingX, paddingY, maxWidth, maxHeight, index, id]
* CIRCLE: [s, t, anchorOffsetX, anchorOffsetY, offsetX, offsetY, paddingX, paddingY, maxWidth, maxHeight, index, id]
*/
export type Filter = number[];
/** Row: [rowCount, rowWidth, rowHeight] */
export type Row = [rowCount: number, rowWidth: number, rowHeight: number];
export declare const QUAD_SIZE_TEXT = 12;
export declare const QUAD_SIZE_PATH = 20;
export declare const NULL_GLYPH: {
code: string;
texX: number;
texY: number;
texW: number;
texH: number;
xOffset: number;
yOffset: number;
width: number;
height: number;
advanceWidth: number;
};
/**
* This step exclusively creates quad data, E.G. How to draw each glyph on the screen,
* given the anchor point as a basis for drawing. This step is seperate to preprocessing
* as we are avoiding doing too much work prior to potentially filtering the object (rtree).
* NOTE: EVERY GLYPH is currently "normalized", with a 0->1 scale so it can later be
* multiplied by "size"
* NOTE: Just put the glyph offsets + word-wrap-y offset provided at first,
* add in the excess anchor offset AFTER we know the bbox size
* TODO: https://blog.mapbox.com/beautifying-map-labels-with-better-line-breaking-2a6ce3ed432
* @param feature - input glyph point feature
* @param glyphSource - glyph source to pull glyph metadata from
* @param tileSize - tile size/extent
*/
export declare function buildGlyphPointQuads(feature: GlyphPoint, glyphSource: MapGlyphSource, tileSize: number): void;
/**
* Build glyph path quads
* IDEATION: https://blog.mapbox.com/map-label-placement-in-mapbox-gl-c6f843a7caaa
* @param feature - glyph lines feature
* @param glyphSource - glyph source to pull glyph metadata from
* @param tileSize - tile size/extent
*/
export declare function buildGlyphPathQuads(feature: GlyphPath, glyphSource: MapGlyphSource, tileSize: number): void;