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>
135 lines (134 loc) • 4.59 kB
TypeScript
import { Canvas } from './Canvas';
/**
* Konva wrapper around native 2d canvas context. It has almost the same API of 2d context with some additional functions.
* With core Konva shapes you don't need to use this object. But you have to use it if you want to create
* a custom shape or a custom hit regions.
* @constructor
* @memberof Konva
* @example
* const rect = new Konva.Shape({
* fill: 'red',
* width: 100,
* height: 100,
* sceneFunc: (ctx, shape) => {
* // ctx - is context wrapper
* // shape - is instance of Konva.Shape, so it equals to "rect" variable
* ctx.rect(0, 0, shape.getAttr('width'), shape.getAttr('height'));
*
* // automatically fill shape from props and draw hit region
* ctx.fillStrokeShape(shape);
* }
* })
*/
export declare class Context {
canvas: Canvas;
_context: CanvasRenderingContext2D;
traceArr: Array<String>;
constructor(canvas: any);
init(canvas: any): void;
/**
* fill shape
* @method
* @name Konva.Context#fillShape
* @param {Konva.Shape} shape
*/
fillShape(shape: any): void;
_fill(shape: any): void;
/**
* stroke shape
* @method
* @name Konva.Context#strokeShape
* @param {Konva.Shape} shape
*/
strokeShape(shape: any): void;
_stroke(shape: any): void;
/**
* fill then stroke
* @method
* @name Konva.Context#fillStrokeShape
* @param {Konva.Shape} shape
*/
fillStrokeShape(shape: any): void;
getTrace(relaxed: any): string;
clearTrace(): void;
_trace(str: any): void;
/**
* reset canvas context transform
* @method
* @name Konva.Context#reset
*/
reset(): void;
/**
* get canvas wrapper
* @method
* @name Konva.Context#getCanvas
* @returns {Konva.Canvas}
*/
getCanvas(): Canvas;
/**
* clear canvas
* @method
* @name Konva.Context#clear
* @param {Object} [bounds]
* @param {Number} [bounds.x]
* @param {Number} [bounds.y]
* @param {Number} [bounds.width]
* @param {Number} [bounds.height]
*/
clear(bounds?: any): void;
_applyLineCap(shape: any): void;
_applyOpacity(shape: any): void;
_applyLineJoin(shape: any): void;
setAttr(attr: any, val: any): void;
arc(a0: any, a1: any, a2: any, a3: any, a4: any, a5: any): void;
arcTo(a0: any, a1: any, a2: any, a3: any, a4: any, a5: any): void;
beginPath(): void;
bezierCurveTo(a0: any, a1: any, a2: any, a3: any, a4: any, a5: any): void;
clearRect(a0: any, a1: any, a2: any, a3: any): void;
clip(): void;
closePath(): void;
createImageData(a0: any, a1: any): ImageData;
createLinearGradient(a0: any, a1: any, a2: any, a3: any): CanvasGradient;
createPattern(a0: any, a1: any): CanvasPattern;
createRadialGradient(a0: any, a1: any, a2: any, a3: any, a4: any, a5: any): CanvasGradient;
drawImage(a0: any, a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any): void;
isPointInPath(x: any, y: any): boolean;
fill(): void;
fillRect(x: any, y: any, width: any, height: any): void;
strokeRect(x: any, y: any, width: any, height: any): void;
fillText(a0: any, a1: any, a2: any): void;
measureText(text: any): TextMetrics;
getImageData(a0: any, a1: any, a2: any, a3: any): ImageData;
lineTo(a0: any, a1: any): void;
moveTo(a0: any, a1: any): void;
rect(a0: any, a1: any, a2: any, a3: any): void;
putImageData(a0: any, a1: any, a2: any): void;
quadraticCurveTo(a0: any, a1: any, a2: any, a3: any): void;
restore(): void;
rotate(a0: any): void;
save(): void;
scale(a0: any, a1: any): void;
setLineDash(a0: any): void;
getLineDash(): number[];
setTransform(a0: any, a1: any, a2: any, a3: any, a4: any, a5: any): void;
stroke(): void;
strokeText(a0: any, a1: any, a2: any, a3: any): void;
transform(a0: any, a1: any, a2: any, a3: any, a4: any, a5: any): void;
translate(a0: any, a1: any): void;
_enableTrace(): void;
}
export declare class SceneContext extends Context {
_fillColor(shape: any): void;
_fillPattern(shape: any): void;
_fillLinearGradient(shape: any): void;
_fillRadialGradient(shape: any): void;
_fill(shape: any): void;
_strokeLinearGradient(shape: any): void;
_stroke(shape: any): void;
_applyShadow(shape: any): void;
_applyGlobalCompositeOperation(shape: any): void;
}
export declare class HitContext extends Context {
_fill(shape: any): void;
_stroke(shape: any): void;
}