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

Constants

const Int

Represents an unbounded (infinite) constraint value.

Public constructors

VolumeConstraints(
    minWidth: Int,
    maxWidth: Int,
    minHeight: Int,
    maxHeight: Int,
    minDepth: Int,
    maxDepth: Int
)

Public functions

VolumeConstraints
copy(
    minWidth: Int,
    maxWidth: Int,
    minHeight: Int,
    maxHeight: Int,
    minDepth: Int,
    maxDepth: Int
)

Creates a copy of this VolumeConstraints object with modifications to its properties.

open operator Boolean
equals(other: Any?)

Checks if this VolumeConstraints object is equal to other object.

open Int

Calculates a hash code for this VolumeConstraints object.

open String

Returns a string representation of the VolumeConstraints.

Public properties

Boolean

Indicates whether the depth is bounded (has a maximum value other than INFINITY).

Boolean

Indicates whether the height is bounded (has a maximum value other than INFINITY).

Boolean

Indicates whether the width is bounded (has a maximum value other than INFINITY).

Int

the maximum allowed depth in pixels.

Int

the maximum allowed height in pixels.

Int

the maximum allowed width in pixels, use INFINITY to indicate no maximum.

Int

the minimum allowed depth in pixels.

Int

the minimum allowed height in pixels.

Int

the minimum allowed width in pixels.

Extension functions

VolumeConstraints

Constrains the dimensions of this VolumeConstraints object to fit within the bounds of the other VolumeConstraints object.

Int

Constrains a given depth value to fit within the bounds of this VolumeConstraints object.

Int

Constrains a given height value to fit within the bounds of this VolumeConstraints object.

Int

Constrains a given width value to fit within the bounds of this VolumeConstraints object.

VolumeConstraints
VolumeConstraints.offset(
    horizontal: Int,
    vertical: Int,
    depth: Int,
    resetMins: Boolean
)

Creates a new VolumeConstraints object by offsetting the minimum and maximum values of this one.

Constants

INFINITY

const val INFINITYInt

Represents an unbounded (infinite) constraint value.

Public constructors

VolumeConstraints

Added in 1.0.0-alpha01
VolumeConstraints(
    minWidth: Int,
    maxWidth: Int,
    minHeight: Int,
    maxHeight: Int,
    minDepth: Int = 0,
    maxDepth: Int = INFINITY
)

Public functions

copy

Added in 1.0.0-alpha01
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 VolumeConstraints object with the specified modifications.

equals

open operator fun equals(other: Any?): Boolean

Checks if this VolumeConstraints object is equal to other object.

hashCode

open fun hashCode(): Int

Calculates a hash code for this VolumeConstraints object.

toString

open fun toString(): String

Returns a string representation of the VolumeConstraints.

Public properties

hasBoundedDepth

Added in 1.0.0-alpha01
val hasBoundedDepthBoolean

Indicates whether the depth is bounded (has a maximum value other than INFINITY).

hasBoundedHeight

Added in 1.0.0-alpha01
val hasBoundedHeightBoolean

Indicates whether the height is bounded (has a maximum value other than INFINITY).

hasBoundedWidth

Added in 1.0.0-alpha01
val hasBoundedWidthBoolean

Indicates whether the width is bounded (has a maximum value other than INFINITY).

maxDepth

Added in 1.0.0-alpha01
val maxDepthInt

the maximum allowed depth in pixels. Can be INFINITY to indicate no maximum. Defaults to INFINITY.

maxHeight

Added in 1.0.0-alpha01
val maxHeightInt

the maximum allowed height in pixels. Can be INFINITY to indicate no maximum.

maxWidth

Added in 1.0.0-alpha01
val maxWidthInt

the maximum allowed width in pixels, use INFINITY to indicate no maximum.

minDepth

Added in 1.0.0-alpha01
val minDepthInt

the minimum allowed depth in pixels. Defaults to 0.

minHeight

Added in 1.0.0-alpha01
val minHeightInt

the minimum allowed height in pixels.

minWidth

Added in 1.0.0-alpha01
val minWidthInt

the minimum allowed width in pixels.

Extension functions

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 VolumeConstraints to constrain against.

Returns
VolumeConstraints

a new VolumeConstraints object with dimensions constrained within the bounds of otherConstraints.

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.

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 VolumeConstraints object with offset values.