Skip to content

Conversation

@krystofbe
Copy link

This pull request updates the arc.js file to allow individual corners to be rounded by passing an array of numbers. This change is based on the code by murtada58 and ensures backward compatibility with the previous method of passing a single number for uniform corner rounding.

Changes include:

  • Allowing corner radius to accept an array of up to four numbers.
  • Maintaining backward compatibility by coercing single numbers.

Please review and let me know if there are any further adjustments needed.

Note: I am currently unsure how to update the d3-shape documentation to reflect these changes. Any guidance on this would be appreciated.

Here is a custom build d3.mjs.zip of D3 version 7.9.0 (d3.mjs) that includes these changes for immediate use.

if (rci.length === 1) rc = [rci[0], rci[0], rci[0], rci[0]];
else if (rci.length === 2) rc = [rci[0], rci[1], rci[0], rci[1]];
else if (rci.length === 3) rc = [rci[0], rci[1], rci[2], rci[1]];
else if (rci.length === 4) rc = rci;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could change that to else rc = rci.slice(0,4);, otherwise passing rci with more than 4 elements would never set rc?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants