diff --git a/src/Context.ts b/src/Context.ts index 4073342b..1d7c53a8 100644 --- a/src/Context.ts +++ b/src/Context.ts @@ -362,8 +362,8 @@ export class Context { * @method * @name Konva.Context#clip */ - clip(fillRule?: CanvasFillRule): void - clip(path: Path2D, fillRule?: CanvasFillRule): void + clip(fillRule?: CanvasFillRule): void; + clip(path: Path2D, fillRule?: CanvasFillRule): void; clip(...args: any[]) { this._context.clip.apply(this._context, args); } @@ -484,9 +484,10 @@ export class Context { * @method * @name Konva.Context#fill */ - fill(fillRule?: CanvasFillRule): void - fill(path: Path2D, fillRule?: CanvasFillRule): void + fill(fillRule?: CanvasFillRule): void; + fill(path: Path2D, fillRule?: CanvasFillRule): void; fill(...args: any[]) { + // this._context.fill(); this._context.fill.apply(this._context, args); } /** @@ -749,7 +750,7 @@ export class Context { // supported context properties type CanvasContextProps = Pick< CanvasRenderingContext2D, - typeof CONTEXT_PROPERTIES[number] + (typeof CONTEXT_PROPERTIES)[number] >; export interface Context extends CanvasContextProps {} diff --git a/src/Shape.ts b/src/Shape.ts index 2b9f5223..93fd096e 100644 --- a/src/Shape.ts +++ b/src/Shape.ts @@ -56,7 +56,7 @@ export interface ShapeConfig extends NodeConfig { fillRadialGradientColorStops?: Array; fillEnabled?: boolean; fillPriority?: string; - fillRule?: CanvasFillRule + fillRule?: CanvasFillRule; stroke?: string | CanvasGradient; strokeWidth?: number; fillAfterStrokeEnabled?: boolean; @@ -89,7 +89,10 @@ export interface ShapeGetClientRectConfig { relativeTo?: Node; } -export type FillFuncOutput = void | [Path2D | CanvasFillRule] | [Path2D, CanvasFillRule] +export type FillFuncOutput = + | void + | [Path2D | CanvasFillRule] + | [Path2D, CanvasFillRule]; var HAS_SHADOW = 'hasShadow'; var SHADOW_RGBA = 'shadowRGBA'; @@ -115,7 +118,7 @@ export const shapes: { [key: string]: Shape } = {}; // what color to use for hit test? function _fillFunc(context) { - const fillRule = this.fillRule() + const fillRule = this.attrs.fillRule; if (fillRule) { context.fill(fillRule); } else { diff --git a/test/bunnies.html b/test/bunnies.html index de716ed7..f40aba22 100644 --- a/test/bunnies.html +++ b/test/bunnies.html @@ -96,6 +96,7 @@ perfectDrawEnabled: false, width: wabbitTexture.width, height: wabbitTexture.height, + fill: 'yellow', }); bunny.speedX = Math.random() * 10;