擴展mxPoint以實現具有雙精度坐標的二維矩形。
```
function mxRectangle(x, y, width, height)
```
**變量**:
- `width` : 容納矩形的寬度,默認為 `0`
- `height` : 容納矩形的高度,默認為 `0`
**函數**:
- `setRect(x, y, w, h)` : 將此矩形設定為指定的值
- `getCenterX()` : 返回中心點的X坐標
- `getCenterY()` : 返回中心點的Y坐標
```
const rect = new mxRectangle(0, 0, 200, 30)
const rect2 = new mxRectangle(10, 20, 200, 30)
rect.getCenterX() // 100
rect.getCenterY() // 15
rect2.getCenterX() // 110
rect2.getCenterY() // 35
```
- `add(rect: mxRectangle)` : 將給定的矩形添加到此矩形
```
const rect = new mxRectangle(0, 0, 200, 30)
const rect2 = new mxRectangle(10, 10, 200, 30)
rect.add(rect2)
rect // 210x40
```

- `intersect(rect: mxRectangle)` : 將此矩形更改為與給定矩形重疊的位置。
```
rect.intersect(rect2)
rect // 190x20
```

- `grow(amount)` : 將矩形增長給定的數量,也就是說,此方法從 `x` 坐標和 `y` 坐標中減去給定的數量,然后將寬度和高度相加兩倍。
```
const rect = new mxRectangle(20, 20, 200, 30)
rect.grow(20)
rect // 240x70
```

- `getPoint()` : 返回左上角作為新的 `mxPoint`
```
const rect = new mxRectangle(20, 20, 200, 30)
rect.getPoint() // mxPoint {x: 20, y: 20}
```
- `rotate90()` : 將此矩形圍繞其中心點旋轉90度。
- `equals(obj)` : 如果給定對象等于此矩形,則返回 `true`
- `fromRectangle(rect: mxRectangle)` : 返回一個新的mxRectangle,它是給定矩形的副本