types fixes

This commit is contained in:
Anton Lavrenov 2018-02-27 08:55:54 +08:00
parent 4348e6971d
commit 1bbc433262

495
konva.d.ts vendored
View File

@ -1,5 +1,4 @@
declare module Konva { declare namespace Konva {
var pixelRatio: number; var pixelRatio: number;
var dragDistance: number; var dragDistance: number;
var isDragging: () => boolean; var isDragging: () => boolean;
@ -30,8 +29,7 @@ declare module Konva {
static StrongEaseOut(): any; static StrongEaseOut(): any;
} }
class Filter { class Filter {}
}
export class Filters { export class Filters {
static Blur(imageData: any): Filter; static Blur(imageData: any): Filter;
@ -104,10 +102,10 @@ declare module Konva {
interface CacheConfig extends SizeConfig { interface CacheConfig extends SizeConfig {
drawBorder?: boolean; drawBorder?: boolean;
pixelRatio?: number;
} }
interface ClearConfig extends SizeConfig { interface ClearConfig extends SizeConfig {}
}
class Node { class Node {
constructor(config: NodeConfig); constructor(config: NodeConfig);
@ -115,39 +113,47 @@ declare module Konva {
addName(name: string): Node; addName(name: string): Node;
blue(): number; blue(): number;
blue(blue: number): Node; blue(blue: number): this;
brightness(): number; brightness(): number;
brightness(brightness: number): Node; brightness(brightness: number): this;
contrast(): number; contrast(): number;
contrast(contrast: number): Node; contrast(contrast: number): this;
blurRadius(): number; blurRadius(): number;
blurRadius(radius: number): Node; blurRadius(radius: number): this;
cache(config?: CacheConfig): Node; cache(config?: CacheConfig): this;
clearCache(): Node; clearCache(): this;
clear(bounds?: ClearConfig): Node; clear(bounds?: ClearConfig): this;
clone(attrs?: NodeConfig): Node; clone(attrs?: NodeConfig): this;
destroy(): void; destroy(): void;
dragBoundFunc(): (pos: Vector2d) => Vector2d; dragBoundFunc(): (pos: Vector2d) => Vector2d;
dragBoundFunc(dragBoundFunc: (pos: Vector2d) => Vector2d): Node; dragBoundFunc(dragBoundFunc: (pos: Vector2d) => Vector2d): this;
draggable(): boolean; draggable(): boolean;
draggable(draggable: boolean): Node; draggable(draggable: boolean): this;
draw(): Node; draw(): this;
embossBlend(): boolean; embossBlend(): boolean;
embossBlend(embossBlend: boolean): Node; embossBlend(embossBlend: boolean): this;
embossDirection(): string; embossDirection(): string;
embossDirection(embossDirection: string): Node; embossDirection(embossDirection: string): this;
embossStrength(): number; embossStrength(): number;
embossStrength(level: number): Node; embossStrength(level: number): this;
embossWhiteLevel(): number; embossWhiteLevel(): number;
embossWhiteLevel(embossWhiteLevel: number): Node; embossWhiteLevel(embossWhiteLevel: number): this;
enhance(): number; enhance(): number;
enhance(enhance: number): Node; enhance(enhance: number): this;
filters(): Filter[]; filters(): Filter[];
filters(filters: Filter): Node; filters(filters: Filter): this;
findAncestor(selector?: string, includeSelf?: boolean, stopNode?: Node): Node; findAncestor(
findAncestors(selector?: string, includeSelf?: boolean, stopNode?: Node): Node[]; selector?: string,
fire(eventType: string, evt?: any, bubble?: boolean): Node; includeSelf?: boolean,
stopNode?: Node
): this;
findAncestors(
selector?: string,
includeSelf?: boolean,
stopNode?: Node
): Node[];
fire(eventType: string, evt?: any, bubble?: boolean): this;
getAbsoluteOpacity(): number; getAbsoluteOpacity(): number;
getAbsolutePosition(): Vector2d; getAbsolutePosition(): Vector2d;
getAbsoluteTransform(): Transform; getAbsoluteTransform(): Transform;
@ -177,104 +183,102 @@ declare module Konva {
getWidth(): number; getWidth(): number;
getZIndex(): number; getZIndex(): number;
green(): number; green(): number;
green(green: number): Node; green(green: number): this;
hasName(name: string): boolean; hasName(name: string): boolean;
height(): number; height(): number;
height(height: number): Node; height(height: number): this;
hide(): void; hide(): void;
hue(): number; hue(): number;
hue(hue: number): Node; hue(hue: number): this;
id(): string; id(): string;
id(id: string): Node; id(id: string): this;
isDragging(): boolean; isDragging(): boolean;
isListening(): boolean; isListening(): boolean;
isVisible(): boolean; isVisible(): boolean;
kaleidoscopeAngle(): number; kaleidoscopeAngle(): number;
kaleidoscopeAngle(kaleidoscopeAngle: number): Node; kaleidoscopeAngle(kaleidoscopeAngle: number): this;
kaleidoscopePower(): number; kaleidoscopePower(): number;
kaleidoscopePower(kaleidoscopePower: number): Node; kaleidoscopePower(kaleidoscopePower: number): this;
levels(): number; levels(): number;
levels(levels: number): Node; levels(levels: number): this;
listening(): any; listening(): any;
listening(listening: boolean): Node; listening(listening: boolean): this;
listening(listening: string): Node; listening(listening: string): this;
move(move: Vector2d): Node; move(move: Vector2d): this;
moveDown(): boolean; moveDown(): boolean;
moveTo(newContainer: Container): Node; moveTo(newContainer: Container): this;
moveToBottom(): boolean; moveToBottom(): boolean;
moveToTop(): boolean; moveToTop(): boolean;
moveUp(): boolean; moveUp(): boolean;
name(): string; name(): string;
name(name: string): Node; name(name: string): this;
noise(): number; noise(): number;
noise(noise: number): Node; noise(noise: number): this;
off(evtStr: string): Node; off(evtStr: string): this;
offset(): Vector2d; offset(): Vector2d;
offset(offset: Vector2d): Node; offset(offset: Vector2d): this;
offsetX(): number; offsetX(): number;
offsetX(offsetX: number): Node; offsetX(offsetX: number): this;
offsetY(): number; offsetY(): number;
offsetY(offsetY: number): Node; offsetY(offsetY: number): this;
on(evtStr: string, handler: Function): Node; on(evtStr: string, handler: Function): this;
opacity(): number; opacity(): number;
opacity(opacity: number): Node; opacity(opacity: number): this;
pixelSize(): number; pixelSize(): number;
pixelSize(pixelSize: number): Node; pixelSize(pixelSize: number): this;
position(): Vector2d; position(): Vector2d;
position(position: Vector2d): Node; position(position: Vector2d): this;
preventDefault(): boolean;
preventDefault(preventDefault: boolean): Node;
red(): number; red(): number;
red(red: number): Node; red(red: number): this;
remove(): Node; remove(): this;
removeName(name: string): Node; removeName(name: string): this;
rotate(theta: number): Node; rotate(theta: number): this;
rotation(): number; rotation(): number;
rotation(rotation: number): Node; rotation(rotation: number): this;
saturation(): number; saturation(): number;
saturation(saturation: number): Node; saturation(saturation: number): this;
scale(): Vector2d; scale(): Vector2d;
scale(scale: Vector2d): Node; scale(scale: Vector2d): this;
scaleX(): number; scaleX(): number;
scaleX(scaleX: number): Node; scaleX(scaleX: number): this;
scaleY(): number; scaleY(): number;
scaleY(scaleY: number): Node; scaleY(scaleY: number): this;
setAbsolutePosition(pos: Vector2d): Node; setAbsolutePosition(pos: Vector2d): this;
setAttr(attr: string, val: any): Node; setAttr(attr: string, val: any): this;
setAttrs(attrs: NodeConfig): void; setAttrs(attrs: NodeConfig): void;
setId(id: string): Node; setId(id: string): this;
setSize(size: { width: number; height: number }): Node; setSize(size: { width: number; height: number }): this;
setZIndex(zIndex: number): void; setZIndex(zIndex: number): void;
shouldDrawHit(): boolean; shouldDrawHit(): boolean;
show(): Node; show(): this;
skew(): Vector2d; skew(): Vector2d;
skew(skew: Vector2d): Node; skew(skew: Vector2d): this;
skewX(): number; skewX(): number;
skewX(skewX: number): Node; skewX(skewX: number): this;
skewY(): number; skewY(): number;
skewY(skewY: number): Node; skewY(skewY: number): this;
startDrag(): void; startDrag(): void;
stopDrag(): void; stopDrag(): void;
threshold(): number; threshold(): number;
threshold(threshold: number): Node; threshold(threshold: number): this;
to(params: any): void; to(params: any): void;
toDataURL(config: ToDataURLConfig): string; toDataURL(config: ToDataURLConfig): string;
toImage(config: ToDataURLConfig): HTMLImageElement; toImage(config: ToDataURLConfig): HTMLImageElement;
toJSON(): string; toJSON(): string;
toObject(): any; toObject(): any;
transformsEnabled(): string; transformsEnabled(): string;
transformsEnabled(transformsEnabled: string): Node; transformsEnabled(transformsEnabled: string): this;
value(): number; value(): number;
value(value: number): Node; value(value: number): this;
visible(): any; visible(): any;
visible(visible: boolean): Node; visible(visible: boolean): this;
visible(visible: string): Node; visible(visible: string): this;
width(): number; width(): number;
width(width: number): Node; width(width: number): this;
x(): number; x(): number;
x(x: number): Node; x(x: number): this;
y(): number; y(): number;
y(y: number): Node; y(y: number): this;
} }
interface ContainerConfig extends NodeConfig { interface ContainerConfig extends NodeConfig {
@ -284,24 +288,24 @@ declare module Konva {
class Container extends Node { class Container extends Node {
constructor(params?: ContainerConfig); constructor(params?: ContainerConfig);
add(...children: Node[]): Container; add(...children: Node[]): this;
getChildren(filterfunc?: Function): Collection; getChildren(filterfunc?: Function): Collection;
clip(): SizeConfig; clip(): SizeConfig;
clip(clip: SizeConfig | undefined | null): Container; clip(clip: SizeConfig | undefined | null): this;
clipHeight(): number; clipHeight(): number;
clipHeight(clipHeight: number | undefined | null): Container; clipHeight(clipHeight: number | undefined | null): this;
clipWidth(): number; clipWidth(): number;
clipWidth(clipWidth: number | undefined | null): Container; clipWidth(clipWidth: number | undefined | null): this;
clipX(): number; clipX(): number;
clipX(clipX: number | undefined | null): Container; clipX(clipX: number | undefined | null): this;
clipY(): number; clipY(): number;
clipY(clipY: number | undefined | null): Container; clipY(clipY: number | undefined | null): this;
clipFunc(): (ctx: CanvasRenderingContext2D) => void; clipFunc(): (ctx: CanvasRenderingContext2D) => void;
clipFunc(ctx: CanvasRenderingContext2D | undefined | null): void; clipFunc(ctx: CanvasRenderingContext2D | undefined | null): void;
destroyChildren(): void; destroyChildren(): void;
find(selector?: string): Collection; find(selector?: string): Collection;
findOne<T extends Node>(selector: string): T; findOne<T extends Node>(selector: string): T;
getAllIntersections(pos: Vector2d): Node[]; getAllIntersections(pos: Vector2d): Shape[];
hasChildren(): boolean; hasChildren(): boolean;
removeChildren(): void; removeChildren(): void;
} }
@ -361,107 +365,109 @@ declare module Konva {
class Shape extends Node { class Shape extends Node {
constructor(ShapeConfig: ShapeConfig); constructor(ShapeConfig: ShapeConfig);
preventDefault(): boolean;
preventDefault(preventDefault: boolean): this;
dash(): number[]; dash(): number[];
dash(dash: number[]): Shape; dash(dash: number[]): this;
dashEnabled(): boolean; dashEnabled(): boolean;
dashEnabled(dashEnabled: boolean): Shape; dashEnabled(dashEnabled: boolean): this;
drawHitFromCache(alphaThreshold: number): Shape; drawHitFromCache(alphaThreshold: number): this;
fill(): string; fill(): string;
fill(fill: string): Shape; fill(fill: string): this;
fillEnabled(): boolean; fillEnabled(): boolean;
fillEnabled(fillEnabled: boolean): Shape; fillEnabled(fillEnabled: boolean): this;
fillLinearGradientColorStops(): Array<number | string>; fillLinearGradientColorStops(): Array<number | string>;
fillLinearGradientColorStops(colors: Array<number | string>): Shape; fillLinearGradientColorStops(colors: Array<number | string>): this;
fillLinearGradientStartPoint(): Vector2d; fillLinearGradientStartPoint(): Vector2d;
fillLinearGradientStartPoint(point: Vector2d): Vector2d; fillLinearGradientStartPoint(point: Vector2d): Vector2d;
fillLinearGradientStartPointX(): number; fillLinearGradientStartPointX(): number;
fillLinearGradientStartPointX(x: number): Shape; fillLinearGradientStartPointX(x: number): this;
fillLinearGradientStartPointY(): number; fillLinearGradientStartPointY(): number;
fillLinearGradientStartPointY(y: number): Shape; fillLinearGradientStartPointY(y: number): this;
fillLinearGradientEndPoint(): Vector2d; fillLinearGradientEndPoint(): Vector2d;
fillLinearGradientEndPoint(point: Vector2d): Shape; fillLinearGradientEndPoint(point: Vector2d): this;
fillLinearGradientEndPointX(): number; fillLinearGradientEndPointX(): number;
fillLinearGradientEndPointX(x: number): Shape; fillLinearGradientEndPointX(x: number): this;
fillLinearGradientEndPointY(): number; fillLinearGradientEndPointY(): number;
fillLinearGradientEndPointY(y: number): Shape; fillLinearGradientEndPointY(y: number): this;
fillLinearRadialStartPoint(): Vector2d; fillLinearRadialStartPoint(): Vector2d;
fillLinearRadialStartPoint(point: Vector2d): Shape; fillLinearRadialStartPoint(point: Vector2d): this;
fillLinearRadialStartPointX(): number; fillLinearRadialStartPointX(): number;
fillLinearRadialStartPointX(x: number): Shape; fillLinearRadialStartPointX(x: number): this;
fillLinearRadialStartPointY(): number; fillLinearRadialStartPointY(): number;
fillLinearRadialStartPointY(y: number): Shape; fillLinearRadialStartPointY(y: number): this;
fillLinearRadialEndPoint(): Vector2d; fillLinearRadialEndPoint(): Vector2d;
fillLinearRadialEndPoint(point: Vector2d): Vector2d; fillLinearRadialEndPoint(point: Vector2d): Vector2d;
fillLinearRadialEndPointX(): number; fillLinearRadialEndPointX(): number;
fillLinearRadialEndPointX(x: number): Shape; fillLinearRadialEndPointX(x: number): this;
fillLinearRadialEndPointY(): number; fillLinearRadialEndPointY(): number;
fillLinearRadialEndPointY(y: number): Shape; fillLinearRadialEndPointY(y: number): this;
fillPatternImage(): HTMLImageElement; fillPatternImage(): HTMLImageElement;
fillPatternImage(image: HTMLImageElement): Shape; fillPatternImage(image: HTMLImageElement): this;
fillRadialGradientStartRadius(): number; fillRadialGradientStartRadius(): number;
fillRadialGradientStartRadius(radius: number): Shape; fillRadialGradientStartRadius(radius: number): this;
fillRadialGradientEndRadius(): number; fillRadialGradientEndRadius(): number;
fillRadialGradientEndRadius(radius: number): Shape; fillRadialGradientEndRadius(radius: number): this;
fillRadialGradientColorStops(): Array<number | string>; fillRadialGradientColorStops(): Array<number | string>;
fillRadialGradientColorStops(color: Array<number | string>): Shape; fillRadialGradientColorStops(color: Array<number | string>): this;
fillPatternOffset(): Vector2d; fillPatternOffset(): Vector2d;
fillPatternOffset(offset: Vector2d): Shape; fillPatternOffset(offset: Vector2d): this;
fillPatternOffsetX(): number; fillPatternOffsetX(): number;
fillPatternOffsetX(x: number): Shape; fillPatternOffsetX(x: number): this;
fillPatternOffsetY(): number; fillPatternOffsetY(): number;
fillPatternOffsetY(y: number): Shape; fillPatternOffsetY(y: number): this;
fillPatternRepeat(): string; fillPatternRepeat(): string;
fillPatternRepeat(repeat: string): Shape; fillPatternRepeat(repeat: string): this;
fillPatternRotation(): number; fillPatternRotation(): number;
fillPatternRotation(rotation: number): Shape; fillPatternRotation(rotation: number): this;
fillPatternScale(): Vector2d; fillPatternScale(): Vector2d;
fillPatternScale(scale: Vector2d): Shape; fillPatternScale(scale: Vector2d): this;
fillPatternScaleX(): number; fillPatternScaleX(): number;
fillPatternScaleX(x: number): Shape; fillPatternScaleX(x: number): this;
fillPatternScaleY(): number; fillPatternScaleY(): number;
fillPatternScaleY(y: number): Shape; fillPatternScaleY(y: number): this;
fillPatternX(): number; fillPatternX(): number;
fillPatternX(x: number): number; fillPatternX(x: number): number;
fillPatternY(): number; fillPatternY(): number;
fillPatternY(y: number): Shape; fillPatternY(y: number): this;
fillPriority(): string; fillPriority(): string;
fillPriority(priority: string): Shape; fillPriority(priority: string): this;
hasFill(): boolean; hasFill(): boolean;
hasShadow(): boolean; hasShadow(): boolean;
hasStroke(): boolean; hasStroke(): boolean;
hitFunc(): Function; hitFunc(): Function;
hitFunc(func: Function): Shape; hitFunc(func: Function): this;
intersects(point: Vector2d): boolean; intersects(point: Vector2d): boolean;
lineCap(): string; lineCap(): string;
lineCap(lineCap: string): Shape; lineCap(lineCap: string): this;
lineJoin(): string; lineJoin(): string;
lineJoin(lineJoin: string): Shape; lineJoin(lineJoin: string): this;
sceneFunc(): Function; sceneFunc(): Function;
sceneFunc(func: (con: Context) => {}): Shape; sceneFunc(func: (con: Context) => {}): this;
shadowColor(): string; shadowColor(): string;
shadowColor(shadowColor: string): Shape; shadowColor(shadowColor: string): this;
shadowEnabled(): boolean; shadowEnabled(): boolean;
shadowEnabled(shadowEnabled: boolean): Shape; shadowEnabled(shadowEnabled: boolean): this;
shadowOffset(): Vector2d; shadowOffset(): Vector2d;
shadowOffset(shadowOffset: Vector2d): Shape; shadowOffset(shadowOffset: Vector2d): this;
shadowOffsetX(): number; shadowOffsetX(): number;
shadowOffsetX(shadowOffsetX: number): Shape; shadowOffsetX(shadowOffsetX: number): this;
shadowOffsetY(): number; shadowOffsetY(): number;
shadowOffsetY(shadowOffsetY: number): Shape; shadowOffsetY(shadowOffsetY: number): this;
shadowOpacity(): number; shadowOpacity(): number;
shadowOpacity(shadowOpacity: number): Shape; shadowOpacity(shadowOpacity: number): this;
shadowBlur(): number; shadowBlur(): number;
shadowBlur(blur: number): Shape; shadowBlur(blur: number): this;
stroke(): string; stroke(): string;
stroke(stroke: string): Shape; stroke(stroke: string): this;
strokeEnabled(): boolean; strokeEnabled(): boolean;
strokeEnabled(strokeEnabled: boolean): Shape; strokeEnabled(strokeEnabled: boolean): this;
strokeScaleEnabled(): boolean; strokeScaleEnabled(): boolean;
strokeScaleEnabled(strokeScaleEnabled: boolean): Shape; strokeScaleEnabled(strokeScaleEnabled: boolean): this;
strokeHitEnabled(): boolean; strokeHitEnabled(): boolean;
strokeHitEnabled(strokeHitEnabled: boolean): Shape; strokeHitEnabled(strokeHitEnabled: boolean): this;
strokeWidth(): number; strokeWidth(): number;
strokeWidth(strokeWidth: number): Shape; strokeWidth(strokeWidth: number): this;
} }
interface StageConfig extends ContainerConfig { interface StageConfig extends ContainerConfig {
@ -470,8 +476,8 @@ declare module Konva {
class Stage extends Container { class Stage extends Container {
constructor(StageConfig: StageConfig); constructor(StageConfig: StageConfig);
add(...layers: Layer[]): Stage; add(...layers: Layer[]): this;
add(...layers: FastLayer[]): Stage; add(...layers: FastLayer[]): this;
batchDraw(): void; batchDraw(): void;
container(): HTMLElement; container(): HTMLElement;
destroy(): void; destroy(): void;
@ -492,26 +498,24 @@ declare module Konva {
class FastLayer extends Container { class FastLayer extends Container {
constructor(config?: LayerConfig); constructor(config?: LayerConfig);
drawScene(): void; drawScene(): void;
hitGraphEnabled(val: boolean): FastLayer; hitGraphEnabled(val: boolean): this;
batchDraw(): void; batchDraw(): void;
} }
class Layer extends Container { class Layer extends Container {
constructor(config?: LayerConfig); constructor(config?: LayerConfig);
getIntersection(pos: Vector2d, selector?: string): Shape; getIntersection(pos: Vector2d, selector?: string): Shape;
enableHitGraph(): Layer; enableHitGraph(): this;
disableHitGraph(): Layer; disableHitGraph(): this;
clearBeforeDraw(): boolean; clearBeforeDraw(): boolean;
clearBeforeDraw(val: boolean): Layer; clearBeforeDraw(val: boolean): this;
hitGraphEnabled(): boolean; hitGraphEnabled(): boolean;
hitGraphEnabled(val: boolean): Layer; hitGraphEnabled(val: boolean): this;
batchDraw(): void; batchDraw(): void;
drawScene(): void; drawScene(): void;
} }
class Group extends Container { class Group extends Container {}
}
interface CanvasConfig { interface CanvasConfig {
width: number; width: number;
@ -546,19 +550,80 @@ declare module Konva {
// context pass through methods // context pass through methods
// originally from lib.es6.d.ts // originally from lib.es6.d.ts
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; arc(
x: number,
y: number,
radius: number,
startAngle: number,
endAngle: number,
anticlockwise?: boolean
): void;
beginPath(): void; beginPath(): void;
bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; bezierCurveTo(
cp1x: number,
cp1y: number,
cp2x: number,
cp2y: number,
x: number,
y: number
): void;
clearRect(x: number, y: number, width: number, height: number): void; clearRect(x: number, y: number, width: number, height: number): void;
clip(): void; clip(): void;
closePath(): void; closePath(): void;
createImageData(imageDataOrSw: number | ImageData, sh?: number): ImageData; createImageData(imageDataOrSw: number | ImageData, sh?: number): ImageData;
createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; createLinearGradient(
createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern; x0: number,
createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; y0: number,
drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, dstX: number, dstY: number): void; x1: number,
drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, dstX: number, dstY: number, dstW: number, dstH: number): void; y1: number
drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, srcX: number, srcY: number, srcW: number, srcH: number, dstX: number, dstY: number, dstW: number, dstH: number): void; ): CanvasGradient;
createPattern(
image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement,
repetition: string
): CanvasPattern;
createRadialGradient(
x0: number,
y0: number,
r0: number,
x1: number,
y1: number,
r1: number
): CanvasGradient;
drawImage(
image:
| HTMLImageElement
| HTMLCanvasElement
| HTMLVideoElement
| ImageBitmap,
dstX: number,
dstY: number
): void;
drawImage(
image:
| HTMLImageElement
| HTMLCanvasElement
| HTMLVideoElement
| ImageBitmap,
dstX: number,
dstY: number,
dstW: number,
dstH: number
): void;
drawImage(
image:
| HTMLImageElement
| HTMLCanvasElement
| HTMLVideoElement
| ImageBitmap,
srcX: number,
srcY: number,
srcW: number,
srcH: number,
dstX: number,
dstY: number,
dstW: number,
dstH: number
): void;
isPointInPath(x: number, y: number): boolean; isPointInPath(x: number, y: number): boolean;
fill(): void; fill(): void;
fillRect(x: number, y: number, width: number, height: number): void; fillRect(x: number, y: number, width: number, height: number): void;
@ -577,10 +642,24 @@ declare module Konva {
scale(x: number, y: number): void; scale(x: number, y: number): void;
setLineDash(segments: number[]): void; setLineDash(segments: number[]): void;
getLineDash(): number[]; getLineDash(): number[];
setTransform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; setTransform(
m11: number,
m12: number,
m21: number,
m22: number,
dx: number,
dy: number
): void;
stroke(path?: Path2D): void; stroke(path?: Path2D): void;
strokeText(text: string, x: number, y: number): void; strokeText(text: string, x: number, y: number): void;
transform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; transform(
m11: number,
m12: number,
m21: number,
m22: number,
dx: number,
dy: number
): void;
translate(x: number, y: number): void; translate(x: number, y: number): void;
} }
@ -606,9 +685,9 @@ declare module Konva {
class Ring extends Shape { class Ring extends Shape {
constructor(RingConfig: RingConfig); constructor(RingConfig: RingConfig);
innerRadius(): number; innerRadius(): number;
innerRadius(innerRadius: number): Ring; innerRadius(innerRadius: number): this;
outerRadius(): number; outerRadius(): number;
outerRadius(outerRadius: number): Ring; outerRadius(outerRadius: number): this;
} }
interface ArcConfig extends ShapeConfig { interface ArcConfig extends ShapeConfig {
@ -621,13 +700,13 @@ declare module Konva {
class Arc extends Shape { class Arc extends Shape {
constructor(ArcConfig: ArcConfig); constructor(ArcConfig: ArcConfig);
angle(): number; angle(): number;
angle(angle: number): Ring; angle(angle: number): this;
clockwise(): boolean; clockwise(): boolean;
clockwise(clockwise: boolean): Arc; clockwise(clockwise: boolean): this;
innerRadius(): number; innerRadius(): number;
innerRadius(innerRadius: number): Arc; innerRadius(innerRadius: number): this;
outerRadius(): number; outerRadius(): number;
outerRadius(outerRadius: number): Arc; outerRadius(outerRadius: number): this;
} }
interface CircleConfig extends ShapeConfig { interface CircleConfig extends ShapeConfig {
@ -637,7 +716,7 @@ declare module Konva {
class Circle extends Shape { class Circle extends Shape {
constructor(CircleConfig: CircleConfig); constructor(CircleConfig: CircleConfig);
radius(): number; radius(): number;
radius(radius: number): Circle; radius(radius: number): this;
} }
interface EllipseConfig extends ShapeConfig { interface EllipseConfig extends ShapeConfig {
@ -647,11 +726,11 @@ declare module Konva {
class Ellipse extends Shape { class Ellipse extends Shape {
constructor(EllipseConfig: EllipseConfig); constructor(EllipseConfig: EllipseConfig);
radius(): any; radius(): any;
radius(radius: any): Ellipse; radius(radius: any): this;
radiusX(): number; radiusX(): number;
radiusX(radiusX: number): Ellipse; radiusX(radiusX: number): this;
radiusY(): number; radiusY(): number;
radiusY(radiusY: number): Ellipse; radiusY(radiusY: number): this;
} }
interface ImageConfig extends ShapeConfig { interface ImageConfig extends ShapeConfig {
@ -662,17 +741,17 @@ declare module Konva {
class Image extends Shape { class Image extends Shape {
constructor(ImageConfig: ImageConfig); constructor(ImageConfig: ImageConfig);
image(): HTMLImageElement; image(): HTMLImageElement;
image(image: HTMLImageElement): Image; image(image: HTMLImageElement): this;
crop(): SizeConfig; crop(): SizeConfig;
crop(crop: SizeConfig): Image; crop(crop: SizeConfig): this;
cropX(): number; cropX(): number;
cropX(cropX: number): Image; cropX(cropX: number): this;
cropY(): number; cropY(): number;
cropY(cropY: number): Image; cropY(cropY: number): this;
cropWidth(): number; cropWidth(): number;
cropWidth(cropWidth: number): Image; cropWidth(cropWidth: number): this;
cropHeight(): number; cropHeight(): number;
cropHeight(cropHeight: number): Image; cropHeight(cropHeight: number): this;
} }
interface LineConfig extends ShapeConfig { interface LineConfig extends ShapeConfig {
@ -684,11 +763,11 @@ declare module Konva {
class Line extends Shape { class Line extends Shape {
constructor(LineConfig: LineConfig); constructor(LineConfig: LineConfig);
closed(): boolean; closed(): boolean;
closed(closed: boolean): Line; closed(closed: boolean): this;
tension(): number; tension(): number;
tension(tension: number): Line; tension(tension: number): this;
points(): number[]; points(): number[];
points(points: number[]): Line; points(points: number[]): this;
} }
interface ArrowConfig extends ShapeConfig { interface ArrowConfig extends ShapeConfig {
@ -702,17 +781,17 @@ declare module Konva {
class Arrow extends Shape { class Arrow extends Shape {
constructor(ArrowConfig: ArrowConfig); constructor(ArrowConfig: ArrowConfig);
closed(): boolean; closed(): boolean;
closed(closed: boolean): Arrow; closed(closed: boolean): this;
tension(): number; tension(): number;
tension(tension: number): Arrow; tension(tension: number): this;
points(): number[]; points(): number[];
points(points: number[]): Arrow; points(points: number[]): this;
pointerLength(): Number; pointerLength(): Number;
pointerLength(Length: Number): Number; pointerLength(Length: Number): this;
pointerWidth(): Number; pointerWidth(): Number;
pointerWidth(Width: Number): Number; pointerWidth(Width: Number): this;
pointerAtBeginning(): boolean; pointerAtBeginning(): boolean;
pointerAtBeginning(Should: boolean): void; pointerAtBeginning(Should: boolean): this;
} }
interface RectConfig extends ShapeConfig { interface RectConfig extends ShapeConfig {
@ -722,7 +801,7 @@ declare module Konva {
class Rect extends Shape { class Rect extends Shape {
constructor(RectConfig: RectConfig); constructor(RectConfig: RectConfig);
cornerRadius(): number; cornerRadius(): number;
cornerRadius(cornerRadius: number): Rect; cornerRadius(cornerRadius: number): this;
} }
interface SpriteConfig extends ShapeConfig { interface SpriteConfig extends ShapeConfig {
@ -737,15 +816,15 @@ declare module Konva {
start(): void; start(): void;
stop(): void; stop(): void;
animation(): string; animation(): string;
animation(val: string): Sprite; animation(val: string): this;
animations(): any; animations(): any;
animations(val: any): Sprite; animations(val: any): this;
frameIndex(): number; frameIndex(): number;
frameIndex(val: number): Sprite; frameIndex(val: number): this;
image(): HTMLImageElement; image(): HTMLImageElement;
image(image: HTMLImageElement): Sprite; image(image: HTMLImageElement): this;
frameRate(): number; frameRate(): number;
frameRate(frameRate: number): Sprite; frameRate(frameRate: number): this;
} }
interface TextConfig extends ShapeConfig { interface TextConfig extends ShapeConfig {
@ -764,25 +843,25 @@ declare module Konva {
getTextWidth(): number; getTextWidth(): number;
getTextHeight(): number; getTextHeight(): number;
text(): string; text(): string;
text(text: string): Text; text(text: string): this;
fontFamily(): string; fontFamily(): string;
fontFamily(fontFamily: string): Text; fontFamily(fontFamily: string): this;
fontSize(): number; fontSize(): number;
fontSize(fontSize: number): Text; fontSize(fontSize: number): this;
fontStyle(): string; fontStyle(): string;
fontStyle(fontStyle: string): Text; fontStyle(fontStyle: string): this;
fontVariant(): string; fontVariant(): string;
fontVariant(fontVariant: string): Text; fontVariant(fontVariant: string): this;
align(): string; align(): string;
align(align: string): Text; align(align: string): this;
padding(): number; padding(): number;
padding(padding: number): Text; padding(padding: number): this;
lineHeight(): number; lineHeight(): number;
lineHeight(lineHeight: number): Text; lineHeight(lineHeight: number): this;
wrap(): string; wrap(): string;
wrap(wrap: string): Text; wrap(wrap: string): this;
textDecoration(): string; textDecoration(): string;
textDecoration(textDecoration: string): Text; textDecoration(textDecoration: string): this;
} }
interface WedgeConfig extends ShapeConfig { interface WedgeConfig extends ShapeConfig {
@ -794,11 +873,11 @@ declare module Konva {
class Wedge extends Shape { class Wedge extends Shape {
constructor(WedgeConfig: WedgeConfig); constructor(WedgeConfig: WedgeConfig);
angle(): number; angle(): number;
angle(angle: number): Wedge; angle(angle: number): this;
radius(): number; radius(): number;
radius(radius: number): Wedge; radius(radius: number): this;
clockwise(): boolean; clockwise(): boolean;
clockwise(clockwise: boolean): Wedge; clockwise(clockwise: boolean): this;
} }
// Plugins // Plugins
@ -812,18 +891,16 @@ declare module Konva {
class Tag extends Shape { class Tag extends Shape {
constructor(config: TagConfig); constructor(config: TagConfig);
pointerDirection(): string; pointerDirection(): string;
pointerDirection(pointerDirection: string): Tag; pointerDirection(pointerDirection: string): this;
pointerWidth(): number; pointerWidth(): number;
pointerWidth(pointerWidth: number): Tag; pointerWidth(pointerWidth: number): this;
pointerHeight(): number; pointerHeight(): number;
pointerHeight(pointerHeight: number): Tag; pointerHeight(pointerHeight: number): this;
cornerRadius(): number; cornerRadius(): number;
cornerRadius(cornerRadius: number): Tag; cornerRadius(cornerRadius: number): this;
} }
interface LabelInterface extends ContainerConfig {}
interface LabelInterface extends ContainerConfig {
}
class Label extends Group { class Label extends Group {
constructor(LabelInterface: LabelInterface); constructor(LabelInterface: LabelInterface);
@ -838,7 +915,7 @@ declare module Konva {
class Path extends Shape { class Path extends Shape {
constructor(PathConfig: PathConfig); constructor(PathConfig: PathConfig);
data(): string; data(): string;
data(data: string): Path; data(data: string): this;
} }
interface RegularPolygonConfig extends ShapeConfig { interface RegularPolygonConfig extends ShapeConfig {
@ -849,9 +926,9 @@ declare module Konva {
class RegularPolygon extends Shape { class RegularPolygon extends Shape {
constructor(RegularPolygonConfig: RegularPolygonConfig); constructor(RegularPolygonConfig: RegularPolygonConfig);
sides(): number; sides(): number;
sides(sides: number): RegularPolygon; sides(sides: number): this;
radius(): number; radius(): number;
radius(radius: number): RegularPolygon; radius(radius: number): this;
} }
interface StarConfig extends ShapeConfig { interface StarConfig extends ShapeConfig {
@ -863,11 +940,11 @@ declare module Konva {
class Star extends Shape { class Star extends Shape {
constructor(StarConfig: StarConfig); constructor(StarConfig: StarConfig);
numPoints(): number; numPoints(): number;
numPoints(numPoints: number): Star; numPoints(numPoints: number): this;
innerRadius(): number; innerRadius(): number;
innerRadius(innerRadius: number): Star; innerRadius(innerRadius: number): this;
outerRadius(): number; outerRadius(): number;
outerRadius(outerRadius: number): Star; outerRadius(outerRadius: number): this;
} }
interface TextPathConfig extends ShapeConfig { interface TextPathConfig extends ShapeConfig {
@ -884,16 +961,15 @@ declare module Konva {
getTextHeight(): number; getTextHeight(): number;
setText(text: string): void; setText(text: string): void;
text(): string; text(): string;
text(text: string): Path; text(text: string): this;
fontFamily(): string; fontFamily(): string;
fontFamily(fontFamily: string): Path; fontFamily(fontFamily: string): this;
fontSize(): number; fontSize(): number;
fontSize(fontSize: number): Path; fontSize(fontSize: number): this;
fontStyle(): string; fontStyle(): string;
fontStyle(fontStyle: string): Path; fontStyle(fontStyle: string): this;
} }
class Collection { class Collection {
[i: number]: any; [i: number]: any;
static toCollection(arr: any[]): Collection; static toCollection(arr: any[]): Collection;
@ -916,7 +992,6 @@ declare module Konva {
translate(x: number, y: Number): Transform; translate(x: number, y: Number): Transform;
} }
interface Vector2d { interface Vector2d {
x: number; x: number;
y: number; y: number;