comet.CRect¶
- class comet.CRect¶
A convenience class representing an always axis-aligned 2D rectangle. Coordinate values shrink towards top, grow towards bottom, shrink towards left and grow towards the right. The internal data is stored as float values.
Methods¶
- CRect.getValues()¶
Convenience functions to return all four side coordinates at once
- Returns:
All sides as (left, top, right, bottom)
- Return type:
- Available:
InDesign® comet_pdf® Illustrator®
- CScript:
- CRect.getLeft()¶
Returns the left component of the rectangle
- Returns:
The left side
- Return type:
- Available:
InDesign® comet_pdf® Illustrator®
- CScript:
- CRect.getTop()¶
Returns the top component of the rectangle
- CRect.getRight()¶
Returns the right component of the rectangle
- Returns:
The right side
- Return type:
- Available:
InDesign® comet_pdf® Illustrator®
- CScript:
- CRect.getBottom()¶
Returns the bottom component of the rectangle
- Returns:
The bottom side
- Return type:
- Available:
InDesign® comet_pdf® Illustrator®
- CScript:
- CRect.getCenter()¶
Returns the center of the rectangle
- Returns:
The center (x, y)
- Return type:
- Available:
InDesign® comet_pdf® Illustrator®
- CScript:
- CRect.getWidth()¶
Returns the width of the rectanggle
- Returns:
The width
- Return type:
- Available:
InDesign® comet_pdf® Illustrator®
- CScript:
- CRect.getHeight()¶
Returns the height of the rectanggle
- Returns:
The height
- Return type:
- Available:
InDesign® comet_pdf® Illustrator®
- CScript:
- CRect.getArea()¶
Returns the total area the rectangle covers
- Returns:
The rectangle are
- Return type:
- Available:
InDesign® comet_pdf® Illustrator®
- CScript:
- CRect.getAspectRatio()¶
Calculates the aspect ratio for the rectangle.
The aspect ratio is calculated as the ratio of the rectangle’s height to its width.
If the rectangle is empty, 0.0 is returned.
- Returns:
The aspect ratio
- Return type:
- Available:
InDesign® comet_pdf® Illustrator®
- CScript:
- CRect.moveTo(x, y, refPoint=0)¶
Move all coordinates so the reference point of the rectangle aligns with the provided coordinates
- Parameters:
x (float) – The new horizontal center
y (float) – The new vertical center
refPoint (int) –
The reference point which should be moved to the target coordinates.
One of Reference Points.
Default is
constants.kRefPointTopLeft
.
- Return type:
None
- Raises:
TypeError – When parameter types are invalid
ValueError – When parameter refPoint has invalid value
- Available:
InDesign® comet_pdf® Illustrator®
- CScript:
- CRect.moveBy(x, y)¶
Move all coordinates horizontally by x and vertically by y
- Parameters:
- Return type:
None
- Raises:
TypeError – When parameter types are invalid
- Available:
InDesign® comet_pdf® Illustrator®
- CScript:
- CRect.adjust(dx, dy, refPoint=0)¶
Enlarge (positive values) or shrink (negative values) the rectangle by moving the sides by the specified amounts. The adjusting is done around a fixed reference point.
- Parameters:
dx (float) – The amount to adjust horizontally
dy (float) – The amount to adjust vertically
refPoint (int) –
The reference point which is fixed during resize.
One of Reference Points.
Default is
constants.kRefPointTopLeft
.
- Return type:
None
- Raises:
TypeError – When parameter types are invalid
ValueError – When parameter refPoint has invalid value
- Available:
InDesign® comet_pdf® Illustrator®
- CScript:
- CRect.setLeft(value)¶
Set the left value component of the rectangle
- CRect.setTop(value)¶
Set the top value component of the rectangle
- CRect.setRight(value)¶
Set the right value component of the rectangle
- CRect.setBottom(value)¶
Set the bottom value component of the rectangle
- CRect.setWidth(value, refPoint=0)¶
Sets the new width of the rectangle by adjusting the horizontal components.
The center remains the same.
- Parameters:
value (float) – The new desired rectangle width
refPoint (int) –
The reference point which is fixed during resize.
One of Reference Points.
Default is
constants.kRefPointTopLeft
.
- Return type:
None
- Raises:
TypeError – When parameter types are invalid
When parameter value has invalid value (< 0.0)
When parameter refPoint has invalid value
- Available:
InDesign® comet_pdf® Illustrator®
- CScript:
- CRect.setHeight(value, refPoint=0)¶
Sets the new height of the rectangle by adjusting the vertical components. The center remains the same.
- Parameters:
value (float) – The new desired rectangle height
refPoint (int) –
The reference point which is fixed during resize.
One of Reference Points.
Default is
constants.kRefPointTopLeft
.
- Return type:
None
- Raises:
TypeError – When parameter types are invalid
When parameter value has invalid value (< 0.0)
When parameter refPoint has invalid value
- Available:
InDesign® comet_pdf® Illustrator®
- CScript:
- CRect.intersects(other)¶
Determines whether this rectangle intersects with another.
- CRect.createIntersection(other)¶
Create a new CRect by determining the intersection with other. May create a zero-length rectangle when no intersection is found.
- CRect.createUnion(other)¶
Create a union of the CRect instances.
- CRect.containsPoint(x, y)¶
Determine whether the rectangle contains the point defined by x and y.
- Parameters:
- Returns:
Whether the rectangle contains the point defined by x/y
- Return type:
- Raises:
TypeError – When parameter types are invalid
- Available:
InDesign® comet_pdf® Illustrator®
- CScript:
- CRect.containsRect(other)¶
Determine whether the rectangle fully contains another one.