Package-level declarations

Types

Link copied to clipboard
class Clock

A simple class for timing of animations and things. Literally a delta function.

Link copied to clipboard
class Debugger(polyUI: PolyUI)

the debug utilities for PolyUI.

Link copied to clipboard
typealias Line = Pair<String, Vec2>
Link copied to clipboard
@Blocking
@ApiStatus.Experimental
annotation class Locking(val when: String = "")

Marker class for future use, which will be used to indicate that the given function or property will block until the lock is freed (when it finishes the frame)

Link copied to clipboard
data class Quad<out A, out B, out C, out D>(val first: A, val second: B, val third: C, val fourth: D)

A quad of values.

Link copied to clipboard
@ApiStatus.Experimental
annotation class SideEffects(val values: String, val when: String = "")

An annotation to mark a function or property as having side effects.

Properties

Link copied to clipboard
Link copied to clipboard
val Int.blue: Int
Link copied to clipboard
Link copied to clipboard
val Int.red: Int

Functions

Link copied to clipboard
fun <E> MutableList<E>.addIfAbsent(element: E)

Add the given element to this list if it is not in it already.

Link copied to clipboard
@ApiStatus.Internal
fun <E> MutableList<E>.addOrReplace(element: E): E?

Replace this given element if it already exists in this list using Any.equals, or append it to the end if it does not. This method is very strange and has one specific use case, which is for cases where referential equality is needed as well as structural equality. See more here.

Link copied to clipboard
Link copied to clipboard

append the given Char to this StringBuilder, repeated repeats times.

Link copied to clipboard
fun argb(argb: Int): PolyColor
Link copied to clipboard
inline fun <T> Pair<T, T>.both(func: (T) -> Unit)

Perform the given function on both elements of this pair. The highest common type of both elements is used as the type of the parameter.

Link copied to clipboard
inline fun cl0(a: Float, b: Float): Float

Returns the value closer to zero.

Link copied to clipboard
inline fun cl1(a: Float, b: Float): Float

Returns the value closer to one.

Link copied to clipboard
fun CharSequence.closestToPoint(renderer: Renderer, font: Font, fontSize: Float, x: Float): Int

Returns the closest character index from the given string to the given point x.

Link copied to clipboard
fun <L : MutableList<E>, RandomAccess, E> L.cut(from: Int, to: Int): L

Returns this list, with all elements not in the range from..to removed.

Link copied to clipboard
fun <T> Ref.ObjectRef<T>.deref(): T

Return the value of this Ref.ObjectRef.

Link copied to clipboard
Link copied to clipboard
fun String.dropAt(index: Int = lastIndex, amount: Int = 1): String
Link copied to clipboard
Link copied to clipboard
inline fun <T> MutableList<T>.ensureSize(size: Int, initializer: (Int) -> T): MutableList<T>

Ensure that this list is at least size elements long, and if it is not, add elements to it using the given initializer.

Link copied to clipboard
inline fun <L : List<E>, RandomAccess, E> L.fastAll(predicate: (E) -> Boolean): Boolean

Returns true if all elements match the given predicate.

Link copied to clipboard
inline fun <L : List<E>, RandomAccess, E> L.fastAny(predicate: (E) -> Boolean): Boolean

Returns true if all elements match the given predicate.

Link copied to clipboard
inline fun <L : List<E>, RandomAccess, E> L.fastEach(func: (E) -> Unit)

no-alloc Iterable.forEach which utilizes RandomAccess to get the elements.

Link copied to clipboard
inline fun <L : List<E>, RandomAccess, E> L.fastEachIndexed(func: (Int, E) -> Unit)

no-alloc Iterable.forEachIndexed which utilizes RandomAccess to get the elements.

Link copied to clipboard
inline fun <L : List<E>, RandomAccess, E> L.fastEachReversed(func: (E) -> Unit)

no-alloc List.forEach which utilizes RandomAccess to get the elements, backwards.

Link copied to clipboard
inline fun <L : MutableList<E>, RandomAccess, E> L.fastRemoveIf(predicate: (E) -> Boolean)

no-alloc MutableList.removeIf which utilizes RandomAccess to get the elements.

Link copied to clipboard
inline fun <L : MutableList<E>, RandomAccess, E> L.fastRemoveIfReversed(predicate: (E) -> Boolean)

no-alloc MutableList.removeIf which utilizes RandomAccess to get the elements.

Link copied to clipboard
fun Int.gcd(b: Int): Int

Calculate the greatest common denominator of two integers.

Link copied to clipboard
fun <E : Enum<E>> EnumEntries<E>.getByName(name: String?, ignoreCase: Boolean = false): E?

Get an enum constant by its name, or null if name is null; or does not match any of this enum's constants.

Link copied to clipboard
fun getResourceStream(resourcePath: String, caller: Class<*> = PolyUI::class.java): InputStream

