/
helpers.canvas.d.ts
135 lines (109 loc) · 3.16 KB
/
helpers.canvas.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import {PointStyle, Scriptable, ScriptableScaleContext} from '../index.js';
import {Color} from '../color.js';
import {ChartArea, RoundedRect} from '../geometric.js';
import {CanvasFontSpec} from '../../helpers/helpers.options.js';
export function clearCanvas(canvas: HTMLCanvasElement, ctx?: CanvasRenderingContext2D): void;
export function clipArea(ctx: CanvasRenderingContext2D, area: ChartArea): void;
export function unclipArea(ctx: CanvasRenderingContext2D): void;
export interface DrawPointOptions {
pointStyle: PointStyle;
rotation?: number;
radius: number;
borderWidth: number;
}
export function drawPoint(ctx: CanvasRenderingContext2D, options: DrawPointOptions, x: number, y: number): void;
export function drawPointLegend(ctx: CanvasRenderingContext2D, options: DrawPointOptions, x: number, y: number, w: number): void;
/**
* Converts the given font object into a CSS font string.
* @param font a font object
* @return The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font
*/
export function toFontString(font: { size: number; family: string; style?: string; weight?: string }): string | null;
export interface RenderTextOpts {
/**
* The fill color of the text. If unset, the existing
* fillStyle property of the canvas is unchanged.
*/
color?: Color;
/**
* The width of the strikethrough / underline
* @default 2
*/
decorationWidth?: number;
/**
* The max width of the text in pixels
*/
maxWidth?: number;
/**
* A rotation to be applied to the canvas
* This is applied after the translation is applied
*/
rotation?: number;
/**
* Apply a strikethrough effect to the text
*/
strikethrough?: boolean;
/**
* The color of the text stroke. If unset, the existing
* strokeStyle property of the context is unchanged
*/
strokeColor?: Color;
/**
* The text stroke width. If unset, the existing
* lineWidth property of the context is unchanged
*/
strokeWidth?: number;
/**
* The text alignment to use. If unset, the existing
* textAlign property of the context is unchanged
*/
textAlign?: CanvasTextAlign;
/**
* The text baseline to use. If unset, the existing
* textBaseline property of the context is unchanged
*/
textBaseline?: CanvasTextBaseline;
/**
* If specified, a translation to apply to the context
*/
translation?: [number, number];
/**
* Underline the text
*/
underline?: boolean;
/**
* Dimensions for drawing the label backdrop
*/
backdrop?: BackdropOptions;
}
export interface BackdropOptions {
/**
* Left position of backdrop as pixel
*/
left: number;
/**
* Top position of backdrop as pixel
*/
top: number;
/**
* Width of backdrop in pixels
*/
width: number;
/**
* Height of backdrop in pixels
*/
height: number;
/**
* Color of label backdrops.
*/
color: Scriptable<Color, ScriptableScaleContext>;
}
export function renderText(
ctx: CanvasRenderingContext2D,
text: string | string[],
x: number,
y: number,
font: CanvasFontSpec,
opts?: RenderTextOpts
): void;
export function addRoundedRectPath(ctx: CanvasRenderingContext2D, rect: RoundedRect): void;