Debian Codegraph @

vendor/static/chart.js/dist/helpers/helpers.canvas.d.ts

raw
1 import type { Chart, Point, FontSpec, CanvasFontSpec, PointStyle, RenderTextOpts } from '../types/index.js';
2 import type { TRBL, SplinePoint, RoundedRect, TRBLCorners } from '../types/geometric.js';
3 /**
4 * Converts the given font object into a CSS font string.
5 * @param font - A font object.
6 * @return The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font
7 * @private
8 */
9 export declare function toFontString(font: FontSpec): string;
10 /**
11 * @private
12 */
13 export declare function _measureText(ctx: CanvasRenderingContext2D, data: Record<string, number>, gc: string[], longest: number, string: string): number;
14 type Thing = string | undefined | null;
15 type Things = (Thing | Thing[])[];
16 /**
17 * @private
18 */
19 export declare function _longestText(ctx: CanvasRenderingContext2D, font: string, arrayOfThings: Things, cache?: {
20 data?: Record<string, number>;
21 garbageCollect?: string[];
22 font?: string;
23 }): number;
24 /**
25 * Returns the aligned pixel value to avoid anti-aliasing blur
26 * @param chart - The chart instance.
27 * @param pixel - A pixel value.
28 * @param width - The width of the element.
29 * @returns The aligned pixel value.
30 * @private
31 */
32 export declare function _alignPixel(chart: Chart, pixel: number, width: number): number;
33 /**
34 * Clears the entire canvas.
35 */
36 export declare function clearCanvas(canvas?: HTMLCanvasElement, ctx?: CanvasRenderingContext2D): void;
37 export interface DrawPointOptions {
38 pointStyle: PointStyle;
39 rotation?: number;
40 radius: number;
41 borderWidth: number;
42 }
43 export declare function drawPoint(ctx: CanvasRenderingContext2D, options: DrawPointOptions, x: number, y: number): void;
44 export declare function drawPointLegend(ctx: CanvasRenderingContext2D, options: DrawPointOptions, x: number, y: number, w: number): void;
45 /**
46 * Returns true if the point is inside the rectangle
47 * @param point - The point to test
48 * @param area - The rectangle
49 * @param margin - allowed margin
50 * @private
51 */
52 export declare function _isPointInArea(point: Point, area: TRBL, margin?: number): boolean;
53 export declare function clipArea(ctx: CanvasRenderingContext2D, area: TRBL): void;
54 export declare function unclipArea(ctx: CanvasRenderingContext2D): void;
55 /**
56 * @private
57 */
58 export declare function _steppedLineTo(ctx: CanvasRenderingContext2D, previous: Point, target: Point, flip?: boolean, mode?: string): void;
59 /**
60 * @private
61 */
62 export declare function _bezierCurveTo(ctx: CanvasRenderingContext2D, previous: SplinePoint, target: SplinePoint, flip?: boolean): void;
63 /**
64 * Render text onto the canvas
65 */
66 export declare function renderText(ctx: CanvasRenderingContext2D, text: string | string[], x: number, y: number, font: CanvasFontSpec, opts?: RenderTextOpts): void;
67 /**
68 * Add a path of a rectangle with rounded corners to the current sub-path
69 * @param ctx - Context
70 * @param rect - Bounding rect
71 */
72 export declare function addRoundedRectPath(ctx: CanvasRenderingContext2D, rect: RoundedRect & {
73 radius: TRBLCorners;
74 }): void;
75 export {};