ScaledPartialTexture

class ScaledPartialTexture(val partialTexture: PartialTexture, val scaleX: Float, val scaleY: Float) : Image

Defines a rectangular region of a Texture as an Image, but its size is reported scaled. i.e. a 64x64 image, scaled by 0.5 will report is size to be 32x32. NOTE, its actual size is still 64x64, and if you draw it (without additional scaling), it will be drawn as 32x32.

Example usage. Suppose we have a Texture with many 64x64 icons. This is typically too large for buttons in a toolbar, but if we scale them by 0.5, then they are fine. So, why not just use 32x32 icons instead? I'm glad you asked. On a high DPI display, the entire scene is also scaled up (maybe by a factor of 2). If we used 32x32 icons, then they would look equally bad (pixelated) on high-DPI displays as regular displays. i.e. we wouldn't be taking advantage of the extra pixels. By using ScaledPartialTexture the icons will be 32x32 logical pixels, but on a high-DPI display, the full 64x64 pixels will be put to use.

NOTE, the overhead of scaling down to 32x32 pixels on a regular display is very minimum (assuming the graphics card isn't older than 20+ years!).

Constructors

Link copied to clipboard
constructor(partialTexture: PartialTexture, scaleX: Float, scaleY: Float)

Properties

Link copied to clipboard
open override val imageHeight: Float
Link copied to clipboard
open override val imageWidth: Float
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open override fun batch(tint: Color?, block: TextureBatch.() -> Unit)
Link copied to clipboard
open override fun draw(x: Float, y: Float, tint: Color?)
Link copied to clipboard
open override fun drawBatched(batch: TextureBatch, x: Float, y: Float)
Link copied to clipboard
open override fun drawTo(x: Float, y: Float, destWidth: Float, destHeight: Float, tint: Color?)
Link copied to clipboard
open override fun drawToBatched(batch: TextureBatch, x: Float, y: Float, destWidth: Float, destHeight: Float)

The same as the other drawTo, but using a TextureBatch for efficiency.

Link copied to clipboard
open override fun partialImage(fromX: Float, fromY: Float, width: Float, height: Float): Image

Takes a rectangular region of this Image, and returns it as an Image. Note, the pixel data is NOT copied

Link copied to clipboard
open override fun scaledBy(scaleX: Float, scaleY: Float): ScaledPartialTexture

Returns an Image using the same pixel data as this image, but it lies about its actual size.

Link copied to clipboard
open override fun toString(): String