From 467147b4c7980511ee9303d08038a63ef17632c8 Mon Sep 17 00:00:00 2001 From: CPatchane Date: Thu, 28 Dec 2023 14:45:39 +0100 Subject: [PATCH] Add support for ctx.roundRect https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/roundRect --- src/Context.ts | 13 +++++++++++++ test/unit/Context-test.ts | 1 + 2 files changed, 14 insertions(+) diff --git a/src/Context.ts b/src/Context.ts index 928aaa8b6..ef75ca2ac 100644 --- a/src/Context.ts +++ b/src/Context.ts @@ -58,6 +58,7 @@ var COMMA = ',', 'putImageData', 'quadraticCurveTo', 'rect', + 'roundRect', 'restore', 'rotate', 'save', @@ -586,6 +587,18 @@ export class Context { rect(x: number, y: number, width: number, height: number) { this._context.rect(x, y, width, height); } + /** + * roundRect function. + * @method + * @name Konva.Context#roundRect + */ + roundRect(x: number, y: number, width: number, height: number, radii: number) { + if (this._context.roundRect) { + this._context.roundRect(x, y, width, height, radii); + } else { + this._context.rect(x, y, width, height); + } + } /** * putImageData function. * @method diff --git a/test/unit/Context-test.ts b/test/unit/Context-test.ts index 7d5a256c6..7cf6fc5d8 100644 --- a/test/unit/Context-test.ts +++ b/test/unit/Context-test.ts @@ -22,6 +22,7 @@ describe('Context', function () { 'arc', 'arcTo', 'rect', + 'roundRect', 'ellipse', 'fill', 'stroke',