regl-scatterplot
Version:
A WebGL-Powered Scalable Interactive Scatter Plot Library
127 lines (126 loc) • 7.33 kB
TypeScript
/**
* Check if all GL extensions are supported and enabled and warn otherwise
* @param {import('regl').Regl} regl Regl instance to be tested
* @param {boolean} silent If `true` the function will not print `console.warn` statements
* @return {boolean} If `true` all required GL extensions are supported
*/
declare function checkReglExtensions(regl: import("regl").Regl, silent: boolean): boolean;
/**
* Create a new Regl instance with `GL_EXTENSIONS` enables
* @param {HTMLCanvasElement} canvas Canvas element to be rendered on
* @return {import('regl').Regl} New Regl instance
*/
export function createRegl(canvas: HTMLCanvasElement): import("regl").Regl;
export function createRenderer(options?: Partial<import("./types").RendererOptions>): {
/**
* Get the associated canvas element
* @return {HTMLCanvasElement} The associated canvas element
*/
readonly canvas: HTMLCanvasElement;
/**
* Get the associated Regl instance
* @return {import('regl').Regl} The associated Regl instance
*/
readonly regl: import("regl").Regl;
/**
* Get the gamma value
* @return {number} The gamma value
*/
gamma: number;
/**
* Get whether the browser supports all necessary WebGL features
* @return {boolean} If `true` the browser supports all necessary WebGL features
*/
readonly isSupported: boolean;
/**
* Get whether the renderer (and its Regl instance) is destroyed
* @return {boolean} If `true` the renderer is destroyed
*/
readonly isDestroyed: boolean;
render: (draw: () => any, targetCanvas: HTMLCanvasElement) => void;
resize: (customWidth: number, customHeight: number) => void;
onFrame: (draw: () => any) => () => void;
refresh: () => void;
destroy: () => void;
};
/**
* Create spatial index from points.
*
* @description
* The spatial index can be used with `scatterplot.draw(points, { spatialIndex })`
* to drastically speed up the draw call.
*
* @param {import('./types').Points} points - The points for which to create the spatial index.
* @param {boolean=} useWorker - Whether to create the spatial index in a worker thread or not. If `undefined`, the spatial index will be created in a worker if `points` contains more than one million entries.
* @return {Promise<ArrayBuffer>} Spatial index
*/
export function createSpatialIndex(points: import("./types").Points, useWorker?: boolean | undefined): Promise<ArrayBuffer>;
/**
* @deprecated Please use `scatterplot.createTextureFromUrl(url)`
*
* Create a Regl texture from an URL.
* @param {import('regl').Regl} regl Regl instance used for creating the texture.
* @param {string} url Source URL of the image.
* @return {Promise<import('regl').Texture2D>} Promise resolving to the texture object.
*/
export function createTextureFromUrl(regl: import("regl").Regl, url: string, timeout?: number): Promise<import("regl").Texture2D>;
declare function createScatterplot(initialProperties?: Partial<import("./types").Properties>): {
/**
* Get whether the browser supports all necessary WebGL features
* @return {boolean} If `true` the browser supports all necessary WebGL features
*/
readonly isSupported: boolean;
clear: () => Promise<void>;
clearPoints: () => Promise<void>;
clearPointConnections: () => Promise<void>;
clearAnnotations: () => Promise<void>;
createTextureFromUrl: (url: string, timeout?: number) => Promise<import("regl").Texture2D>;
deselect: ({ preventEvent }?: {
preventEvent?: boolean;
}) => void;
destroy: () => void;
draw: (newPoints: import("./types").Points, options?: import("./types").ScatterplotMethodOptions["draw"]) => Promise<void>;
drawAnnotations: (newAnnotations: import("./types").Annotation[]) => Promise<void>;
filter: (pointIdxs: number | number[], { preventEvent }?: import("./types").ScatterplotMethodOptions["filter"]) => Promise<any>;
get: <Key extends keyof import("./types").Properties>(property: Key) => import("./types").Properties[Key];
getScreenPosition: (pointIdx: number) => [number, number] | undefined;
hover: (point: number, { showReticleOnce, preventEvent }?: import("./types").ScatterplotMethodOptions["hover"]) => void;
redraw: () => void;
refresh: () => void;
reset: (args_0?: Partial<{
preventEvent: boolean;
}>) => Promise<void>;
select: (pointIdxs: number | number[], { merge, remove, preventEvent }?: import("./types").ScatterplotMethodOptions["select"]) => void;
set: (properties: Partial<import("./types").Settable>) => Promise<void>;
export: {
/**
* Export view as `ImageData` using the current render settings
* @overload
* @param {undefined} options
* @return {ImageData}
*/
(options: undefined): ImageData;
/**
* Export view as `ImageData` using custom render settings
* @overload
* @param {import('./types').ScatterplotMethodOptions['export']} options
* @return {Promise<ImageData>}
*/
(options: import("./types").ScatterplotMethodOptions["export"]): Promise<ImageData>;
};
subscribe: <Key extends "view" | "select" | "focus" | "destroy" | "points" | "lassoEnd" | "deselect" | "init" | "backgroundImageReady" | "unfilter" | "lassoStart" | "transitionStart" | "pointConnectionsDraw" | "lassoExtend" | "pointOver" | "pointOut" | "transitionEnd" | "draw" | "drawing">(event: Key, handler: import("pub-sub-es").Handler<import("./types").Events[Key]>, times?: number) => {
event: Key;
handler: import("pub-sub-es").Handler<import("./types").Events[Key]>;
};
unfilter: ({ preventEvent }?: import("./types").ScatterplotMethodOptions["filter"]) => Promise<any>;
unsubscribe: {
<Key extends "view" | "select" | "focus" | "destroy" | "points" | "lassoEnd" | "deselect" | "init" | "backgroundImageReady" | "unfilter" | "lassoStart" | "transitionStart" | "pointConnectionsDraw" | "lassoExtend" | "pointOver" | "pointOut" | "transitionEnd" | "draw" | "drawing">(subscription: import("pub-sub-es").Subscription<import("./types").Events, Key>): void;
<Key_1 extends "view" | "select" | "focus" | "destroy" | "points" | "lassoEnd" | "deselect" | "init" | "backgroundImageReady" | "unfilter" | "lassoStart" | "transitionStart" | "pointConnectionsDraw" | "lassoExtend" | "pointOver" | "pointOut" | "transitionEnd" | "draw" | "drawing">(event: Key_1, handler: import("pub-sub-es").Handler<import("./types").Events[Key_1]>): void;
};
view: (cameraView: number[], { preventEvent }?: import("./types").ScatterplotMethodOptions["preventEvent"]) => void;
zoomToLocation: (target: number[], distance: number, options?: import("./types").ScatterplotMethodOptions["zoomToLocation"]) => Promise<void>;
zoomToArea: (rect: import("./types").Rect, options?: import("./types").ScatterplotMethodOptions["zoomToArea"]) => Promise<void>;
zoomToPoints: (pointIdxs: number[], options?: import("./types").ScatterplotMethodOptions["zoomToPoints"]) => Promise<void>;
zoomToOrigin: (options?: import("./types").ScatterplotMethodOptions["zoomToLocation"]) => Promise<void>;
};
export { checkReglExtensions as checkSupport, createScatterplot as default };