return a stream of the given resource or throws an exception.

Link copied to clipboard
fun getResourceStreamNullable(resourcePath: String, caller: Class<*> = PolyUI::class.java): InputStream?

return a stream of the given resource, or null.

Link copied to clipboard
fun hex(hex: String): PolyColor
Link copied to clipboard
fun hsba(h: Float, s: Float, b: Float, a: Float = 1.0f): PolyColor.Static
Link copied to clipboard
fun HSBtoRGB(hue: Float, saturation: Float, brightness: Float, alpha: Float = 1.0f): Int

Converts the components of a color, as specified by the HSB model, to an equivalent set of values for the default RGB model.

Link copied to clipboard
inline fun String.image(): PolyImage
@JvmName(name = "image")
inline fun String.image(size: Vec2): PolyImage
Link copied to clipboard

calculate the levenshtein distance between this string and the other string.

Link copied to clipboard
inline fun <L : List<E>, RandomAccess, E, R> L.mapToArray(transform: (E) -> R): Array<R>
inline fun <T, R> Collection<T>.mapToArray(transform: (T) -> R): Array<R>

Perform the given transform on every element in this list, and return a new array with the results.

inline fun <T, R> Array<T>.mapToArray(transform: (T) -> R): Array<R>

Perform the given transform on every element in this array, and return a new array with the results.

inline fun <K, V, R> Map<K, V>.mapToArray(transform: (Map.Entry<K, V>) -> R): Array<R>

Perform the given transform on every element in this map, and return a new array with the results.

Link copied to clipboard
inline fun <K, V> MutableMap<K, V>.maybeRemove(key: K, shouldRemove: Boolean): V?

Returns the value of the given key in the map, and if shouldRemove is true the value is also removed from the map.

Link copied to clipboard
inline fun min3(a: Int, b: Int, c: Int): Int

Returns the minimum value among three given ints.

Link copied to clipboard
fun mods(vararg mods: KeyModifiers): Modifiers
Link copied to clipboard
inline fun <E> Array<E>.moveElement(from: Int, to: Int)

Moves the given element from the from index to the to index.

Link copied to clipboard
Link copied to clipboard

Return a list of the names of the entries in this enum.

Link copied to clipboard
fun PolyUI.open(window: Window)
Link copied to clipboard
fun <T> T.ref(): Ref.ObjectRef<T>

Box the given value into a Ref.ObjectRef.

Link copied to clipboard
fun String.remove(char: Char): String
Link copied to clipboard
Link copied to clipboard
fun resourceExists(resourcePath: String, caller: Class<*> = PolyUI::class.java): Boolean
Link copied to clipboard
fun rgba(r: Int, g: Int, b: Int, a: Float = 1.0f): PolyColor

create a color from the given red, green, and blue integer values, and an alpha value 0f..1f

Link copied to clipboard
fun RGBtoHSB(r: Int, g: Int, b: Int, out: FloatArray? = null): FloatArray

Converts the components of a color, as specified by the default RGB model, to an equivalent set of values for hue, saturation, and brightness that are the three components of the HSB model.

Link copied to clipboard
Link copied to clipboard

Simplify a ratio of two integers.

Link copied to clipboard
inline fun <T> T.stdout(arg: Any? = null): T

print the object to stdout, then return it.

Link copied to clipboard
fun String.substringOr(fromIndex: Int, toIndex: Int, other: String): String
Link copied to clipboard
fun String.substringSafe(fromIndex: Int, toIndex: Int = lastIndex): String
Link copied to clipboard
fun String.substringToWidth(renderer: Renderer, font: Font, fontSize: Float, width: Float): Pair<String, String>

take the given string and cut it to the length, returning a pair of the string cut to the length, and the remainder.

Link copied to clipboard

Converts the InputStream into a byte array and close it.

Link copied to clipboard

Takes an ARGB integer color and returns a PolyColor object.

Turn the given hex string into a color.

fun String.toColor(alpha: Float = 1.0f): PolyColor
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun PolyColor.toHex(alpha: Boolean = true, hash: Boolean = true): String
Link copied to clipboard

Return a static java Color object of this color at the instant this method is called.

Link copied to clipboard

Return a PolyUI compatible color object representative of this Java color object.

Link copied to clipboard
inline fun Double.toRadians(): Double
Link copied to clipboard
Link copied to clipboard
fun String.truncate(renderer: Renderer, font: Font, fontSize: Float, width: Float, limitText: String = "..."): String

Limit the given string to a width. If the string is too long, it will be cut to the width, and limitText will be appended to the end.

Link copied to clipboard
fun String.wrap(maxWidth: Float, renderer: Renderer, font: Font, fontSize: Float, lines: ArrayList<Line>?): ArrayList<Line>

Wrap the given text to the given width, inserting them into lines, or a new list is created if it is null. It also returned.