PolyImage

class PolyImage @JvmOverloads constructor(val resourcePath: String, val type: PolyImage.Type = from(resourcePath)) : Resource

Image representation in PolyUI. The image is lazily-loaded from the resourcePath.

Parameters

resourcePath

the path to the resource

type

the image type. This is automatically inferred from the file extension normally, but you can manually select it.

Constructors

Link copied to clipboard
constructor(resourcePath: String, type: PolyImage.Type = from(resourcePath))

Types

Link copied to clipboard
object Companion
Link copied to clipboard
Link copied to clipboard

Types for images in PolyUI.

Properties

Link copied to clipboard
@get:JvmName(name = "shouldLoadSync")
val loadSync: Boolean

true if this resource should be loaded synchronously, false otherwise. (optional operation)

Link copied to clipboard
Link copied to clipboard
@get:JvmName(name = "getSize")
var size: Vec2
Link copied to clipboard

Functions

Link copied to clipboard
open fun bytes(): ByteArray

Return this resource's contents as an array of bytes.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
inline fun load(errorHandler: (Throwable) -> ByteArray = { throw it }): ByteArray

load the given resource synchronously into a new byte array. you may then perform any operations on the result.

inline fun <T> load(errorHandler: (Throwable) -> T & Any = { throw it }, mapper: (ByteArray) -> T & Any): T

load the given resource synchronously, mapping to definitely non-nullable type T. you may then perform any operations on the result.

Link copied to clipboard
fun loadAsync(errorHandler: (Throwable) -> Unit = { throw it }, consumer: (ByteArray) -> Unit)

load the given resource asynchronously into a new byte array, calling the consumer with the result on the worker thread.

fun <T> loadAsync(errorHandler: (Throwable) -> Unit = { throw it }, mapper: (ByteArray) -> T & Any, consumer: (T & Any) -> Unit)

load the given resource asynchronously, mapping to definitely non-nullable type T, calling the consumer with the result on the worker thread.

Link copied to clipboard
fun onInit(func: () -> Unit)

Add a callback that will be executed once this resource is about to be initialized by a rendering implementation.

Link copied to clipboard
@ApiStatus.Internal
fun reportInit()

Use this method to execute any callbacks that were added before the resource was initialized.

Link copied to clipboard
open fun stream(): InputStream

return the stream of this resource. it is the caller's responsibility to close the stream.

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