VolumeConstraints
class VolumeConstraints
Defines constraints for a 3D volume, specifying minimum and maximum values for width, height, and depth.
This class is similar in concept to androidx.compose.ui.unit.Constraints, but adapted for 3D volumes.
Summary
Public constructors |
|---|
Public functions |
|
|---|---|
VolumeConstraints |
Creates a copy of this |
open operator Boolean |
Checks if this |
open Int |
hashCode()Calculates a hash code for this |
open String |
toString()Returns a string representation of the |
Public properties |
|
|---|---|
Boolean |
Indicates whether the depth is bounded (has a maximum value other than |
Boolean |
Indicates whether the height is bounded (has a maximum value other than |
Boolean |
Indicates whether the width is bounded (has a maximum value other than |
Int |
the maximum allowed depth in pixels. |
Int |
the maximum allowed height in pixels. |
Int |
the maximum allowed width in pixels, use |
Int |
the minimum allowed depth in pixels. |
Int |
the minimum allowed height in pixels. |
Int |
the minimum allowed width in pixels. |
Extension functions |
|
|---|---|
VolumeConstraints |
VolumeConstraints.constrain(otherConstraints: VolumeConstraints)Constrains the dimensions of this |
Int |
VolumeConstraints.constrainDepth(depth: Int)Constrains a given depth value to fit within the bounds of this |
Int |
VolumeConstraints.constrainHeight(height: Int)Constrains a given height value to fit within the bounds of this |
Int |
VolumeConstraints.constrainWidth(width: Int)Constrains a given |
VolumeConstraints |
Creates a new |
Public constructors
VolumeConstraints
VolumeConstraints(
minWidth: @IntRange(from = 0) Int = 0,
maxWidth: @IntRange(from = 0) Int = INFINITY,
minHeight: @IntRange(from = 0) Int = 0,
maxHeight: @IntRange(from = 0) Int = INFINITY,
minDepth: @IntRange(from = 0) Int = 0,
maxDepth: @IntRange(from = 0) Int = INFINITY
)
Public functions
copy
fun copy(
minWidth: Int = this.minWidth,
maxWidth: Int = this.maxWidth,
minHeight: Int = this.minHeight,
maxHeight: Int = this.maxHeight,
minDepth: Int = this.minDepth,
maxDepth: Int = this.maxDepth
): VolumeConstraints
Creates a copy of this VolumeConstraints object with modifications to its properties.
| Parameters | |
|---|---|
minWidth: Int = this.minWidth |
the minimum allowed width in the new constraints. |
maxWidth: Int = this.maxWidth |
the maximum allowed width in the new constraints. |
minHeight: Int = this.minHeight |
the minimum allowed height in the new constraints. |
maxHeight: Int = this.maxHeight |
the maximum allowed height in the new constraints. |
minDepth: Int = this.minDepth |
the minimum allowed depth in the new constraints. |
maxDepth: Int = this.maxDepth |
the maximum allowed depth in the new constraints. |
| Returns | |
|---|---|
VolumeConstraints |
a new |
equals
open operator fun equals(other: Any?): Boolean
Checks if this VolumeConstraints object is equal to other object.
Public properties
hasBoundedDepth
val hasBoundedDepth: Boolean
Indicates whether the depth is bounded (has a maximum value other than INFINITY).
hasBoundedHeight
val hasBoundedHeight: Boolean
Indicates whether the height is bounded (has a maximum value other than INFINITY).
hasBoundedWidth
val hasBoundedWidth: Boolean
Indicates whether the width is bounded (has a maximum value other than INFINITY).
maxDepth
val maxDepth: Int
the maximum allowed depth in pixels. Can be INFINITY to indicate no maximum. Defaults to INFINITY.
maxHeight
val maxHeight: Int
the maximum allowed height in pixels. Can be INFINITY to indicate no maximum.
maxWidth
val maxWidth: Int
the maximum allowed width in pixels, use INFINITY to indicate no maximum.
minDepth
val minDepth: Int
the minimum allowed depth in pixels. Defaults to 0.
Extension functions
constrain
fun VolumeConstraints.constrain(otherConstraints: VolumeConstraints): VolumeConstraints
Constrains the dimensions of this VolumeConstraints object to fit within the bounds of the other VolumeConstraints object.
| Parameters | |
|---|---|
otherConstraints: VolumeConstraints |
the other |
| Returns | |
|---|---|
VolumeConstraints |
a new |
constrainDepth
fun VolumeConstraints.constrainDepth(depth: Int): Int
Constrains a given depth value to fit within the bounds of this VolumeConstraints object.
| Parameters | |
|---|---|
depth: Int |
the depth value to constrain. |
| Returns | |
|---|---|
Int |
the constrained depth value, ensuring it's within the minimum and maximum depth bounds. |
constrainHeight
fun VolumeConstraints.constrainHeight(height: Int): Int
Constrains a given height value to fit within the bounds of this VolumeConstraints object.
| Parameters | |
|---|---|
height: Int |
the height value to constrain. |
| Returns | |
|---|---|
Int |
the constrained height value, ensuring it's within the minimum and maximum height bounds. |
constrainWidth
fun VolumeConstraints.constrainWidth(width: Int): Int
Constrains a given width value to fit within the bounds of this VolumeConstraints object.
| Parameters | |
|---|---|
width: Int |
the width value to constrain. |
| Returns | |
|---|---|
Int |
the constrained width value, ensuring it's within the minimum and maximum width bounds. |
offset
fun VolumeConstraints.offset(
horizontal: Int = 0,
vertical: Int = 0,
depth: Int = 0,
resetMins: Boolean = false
): VolumeConstraints
Creates a new VolumeConstraints object by offsetting the minimum and maximum values of this one.
| Parameters | |
|---|---|
horizontal: Int = 0 |
the horizontal offset to apply. |
vertical: Int = 0 |
the vertical offset to apply. |
depth: Int = 0 |
the depth offset to apply. |
resetMins: Boolean = false |
if true, the minimum values in the new constraints will be set to 0, otherwise. they will be offset. |
| Returns | |
|---|---|
VolumeConstraints |
a new |