# `<rect>`

[Canonical page](https://nothing.graphics/docs/format/reference/rect) · [Page source on GitHub](https://github.com/gridaco/nothing/blob/main/ncf/docs/reference/rect.md)

Define a rectangle with optional rounded corners as a shape’s geometry.

## Examples

The shape owns the rotation. The rectangle owns its local width. The shape’s translation and the rectangle’s default center registration keep the painted rectangle centered at (32, 24).

[Download the complete .nothing source](https://nothing.graphics/format/centered-rectangle/source.nothing) · [Source on GitHub](https://github.com/gridaco/nothing/blob/main/ncf/conformance/boxed-geometry/centered-rectangle.nothing)

Rendered with ncf-preview at 80 × 56.

- [Frame 0 · Initial pose](https://nothing.graphics/format/centered-rectangle/0.webp). A 12 × 8 white rectangle centered at (32, 24). Three smaller registration examples sit to its right.
- [Frame 4 · Quarter turn](https://nothing.graphics/format/centered-rectangle/4.webp). The rectangle turns 90° clockwise. Its painted extent is 8 × 12 and its center stays at (32, 24).
- [Frame 8 · Wider rectangle](https://nothing.graphics/format/centered-rectangle/8.webp). The local width increases to 20 while the quarter turn holds. The painted extent is 8 × 20 and its center stays at (32, 24).

```xml
  <shape translate-x="32" translate-y="24">
    <animate attributeName="rotate" fill="freeze">
      <key frame="0" value="0" ease="linear"/>
      <key frame="4" value="90"/>
    </animate>
    <rect width="12" height="8">
      <animate attributeName="width" fill="freeze">
        <key frame="4" value="12" ease="linear"/>
        <key frame="8" value="20"/>
      </animate>
    </rect>
    <fill><paint><solid color="#FFFFFFFF"/></paint></fill>
  </shape>
```



<!-- Generated by ncf/tools/reference/generate.mjs. -->

The `<rect>` element defines the rectangular contour of a [shape](https://nothing.graphics/docs/format/reference/shape). With default registration and offsets, its center sits at the shape’s local origin. Set rotation on the owning shape.

## Syntax [#syntax]

Set the rectangle to 10 local units wide and 6 high. With both anchor values at zero, its top-left corner sits at the shape’s local origin.

```xml
<rect width="10" height="6" anchor-u="0" anchor-v="0"/>
```

[Complete .nothing source](https://github.com/gridaco/nothing/blob/main/ncf/conformance/boxed-geometry/centered-rectangle.nothing)

## Usage context [#usage-context]

Allowed parents are [`<shape>`](https://nothing.graphics/docs/format/reference/shape).

Inherits from [Geometry](https://nothing.graphics/docs/format/reference/geometry).

Includes [Registration](https://nothing.graphics/docs/format/reference/registration).

## Attributes [#attributes]

[Property animation](https://nothing.graphics/docs/format/spec/animation#property-types-and-exceptions)

### `width` [#width]

**Value** local units · **Required** · **Keys** Scalar

Nonnegative rectangle width.

### `height` [#height]

**Value** local units · **Required** · **Keys** Scalar

Nonnegative rectangle height.

### `corner-radius` [#corner-radius]

**Value** local units · **If omitted** `0` · **Keys** Scalar

Shared nonnegative circular corner radius. [Rectangle corners](https://nothing.graphics/docs/format/spec/graphics#rectangle-corners)

### `corner-top-left-radius` [#corner-top-left-radius]

**Value** local units · **If omitted** Sampled `corner-radius` · **Keys** Scalar

Nonnegative radius of the local top-left corner. [Rectangle corners](https://nothing.graphics/docs/format/spec/graphics#rectangle-corners)

### `corner-top-right-radius` [#corner-top-right-radius]

**Value** local units · **If omitted** Sampled `corner-radius` · **Keys** Scalar

Nonnegative radius of the local top-right corner. [Rectangle corners](https://nothing.graphics/docs/format/spec/graphics#rectangle-corners)

### `corner-bottom-right-radius` [#corner-bottom-right-radius]

**Value** local units · **If omitted** Sampled `corner-radius` · **Keys** Scalar

Nonnegative radius of the local bottom-right corner. [Rectangle corners](https://nothing.graphics/docs/format/spec/graphics#rectangle-corners)

### `corner-bottom-left-radius` [#corner-bottom-left-radius]

**Value** local units · **If omitted** Sampled `corner-radius` · **Keys** Scalar

Nonnegative radius of the local bottom-left corner. [Rectangle corners](https://nothing.graphics/docs/format/spec/graphics#rectangle-corners)

### `anchor-u` [#anchor-u]

**Value** fraction of width · **If omitted** `0.5` · **Keys** Scalar · **Declared by** [Registration](https://nothing.graphics/docs/format/reference/registration#anchor-u)

Horizontal registration. Zero selects the left edge and one the right edge. Values outside that interval extrapolate.

### `anchor-v` [#anchor-v]

**Value** fraction of height · **If omitted** `0.5` · **Keys** Scalar · **Declared by** [Registration](https://nothing.graphics/docs/format/reference/registration#anchor-v)

Vertical registration. Zero selects the top edge and one the bottom edge. Values outside that interval extrapolate.

### `offset-x` [#offset-x]

**Value** local units · **If omitted** `0` · **Keys** Scalar · **Declared by** [Registration](https://nothing.graphics/docs/format/reference/registration#offset-x)

Horizontal coordinate of the registered point.

### `offset-y` [#offset-y]

**Value** local units · **If omitted** `0` · **Keys** Scalar · **Declared by** [Registration](https://nothing.graphics/docs/format/reference/registration#offset-y)

Vertical coordinate of the registered point.

## Children [#children]

| Elements                                                              | Cardinality  | Declared by | Role and source order                                                                                                                                                                                                |
| --------------------------------------------------------------------- | ------------ | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`<animate>`](https://nothing.graphics/docs/format/reference/animate) | Zero or more | Animation   | A track targets one keyable property on this owner. For equal first-key times, the later track in document order wins. [Evaluating animation tracks](https://nothing.graphics/docs/format/spec/animation#evaluation) |

## Specifications [#specifications]

* [Size, registration and offset](https://nothing.graphics/docs/format/spec/boxed-geometry#size-registration-and-offset)
* [Rectangle corners](https://nothing.graphics/docs/format/spec/graphics#rectangle-corners)
* [Evaluating animation tracks](https://nothing.graphics/docs/format/spec/animation#evaluation)
