Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function createRoundedRectPath(x, y, width, height, radius) {
- return (
- // Move to position, offset by radius in x direction
- "M" +(x + radius) + "," + y
- // Draw a horizontal line to the top right curve start
- + "h" + (width - 2 * radius)
- // Draw the top right corner curve
- + "a" + radius + "," + radius + " 0 0 1 " + radius + "," + radius
- // Draw a vertical line to the bottom right corner
- + "v" + (height - 2 * radius)
- // Draw the bottom right corner curve
- + "a" + radius + "," + radius + " 0 0 1 " + -radius + "," + radius
- // Draw a horizontal line to the bottom left corner
- + "h" + (2 * radius - width)
- // Draw the bottom left corner
- + "a" + -radius + "," + -radius + " 0 0 1 " + -radius + "," + -radius
- // Draw a vertical line to the top left corner
- + "v" + (2 * radius - height)
- // Draw the top left corner
- + "a" + radius + "," + -radius + " 0 0 1 " + radius + "," + -radius
- // Close the shape
- + "z"
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement