Last active
August 29, 2015 14:28
-
-
Save shamansir/1d7b26fff6f650af49fb to your computer and use it in GitHub Desktop.
SVG generate partially rounded rectangle path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // based on http://bl.ocks.org/mbostock/3468167 | |
| function roundedRect(x, y, width, height, rtl, rtr, rbr, rbl) { | |
| return "M" + x + "," + y | |
| + (rtl ? ("v" + rtl | |
| + "a" + rtl + "," + rtl + " 0 0 1 " + rtl + "," + -rtl) : "") | |
| + "h" + (width - (rtl ? rtl : 0) - (rtr ? rtr : 0)) | |
| + (rtr ? ("a" + rtr + "," + rtr + " 0 0 1 " + rtr + "," + rtr) : "") | |
| + "v" + (height - (rtr ? rtr : 0) - (rbr ? rbr : 0)) | |
| + (rbr ? ("a" + rbr + "," + rbr + " 0 0 1 " + -rbr + "," + rbr) : "") | |
| + "h" + ((rbr ? rbr : 0) + (rbl ? rbl : 0) - width) | |
| + (rbl ? ("a" + rbl + "," + rbl + " 0 0 1 " + -rbl + "," + -rbl) : "") | |
| + "v" + ((rbl ? rbl : 0) + (rtl ? rtl : 0) - height) | |
| + "z"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment