RectSlice

data class RectSlice<T : SizeableInt>(val base: T, val rect: RectangleInt, val orientation: SliceOrientation = SliceOrientation.ROTATE_0, val padding: MarginInt = MarginInt.ZERO, val name: String? = null) : SliceCoordsWithBaseAndRect<T>

Represents a 2D slice in an integral space inside a base (or atlas) that has a width and height.

The rect property represents the slice inside that base/container, as it is stored without any kind of transformation.

Then there is a orientation that described how that slice should be interpreted. Should it be rotated or flipped later?

The coords represents a ratio (0-1) coordinates inside the base/container with the swapped coordinates applying the orientation. The unorientedCoords represents a ratio (0-1) coordinates inside the base/container without applying the orientation.

Then the padding describes, the padding that will have the rect after applying the orientation to represent the original sliced region. virtFrame represents the region including the oriented width and height and the padding.

Typically, this slice represents a slice inside a Bitmap or a Texture atlas, that might have been stored rotated, flipped, etc. and sometimes it might have been cropped.

Constructors

Link copied to clipboard
constructor(base: T, rect: RectangleInt, orientation: SliceOrientation = SliceOrientation.ROTATE_0, padding: MarginInt = MarginInt.ZERO, name: String? = null)

Properties

Link copied to clipboard
open val area: Int
Link copied to clipboard
open override val base: T

Data containing width&height

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val blX: Float
Link copied to clipboard
open override val blY: Float
Link copied to clipboard
open val bottom: Int
Link copied to clipboard
open override val brX: Float
Link copied to clipboard
open override val brY: Float
Link copied to clipboard

Coordinates 0-1 based inside the container/base based on the rect after applying the orientation

Link copied to clipboard
open override val frameHeight: Int
Link copied to clipboard
open val frameOffsetX: Int
Link copied to clipboard
open val frameOffsetY: Int
Link copied to clipboard
open override val frameWidth: Int
Link copied to clipboard
open override val height: Int

height of the slice after applying the orientation transformation. ie. if this is rotated by 90 or 270, this can be the width

Link copied to clipboard
Link copied to clipboard
open val left: Int
Link copied to clipboard
open override val name: String? = null

Debug name describing this slice

Link copied to clipboard

An orientation describing how the slice is going to be rotated and flipped

Link copied to clipboard
open override val padding: MarginInt

Extra empty pixels that will be considered for this slice, for tightly packed images

Link copied to clipboard
open override val rect: RectangleInt

rect of the slice, without the orientation applied

Link copied to clipboard
open val right: Int
Link copied to clipboard
open val sizeString: String
Link copied to clipboard
open override val tlX: Float
Link copied to clipboard
open override val tlY: Float
Link copied to clipboard
open val top: Int
Link copied to clipboard
Link copied to clipboard
open override val trX: Float
Link copied to clipboard
open override val trY: Float
Link copied to clipboard

Coordinates 0-1 based inside the container/base based on the rect without applying the orientation

Link copied to clipboard

height of the slice without applying the orientation

Link copied to clipboard

width of the slice without applying the orientation

Link copied to clipboard
Link copied to clipboard
open override val width: Int

width of the slice after applying the orientation transformation. ie. if this is rotated by 90 or 270, this can be the height

Functions

Link copied to clipboard
open override fun flippedX(): RectSlice<T>
Link copied to clipboard
open override fun flippedY(): RectSlice<T>
Link copied to clipboard
open override fun rotatedLeft(offset: Int): RectSlice<T>
Link copied to clipboard
open override fun rotatedRight(offset: Int): RectSlice<T>
Link copied to clipboard
fun slice(rect: RectangleInt, name: String? = null, clamped: Boolean = true, orientation: SliceOrientation = this.orientation): RectSlice<T>
Link copied to clipboard
fun sliceWithBounds(left: Int, top: Int, right: Int, bottom: Int, name: String? = null, clamped: Boolean = true, orientation: SliceOrientation = this.orientation): RectSlice<T>
Link copied to clipboard
fun sliceWithSize(x: Int, y: Int, width: Int, height: Int, name: String? = null, clamped: Boolean = true, orientation: SliceOrientation = this.orientation): RectSlice<T>
Link copied to clipboard
fun <T : SizeableInt> RectSlice<T>.split(width: Int, height: Int, inRows: Boolean): List<RectSlice<T>>
Link copied to clipboard
fun <T : SizeableInt> RectSlice<T>.splitInCols(width: Int, height: Int): List<RectSlice<T>>
Link copied to clipboard
fun <T : SizeableInt> RectSlice<T>.splitInRows(width: Int, height: Int): List<RectSlice<T>>
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open override fun transformed(orientation: SliceOrientation): RectSlice<T>
Link copied to clipboard
fun virtFrame(x: Int, y: Int, width: Int, height: Int): RectSlice<T>
Link copied to clipboard
open fun x(index: Int): Float
Link copied to clipboard
open fun y(index: Int): Float