konva
Version:
<p align="center"> <img src="https://raw.githubusercontent.com/konvajs/konvajs.github.io/master/apple-touch-icon-180x180.png" alt="Konva logo" height="180" /> </p>
263 lines (262 loc) • 7.16 kB
TypeScript
import { Node } from './Node';
export declare type Point = {
x: number;
y: number;
};
export interface RectConf {
x: number;
y: number;
width: number;
height: number;
}
/**
* Collection constructor. Collection extends Array.
* This class is used in conjunction with {@link Konva.Container#find}
* The good thing about collection is that it has ALL methods of all Konva nodes. Take a look into examples.
* @constructor
* @memberof Konva
* @example
*
* // find all rectangles and return them as Collection
* const shapes = layer.find('Rect');
* // fill all rectangles with a single function
* shapes.fill('red');
*/
export declare class Collection<Child extends Node> {
[index: number]: Child;
length: number;
each: (f: Function) => void;
toArray: () => Array<any>;
push: (item: Child) => void;
unshift: (item: Child) => void;
splice: (start: number, length: number, replace?: any) => void;
/**
* convert array into a collection
* @method
* @memberof Konva.Collection
* @param {Array} arr
*/
static toCollection(arr: any): Collection<Node>;
static _mapMethod(methodName: any): void;
static mapMethods: (constructor: any) => void;
}
/**
* Transform constructor.
* In most of the cases you don't need to use it in your app. Because it is for internal usage in Konva core.
* But there is a documentation for that class in case you still want
* to make some manual calculations.
* @constructor
* @param {Array} [m] Optional six-element matrix
* @memberof Konva
*/
export declare class Transform {
m: Array<number>;
constructor(m?: number[]);
/**
* Copy Konva.Transform object
* @method
* @name Konva.Transform#copy
* @returns {Konva.Transform}
* @example
* const tr = shape.getTransform().copy()
*/
copy(): Transform;
/**
* Transform point
* @method
* @name Konva.Transform#point
* @param {Object} point 2D point(x, y)
* @returns {Object} 2D point(x, y)
*/
point(point: any): {
x: number;
y: number;
};
/**
* Apply translation
* @method
* @name Konva.Transform#translate
* @param {Number} x
* @param {Number} y
* @returns {Konva.Transform}
*/
translate(x: any, y: any): this;
/**
* Apply scale
* @method
* @name Konva.Transform#scale
* @param {Number} sx
* @param {Number} sy
* @returns {Konva.Transform}
*/
scale(sx: any, sy: any): this;
/**
* Apply rotation
* @method
* @name Konva.Transform#rotate
* @param {Number} rad Angle in radians
* @returns {Konva.Transform}
*/
rotate(rad: any): this;
/**
* Returns the translation
* @method
* @name Konva.Transform#getTranslation
* @returns {Object} 2D point(x, y)
*/
getTranslation(): {
x: number;
y: number;
};
/**
* Apply skew
* @method
* @name Konva.Transform#skew
* @param {Number} sx
* @param {Number} sy
* @returns {Konva.Transform}
*/
skew(sx: any, sy: any): this;
/**
* Transform multiplication
* @method
* @name Konva.Transform#multiply
* @param {Konva.Transform} matrix
* @returns {Konva.Transform}
*/
multiply(matrix: any): this;
/**
* Invert the matrix
* @method
* @name Konva.Transform#invert
* @returns {Konva.Transform}
*/
invert(): this;
/**
* return matrix
* @method
* @name Konva.Transform#getMatrix
*/
getMatrix(): number[];
/**
* set to absolute position via translation
* @method
* @name Konva.Transform#setAbsolutePosition
* @returns {Konva.Transform}
* @author ericdrowell
*/
setAbsolutePosition(x: any, y: any): this;
}
/**
* @namespace Util
* @memberof Konva
*/
export declare const Util: {
_isElement(obj: any): boolean;
_isFunction(obj: any): boolean;
_isObject(obj: any): boolean;
_isArray(obj: any): boolean;
_isNumber(obj: any): boolean;
_isString(obj: any): boolean;
_isBoolean(obj: any): boolean;
isObject(val: any): boolean;
isValidSelector(selector: any): boolean;
_sign(number: any): 0 | 1 | -1;
createCanvasElement(): any;
createImageElement(): any;
_isInDocument(el: any): boolean;
_simplifyArray(arr: any): any[];
_getImage(arg: any, callback: any): void;
_getRGBAString(obj: any): string;
_rgbToHex(r: any, g: any, b: any): any;
_hexToRgb(hex: any): {
r: number;
g: number;
b: number;
};
/**
* return random hex color
* @method
* @memberof Konva.Util
* @example
* shape.fill(Konva.Util.getRandomColor());
*/
getRandomColor(): string;
get(val: any, def: any): any;
/**
* get RGB components of a color
* @method
* @memberof Konva.Util
* @param {String} color
* @example
* // each of the following examples return {r:0, g:0, b:255}
* var rgb = Konva.Util.getRGB('blue');
* var rgb = Konva.Util.getRGB('#0000ff');
* var rgb = Konva.Util.getRGB('rgb(0,0,255)');
*/
getRGB(color: any): any;
colorToRGBA(str: any): {
r: any;
g: any;
b: any;
a: any;
};
_namedColorToRBA(str: any): {
r: any;
g: any;
b: any;
a: number;
};
_rgbColorToRGBA(str: any): {
r: any;
g: any;
b: any;
a: number;
};
_rgbaColorToRGBA(str: any): {
r: any;
g: any;
b: any;
a: any;
};
_hex6ColorToRGBA(str: any): {
r: number;
g: number;
b: number;
a: number;
};
_hex3ColorToRGBA(str: any): {
r: number;
g: number;
b: number;
a: number;
};
_merge(o1: any, o2: any): any;
/**
* check intersection of two client rectangles
* @method
* @memberof Konva.Util
* @param {Object} r1 - { x, y, width, height } client rectangle
* @param {Object} r2 - { x, y, width, height } client rectangle
* @example
* const overlapping = Konva.Util.haveIntersection(shape1.getClientRect(), shape2.getClientRect());
*/
haveIntersection(r1: any, r2: any): boolean;
cloneObject<Any>(obj: Any): Any;
cloneArray(arr: any): any;
_degToRad(deg: any): number;
_radToDeg(rad: any): number;
_capitalize(str: any): any;
throw(str: any): never;
error(str: any): void;
warn(str: any): void;
extend(child: any, parent: any): void;
_getControlPoints(x0: any, y0: any, x1: any, y1: any, x2: any, y2: any, t: any): any[];
_expandPoints(p: any, tension: any): any[];
each(obj: any, func: any): void;
_inRange(val: any, left: any, right: any): boolean;
_getProjectionToSegment(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any): any[];
_getProjectionToLine(pt: Point, line: any, isClosed: any): Point;
_prepareArrayForTween(startArray: any, endArray: any, isClosed: any): any[];
_prepareToStringify(obj: any): any;
};