diff --git a/CHANGELOG.md b/CHANGELOG.md index 555dd5b6..da2955e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +### 9.2.0 (2023-05-14) + +- More controls on clipping +- `fillRule` for `Konva.Shape` + ### 9.1.0 (2023-05-14) - New `anchorStyleFunc` for `Konva.Transformer` to customize anchor style diff --git a/src/Container.ts b/src/Container.ts index aefd685a..4701ab3e 100644 --- a/src/Container.ts +++ b/src/Container.ts @@ -7,7 +7,10 @@ import { Shape } from './Shape'; import { HitCanvas, SceneCanvas } from './Canvas'; import { SceneContext } from './Context'; -export type ClipFuncOutput = void | [Path2D | CanvasFillRule] | [Path2D, CanvasFillRule] +export type ClipFuncOutput = + | void + | [Path2D | CanvasFillRule] + | [Path2D, CanvasFillRule]; export interface ContainerConfig extends NodeConfig { clearBeforeDraw?: boolean; clipFunc?: (ctx: SceneContext) => ClipFuncOutput; @@ -521,7 +524,10 @@ export abstract class Container< // there was "this" instead of "Container<ChildType>", // but it breaks react-konva types: https://github.com/konvajs/react-konva/issues/390 clipFunc: GetSet< - (ctx: CanvasRenderingContext2D, shape: Container<ChildType>) => ClipFuncOutput, + ( + ctx: CanvasRenderingContext2D, + shape: Container<ChildType> + ) => ClipFuncOutput, this >; } @@ -637,10 +643,12 @@ Factory.addGetterSetter(Container, 'clipFunc'); * // get clip function * var clipFunction = container.clipFunc(); * - * // set clip height + * // set clip function * container.clipFunc(function(ctx) { * ctx.rect(0, 0, 100, 100); + * }); * + * container.clipFunc(function(ctx) { * // optionally return a clip Path2D and clip-rule or just the clip-rule * return [new Path2D('M0 0v50h50Z'), 'evenodd'] * });