d3 / d3-shape

Graphical primitives for visualization, such as lines and areas.
https://d3js.org/d3-shape
ISC License
2.48k stars 310 forks source link

selected rounding of corners in arc #195

Open murtada58 opened 2 years ago

murtada58 commented 2 years ago

Allow rounding of individual corners by passing in an array instead of a number following CSS border radius conventions for which corners get rounded if array has less than 4 numbers and backwards compatible with old method of passing in a single number which will round all 4 corners

Fil commented 2 years ago

Nice! A detail: since the original code is coercing rc to a number, you my want to use Array.isArray to detect the new use case, and fall back to rc = +rc if not an array, so as not to introduce a breaking change for users who might be (inadvertently) calling cornerRadius("10").

This would also need documentation and an example.

murtada58 commented 2 years ago

I've updated the readme with an example now, let me know if there is anything else :)