Skip to content

Commit 418f555

Browse files
committed
bug: incorrect roundRect() with large radii
Fixes #2400
1 parent 9bcf363 commit 418f555

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
1010
### Changed
1111
### Added
1212
### Fixed
13+
* `roundRect()` shape incorrect when radii were large relative to rectangle size (#2400)
1314

1415
3.2.0
1516
==================

src/CanvasRenderingContext2d.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3175,10 +3175,10 @@ Context2d::RoundRect(const Napi::CallbackInfo& info) {
31753175
upperLeft.x *= scale;
31763176
upperLeft.y *= scale;
31773177
upperRight.x *= scale;
3178-
upperRight.x *= scale;
3179-
lowerLeft.y *= scale;
3178+
upperRight.y *= scale;
3179+
lowerLeft.x *= scale;
31803180
lowerLeft.y *= scale;
3181-
lowerRight.y *= scale;
3181+
lowerRight.x *= scale;
31823182
lowerRight.y *= scale;
31833183
}
31843184
}

test/public/tests.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ tests['roundRect()'] = function (ctx) {
132132
ctx.roundRect(135, 70, 60, 60, [{ x: 30, y: 10 }, { x: 5, y: 20 }])
133133
ctx.fillStyle = 'darkseagreen'
134134
ctx.fill()
135+
136+
ctx.beginPath()
137+
ctx.roundRect(5, 135, 8, 60, 15)
138+
ctx.fillStyle = 'purple'
139+
ctx.fill()
135140
}
136141

137142
tests['lineTo()'] = function (ctx) {

0 commit comments

Comments
 (0)