dimensions
The dimensions class provides an interface for manipulating width and height values of a widget.
This class is available from the cs class store, or cs.ui class store if you use the UI component.
cs.dimensions.new()
cs.dimensions.new( widget : Object ) : cs.dimensions
cs.dimensions.new( name : Text ) : cs.dimensions
cs.dimensions.new( width : Integer; height : Integer ) : cs.dimensions
cs.dimensions.new() : cs.dimensions
| Parameter | Type | Description | |
|---|---|---|---|
| widget | Object | → | A widget class object like cs.static, cs.input, cs.button… |
| name | Text | → | Widget name |
| width | Integer | → | Width in pixels |
| height | Integer | → | Height in pixels |
| result | cs.dimensions | ← | New cs.dimensions |
Description
cs.dimensions.new() creates and returns a new class instance.
- If
widgetornameis passed, dimensions are read from the current object coordinates. - If
widthandheightare passed, they are used directly. - If no parameter is passed, width and height default to 0.
Properties
| Properties | Description | Type | Writable |
|---|---|---|---|
| .width | Width in pixels | Integer |
✓ |
| .height | Height in pixels | Integer |
✓ |
Functions
| Functions | |
|---|---|
.area() → Integer |
Returns width * height |
.perimeter() → Integer |
Returns (width + height) * 2 |
Compatibility Note
cs.dimensions is introduced as a transition companion to cs.rect.
- Existing
rectAPIs remain valid. - Newer integrations may expose both
.rectand.dimensionsaliases for backward compatibility.