You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
3.2 KiB

1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /**
  2. * Note: typedefs are auto-exported, so use a made-up `canvas` namespace where
  3. * necessary to avoid duplicates with `export * from './helpers`; see
  4. * https://github.com/microsoft/TypeScript/issues/46011
  5. * @typedef { import('../core/core.controller.js').default } canvas.Chart
  6. * @typedef { import('../types/index.js').Point } Point
  7. */
  8. /**
  9. * @namespace Chart.helpers.canvas
  10. */
  11. /**
  12. * Converts the given font object into a CSS font string.
  13. * @param {object} font - A font object.
  14. * @return {string|null} The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font
  15. * @private
  16. */
  17. export function toFontString(font: object): string | null;
  18. /**
  19. * @private
  20. */
  21. export function _measureText(ctx: any, data: any, gc: any, longest: any, string: any): any;
  22. /**
  23. * @private
  24. */
  25. export function _longestText(ctx: any, font: any, arrayOfThings: any, cache: any): number;
  26. /**
  27. * Returns the aligned pixel value to avoid anti-aliasing blur
  28. * @param {canvas.Chart} chart - The chart instance.
  29. * @param {number} pixel - A pixel value.
  30. * @param {number} width - The width of the element.
  31. * @returns {number} The aligned pixel value.
  32. * @private
  33. */
  34. export function _alignPixel(chart: canvas.Chart, pixel: number, width: number): number;
  35. /**
  36. * Clears the entire canvas.
  37. * @param {HTMLCanvasElement} canvas
  38. * @param {CanvasRenderingContext2D} [ctx]
  39. */
  40. export function clearCanvas(canvas: HTMLCanvasElement, ctx?: CanvasRenderingContext2D): void;
  41. export function drawPoint(ctx: any, options: any, x: any, y: any): void;
  42. export function drawPointLegend(ctx: any, options: any, x: any, y: any, w: any): void;
  43. /**
  44. * Returns true if the point is inside the rectangle
  45. * @param {Point} point - The point to test
  46. * @param {object} area - The rectangle
  47. * @param {number} [margin] - allowed margin
  48. * @returns {boolean}
  49. * @private
  50. */
  51. export function _isPointInArea(point: Point, area: object, margin?: number): boolean;
  52. export function clipArea(ctx: any, area: any): void;
  53. export function unclipArea(ctx: any): void;
  54. /**
  55. * @private
  56. */
  57. export function _steppedLineTo(ctx: any, previous: any, target: any, flip: any, mode: any): any;
  58. /**
  59. * @private
  60. */
  61. export function _bezierCurveTo(ctx: any, previous: any, target: any, flip: any): any;
  62. /**
  63. * Render text onto the canvas
  64. */
  65. export function renderText(ctx: any, text: any, x: any, y: any, font: any, opts?: {}): void;
  66. /**
  67. * Add a path of a rectangle with rounded corners to the current sub-path
  68. * @param {CanvasRenderingContext2D} ctx Context
  69. * @param {*} rect Bounding rect
  70. */
  71. export function addRoundedRectPath(ctx: CanvasRenderingContext2D, rect: any): void;
  72. export namespace canvas {
  73. /**
  74. * Note: typedefs are auto-exported, so use a made-up `canvas` namespace where
  75. * necessary to avoid duplicates with `export * from './helpers`; see
  76. * https://github.com/microsoft/TypeScript/issues/46011
  77. */
  78. type Chart = import('../core/core.controller.js').default;
  79. }
  80. /**
  81. * Note: typedefs are auto-exported, so use a made-up `canvas` namespace where
  82. * necessary to avoid duplicates with `export * from './helpers`; see
  83. * https://github.com/microsoft/TypeScript/issues/46011
  84. */
  85. export type Point = import('../types/index.js').Point;