cornerRadius(topLeft_or_all, topRight, bottomRight, bottomLeft)

Class: Rectangle.

Description:

Sets or gets a corner radius for each corner separately or for all corners at once.

This method sets same width and height of the arc. If you need to set arc with different width and height, you can use Rectangle > cornerArc method: cornerArc(...).

Parameters:

Name Type Description

topLeft_or_all

number | string | object | undefined

Radius for top-left corner, a string radii for all corners (e.g., "15 15 0 0"), or an object containing each corner in the same format as this method returns. If this is the only passed parameter, it will be used for all corners.

topRight

number | undefined

Radius for top-right corner. If omitted, it defaults to topLeft corner.

bottomRight

number | undefined

Radius for bottom-right corner. If omitted, it defaults to topRight corner.

bottomLeft

number | undefined

Radius for bottom-left corner. If omitted, it defaults to bottomRight corner.

Returns:

If called without parameters or topLeft is undefined, current corner radius object is returned. If called with arguments, this Rectangle shape is returned for chaining.

Type: Object | Rectangle

Examples:

3 ways to set radius for each corner separately:

rectangle.cornerRadius(10, 10, 0, 0); // as separate parameters
rectangle.cornerRadius("10 10 0 0"); // in a string (CSS style)
rectangle.cornerRadius({tl:10, tr:10, br:0, bl:0}); // In same object format as this method returns

Setting radius for all corners at once:

rectangle.cornerRadius(10);

Also See: