-
-
Notifications
You must be signed in to change notification settings - Fork 924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for ctx.roundRect #1695
Conversation
I think we can skip the check, as it is already supported by all major browsers. |
It was introduced in Chrome 99 less than two years ago. I removed the check then 👍 |
I just saw that you have a util function to draw round rectangle that is used in some |
src/Context.ts
Outdated
* @method | ||
* @name Konva.Context#roundRect | ||
*/ | ||
roundRect(x: number, y: number, width: number, height: number, radii: number) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should type of radii
by also an array? Like number | Array<number>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh you're right, missed the fact that you can fact an array of corners name 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't be compatible with the internal drawRoundedRectPath
function
So let's just use the native API then 👍
c596112
to
f6ccabb
Compare
Interesting, I just tried to use |
Ouch, it would be better to have at least the same performance, might be an optimisation issue since it's a recent addition? Or maybe it has more work to do to handle DOMPointInit for radius |
According to the MDN, we should be able to use the
roundRect()
function on the canvas context.While we can create rounded rectangles by setting
cornerRadius
toRect()
, theroundRect()
function is particularly useful when we want to clip using a rounded rectangle shape withclipFunc()
.Since this function appears to be a recent implementation, it might be a good idea to check if it's supported before running it.
Here I chose to run
rect()
instead so the result would be at least a rectangle but let me know if you think that we should handle this in a different manner.