UNPKG

ag-charts-community

Version:

Advanced Charting / Charts supporting Javascript / Typescript / React / Angular / Vue

99 lines (98 loc) 4.61 kB
import { type InternalAgGradientColor } from 'ag-charts-core'; import type { AgPatternColor } from 'ag-charts-types'; import type { BBox } from '../bbox'; import type { DropShadow } from '../dropShadow'; import { type ColorSpace, Gradient, type GradientParams } from '../gradient/gradient'; import { Node, type RenderContext } from '../node'; import { Pattern } from '../pattern/pattern'; export type ShapeLineCap = 'butt' | 'round' | 'square'; export type ShapeLineJoin = 'round' | 'bevel' | 'miter'; export type CanvasContext = CanvasFillStrokeStyles & CanvasCompositing & CanvasShadowStyles & CanvasPathDrawingStyles & CanvasDrawPath & CanvasPath & CanvasTransform & CanvasState; export type ShapeGradientColor = Omit<InternalAgGradientColor, 'bounds'> & { colorSpace?: ColorSpace; }; export type ShapeColor = string | ShapeGradientColor | AgPatternColor; export interface DefaultStyles { fill?: ShapeColor; stroke?: ShapeColor; strokeWidth: number; lineDash?: number[]; lineDashOffset: number; lineCap?: ShapeLineCap; lineJoin?: ShapeLineJoin; opacity: number; fillShadow?: DropShadow; } export declare abstract class Shape<D = any> extends Node<D> { /** * Defaults for style properties. Note that properties that affect the position * and shape of the node are not considered style properties, for example: * `x`, `y`, `width`, `height`, `radius`, `rotation`, etc. * Can be used to reset to the original styling after some custom styling * has been applied (using the `restoreOwnStyles` method). * These static defaults are meant to be inherited by subclasses. */ protected static readonly defaultStyles: DefaultStyles; /** * Restores the default styles introduced by this subclass. */ protected restoreOwnStyles(): void; fillOpacity: number; strokeOpacity: number; fill: ShapeColor | undefined; private getGradient; private createGradient; private getPattern; private createPattern; private _cachedFill?; protected onFillChange(): void; protected fillGradient: Gradient | undefined; protected fillPattern: Pattern | undefined; /** * Note that `strokeStyle = null` means invisible stroke, * while `lineWidth = 0` means no stroke, and sometimes this can mean different things. * For example, a rect shape with an invisible stroke may not align to the pixel grid * properly because the stroke affects the rules of alignment, and arc shapes forming * a pie chart will have a gap between them if they have an invisible stroke, whereas * there would be not gap if there was no stroke at all. * The preferred way of making the stroke invisible is setting the `lineWidth` to zero, * unless specific looks that is achieved by having an invisible stroke is desired. */ stroke?: ShapeColor; protected onStrokeChange(): void; protected strokeGradient: Gradient | undefined; strokeWidth: number; /** * Returns a device-pixel aligned coordinate (or length if length is supplied). * * NOTE: Not suitable for strokes, since the stroke needs to be offset to the middle * of a device pixel. */ align(start: number, length?: number): number; lineDash?: number[]; lineDashOffset: number; lineCap?: ShapeLineCap; lineJoin?: ShapeLineJoin; miterLimit?: number; opacity: number; fillShadow: DropShadow | undefined; fillBBox?: BBox; fillParams?: GradientParams; private cachedDefaultGradientFillBBox?; preRender(renderCtx: RenderContext, thisComplexity?: number): import("../node").ChildNodeCounts; protected fillStroke(ctx: CanvasContext, path?: Path2D): void; protected renderFill(ctx: CanvasContext, path?: Path2D): void; protected executeFill(ctx: CanvasContext, path?: Path2D): void; protected applyFill(ctx: CanvasContext): void; protected applyStroke(ctx: CanvasContext): void; protected applyFillAlpha(ctx: CanvasContext): void; protected applyShadow(ctx: CanvasContext): void; protected renderStroke(ctx: CanvasContext, path?: Path2D): void; protected executeStroke(ctx: CanvasContext, path?: Path2D): void; getDefaultGradientFillBBox(): BBox; protected computeDefaultGradientFillBBox(): BBox | undefined; containsPoint(x: number, y: number): boolean; abstract isPointInPath(x: number, y: number): boolean; protected applySvgFillAttributes(element: SVGElement, defs?: SVGElement[]): SVGElement[] | undefined; protected applySvgStrokeAttributes(element: SVGElement): void; }