---
title: "init(rectOf:cornerRadius:)"
framework: spritekit
role: symbol
role_heading: Initializer
path: "spritekit/skshapenode/init(rectof:cornerradius:)"
---

# init(rectOf:cornerRadius:)

Creates a shape with a rectangular path that has rounded corners centered on the node’s position.

## Declaration

```swift
convenience init(rectOf size: CGSize, cornerRadius: CGFloat)
```

## Parameters

- `size`: The size of the rectangle.
- `cornerRadius`: The radius of the rounded corners. The radius should not be a negative number. The value should be no larger than half of the rectangle’s width or height, whichever is smaller.

## Return Value

Return Value A new shape node.

## See Also

### Creating a Shape from a Rectangle

- [init(rect:)](spritekit/skshapenode/init(rect:).md)
- [init(rectOf:)](spritekit/skshapenode/init(rectof:).md)
- [init(rect:cornerRadius:)](spritekit/skshapenode/init(rect:cornerradius:).md)
