import type { GetClientRectConfig, NodeConfig } from './Node.ts'; import { Node } from './Node.ts'; import type { Context } from './Context.ts'; import type { GetSet, Vector2d, IRect } from './types.ts'; import type { HitCanvas, SceneCanvas } from './Canvas.ts'; export type ShapeConfigHandler = { bivarianceHack(ctx: Context, shape: TTarget): void; }['bivarianceHack']; export type LineJoin = 'round' | 'bevel' | 'miter'; export type LineCap = 'butt' | 'round' | 'square'; export type ShapeConfig = NodeConfig & { fill?: string | CanvasGradient; fillPatternImage?: HTMLImageElement; fillPatternX?: number; fillPatternY?: number; fillPatternOffset?: Vector2d; fillPatternOffsetX?: number; fillPatternOffsetY?: number; fillPatternScale?: Vector2d; fillPatternScaleX?: number; fillPatternScaleY?: number; fillPatternRotation?: number; fillPatternRepeat?: string; fillLinearGradientStartPoint?: Vector2d; fillLinearGradientStartPointX?: number; fillLinearGradientStartPointY?: number; fillLinearGradientEndPoint?: Vector2d; fillLinearGradientEndPointX?: number; fillLinearGradientEndPointY?: number; fillLinearGradientColorStops?: Array; strokeLinearGradientStartPoint?: Vector2d; strokeLinearGradientStartPointX?: number; strokeLinearGradientStartPointY?: number; strokeLinearGradientEndPoint?: Vector2d; strokeLinearGradientEndPointX?: number; strokeLinearGradientEndPointY?: number; strokeLinearGradientColorStops?: Array; fillRadialGradientStartPoint?: Vector2d; fillRadialGradientStartPointX?: number; fillRadialGradientStartPointY?: number; fillRadialGradientEndPoint?: Vector2d; fillRadialGradientEndPointX?: number; fillRadialGradientEndPointY?: number; fillRadialGradientStartRadius?: number; fillRadialGradientEndRadius?: number; fillRadialGradientColorStops?: Array; fillEnabled?: boolean; fillPriority?: string; fillRule?: CanvasFillRule; stroke?: string | CanvasGradient; strokeWidth?: number; fillAfterStrokeEnabled?: boolean; hitStrokeWidth?: number | string; strokeScaleEnabled?: boolean; strokeHitEnabled?: boolean; strokeEnabled?: boolean; lineJoin?: LineJoin; lineCap?: LineCap; miterLimit?: number; sceneFunc?: (con: Context, shape: Shape) => void; hitFunc?: (con: Context, shape: Shape) => void; selfRectFunc?: (shape: Shape) => IRect; shadowColor?: string; shadowBlur?: number; shadowOffset?: Vector2d; shadowOffsetX?: number; shadowOffsetY?: number; shadowOpacity?: number; shadowEnabled?: boolean; shadowForStrokeEnabled?: boolean; dash?: number[]; dashOffset?: number; dashEnabled?: boolean; perfectDrawEnabled?: boolean; }; export type ShapeGetClientRectConfig = GetClientRectConfig; export type FillFuncOutput = void | [Path2D | CanvasFillRule] | [Path2D, CanvasFillRule]; export declare const shapes: { [key: string]: Shape; }; /** * Shape constructor. Shapes are primitive objects such as rectangles, * circles, text, lines, etc. * @constructor * @memberof Konva * @augments Konva.Node * @param {Object} config * @@shapeParams * @@nodeParams * @example * var customShape = new Konva.Shape({ * x: 5, * y: 10, * fill: 'red', * // a Konva.Canvas renderer is passed into the sceneFunc function * sceneFunc (context, shape) { * context.beginPath(); * context.moveTo(200, 50); * context.lineTo(420, 80); * context.quadraticCurveTo(300, 100, 260, 170); * context.closePath(); * // Konva specific method * context.fillStrokeShape(shape); * } *}); */ export declare class Shape extends Node { _centroid: boolean; colorKey: string; _fillFunc: (ctx: Context) => FillFuncOutput; _strokeFunc: (ctx: Context) => void; _fillFuncHit: (ctx: Context) => void; _strokeFuncHit: (ctx: Context) => void; constructor(config?: Config); /** * @deprecated */ getContext(): Context; /** * @deprecated */ getCanvas(): SceneCanvas; getSceneFunc(): any; getHitFunc(): any; /** * returns whether or not a shadow will be rendered * @method * @name Konva.Shape#hasShadow * @returns {Boolean} */ hasShadow(): any; _hasShadow(): boolean; _getFillPattern(): any; __getFillPattern(): CanvasPattern | null | undefined; _getLinearGradient(): any; __getLinearGradient(): CanvasGradient | undefined; _getRadialGradient(): any; __getRadialGradient(): CanvasGradient | undefined; getShadowRGBA(): any; _getShadowRGBA(): string | undefined; /** * returns whether or not the shape will be filled * @method * @name Konva.Shape#hasFill * @returns {Boolean} */ hasFill(): any; _hasFill(): boolean; /** * returns whether or not the shape will be stroked * @method * @name Konva.Shape#hasStroke * @returns {Boolean} */ hasStroke(): any; _hasStroke(): boolean; hasHitStroke(): any; /** * determines if point is in the shape, regardless if other shapes are on top of it. Note: because * this method clears a temporary canvas and then redraws the shape, it performs very poorly if executed many times * consecutively. Please use the {@link Konva.Stage#getIntersection} method if at all possible * because it performs much better. A shape that is invisible, not listening or not on a stage * never intersects * @method * @name Konva.Shape#intersects * @param {Object} point * @param {Number} point.x * @param {Number} point.y * @returns {Boolean} */ intersects(point: Vector2d): boolean; destroy(): this; _useBufferCanvas(forceFill?: boolean, opacity?: any): boolean; setStrokeHitEnabled(val: number): void; getStrokeHitEnabled(): boolean; /** * return self rectangle (x, y, width, height) of shape. * This method are not taken into account transformation and styles. * @method * @name Konva.Shape#getSelfRect * @returns {Object} rect with {x, y, width, height} properties * @example * * rect.getSelfRect(); // return {x:0, y:0, width:rect.width(), height:rect.height()} * circle.getSelfRect(); // return {x: - circle.width() / 2, y: - circle.height() / 2, width:circle.width(), height:circle.height()} * */ getSelfRect(): IRect; _getSelfRectForDrawing(): IRect; getClientRect(config?: ShapeGetClientRectConfig): IRect; _getStrokePadding(miterLimit?: number): number; drawScene(can?: SceneCanvas, top?: Node): this; drawHit(can?: HitCanvas, top?: Node): this; /** * draw hit graph using the cached scene canvas * @method * @name Konva.Shape#drawHitFromCache * @param {Integer} alphaThreshold alpha channel threshold that determines whether or not * a pixel should be drawn onto the hit graph. Must be a value between 0 and 255. * The default is 0 * @returns {Konva.Shape} * @example * shape.cache(); * shape.drawHitFromCache(); */ drawHitFromCache(alphaThreshold?: number): this; hasPointerCapture(pointerId: number): boolean; setPointerCapture(pointerId: number): void; releaseCapture(pointerId: number): void; draggable: GetSet; embossBlend: GetSet; dash: GetSet; dashEnabled: GetSet; dashOffset: GetSet; fill: GetSet; fillEnabled: GetSet; fillLinearGradientColorStops: GetSet, this>; fillLinearGradientStartPoint: GetSet; fillLinearGradientStartPointX: GetSet; fillLinearGradientStartPointY: GetSet; fillLinearGradientEndPoint: GetSet; fillLinearGradientEndPointX: GetSet; fillLinearGradientEndPointY: GetSet; fillPatternImage: GetSet; fillRadialGradientStartRadius: GetSet; fillRadialGradientEndRadius: GetSet; fillRadialGradientColorStops: GetSet, this>; fillRadialGradientStartPoint: GetSet; fillRadialGradientStartPointX: GetSet; fillRadialGradientStartPointY: GetSet; fillRadialGradientEndPoint: GetSet; fillRadialGradientEndPointX: GetSet; fillRadialGradientEndPointY: GetSet; fillPatternOffset: GetSet; fillPatternOffsetX: GetSet; fillPatternOffsetY: GetSet; fillPatternRepeat: GetSet; fillPatternRotation: GetSet; fillPatternScale: GetSet; fillPatternScaleX: GetSet; fillPatternScaleY: GetSet; fillPatternX: GetSet; fillPatternY: GetSet; fillPriority: GetSet; hitFunc: GetSet, this>; lineCap: GetSet; lineJoin: GetSet; miterLimit: GetSet; perfectDrawEnabled: GetSet; sceneFunc: GetSet, this>; selfRectFunc: GetSet<((shape: Shape) => IRect) | undefined, this>; shadowColor: GetSet; shadowEnabled: GetSet; shadowForStrokeEnabled: GetSet; shadowOffset: GetSet; shadowOffsetX: GetSet; shadowOffsetY: GetSet; shadowOpacity: GetSet; shadowBlur: GetSet; stroke: GetSet; strokeEnabled: GetSet; fillAfterStrokeEnabled: GetSet; strokeScaleEnabled: GetSet; strokeHitEnabled: GetSet; strokeWidth: GetSet; hitStrokeWidth: GetSet; strokeLinearGradientStartPoint: GetSet; strokeLinearGradientEndPoint: GetSet; strokeLinearGradientColorStops: GetSet, this>; strokeLinearGradientStartPointX: GetSet; strokeLinearGradientStartPointY: GetSet; strokeLinearGradientEndPointX: GetSet; strokeLinearGradientEndPointY: GetSet; fillRule: GetSet; }