FractalUtils - A collection of utility functions and classes, with an emphasis on game related utilities

Related tags

Utility fractalutils
Overview

Build Status Release

FractalUtils

A collection of utility functions and classes written in Kotlin.
There is some emphasis on utilities useful for games (Geometry, Random, Time, Updating, etc).

Has unit tests for some, but not all utilities.

May have breaking changes introduced between major versions.

License

Licensed under the GNU LGPL v3 license.

Including

A maven / gradle package of this library can be downloaded from jitpack:

Add jitpack.io as a repository (gradle):

repositories {
    ...
    maven { url 'https://jitpack.io' }
}

Add dependency:

dependencies {
    implementation 'com.github.fractalpixel:fractalutils:TAG'
}

Where TAG is the release to use (e.g. "v3.0.0", see tags in the sidebar or Release for latest release version).

Usage

Most classes and function have kotlin docs.

The utilities are grouped into packages with related functionality. The packages are:

checking

Contains the Check utility class, for checking function parameters and invariants, and throwing descriptive exceptions when the checks fail. E.g. Check.positiveOrZero(myParam, "myParam").

collections

Collection related utility functions and classes.

The RingBuffer is a fixed length buffer that can have values added or removed either to/from the beginning or end, dropping values when the buffer becomes full. It has fast implementations for various primitive types as well as a generic implementation.

The WeightedMap is a map where each value has some numerical weights, values can be randomly picked from it with a probability relative to their weight in the map.

file

Functions for things like saving a file reliably (using a temporary file and verifying it before replacing the previous version of a file), and recursively iterating files in a directory.

geometry

Contains 2 and 3 position double and integer vectors, as well as volumes and rectangles. Has immutable and mutable variants of each, and a common interface which is easy to implement.

Not as fast as vector classes could be, as inlining can't be used due to the polymorphism of immutable and mutable variants.

As opposed to most 3D library vectors, these are Double typed, so can work with larger ranges and smaller cumulative changes without errors.

interpolation

Contains a set of easing classes for creating various non-linear interpolations, a gradient class, as well as an interface for mixing functions / mixable values, that can be used with the easings or gradient to interpolate arbitrary user defined types or classes provided by other libraries.

logic

Contains a few utility extension functions such as .ifElse(valueIfTrue, valueIfFalse) and similar.

math

A large collection of utility functions and extension functions for doing common math.

Perhaps most notably the mix and map functions for mapping a value in a numerical range to another range (optionally applying an easing at the same time).

Also has various clamping, wrapping and rounding methods.

random

An interface for pseudorandom number generators with a lot of utility functions (e.g. getting a random entry from a collection), as well as a few implementations (XoroShiro etc). Motivated by the notable artifacts especially in low bits that are visible in the default Java Random implementation. XoroShiro and similar functions are also quite fast (but should of course not be used for generating secure random numbers).

Also includes an interface for hashing functions and an implementation.

resource

Utility for loading data from java resource files included in Jars.

service

Interface and base classes for components of an application that are initialized at application start and shutdown at application end, and that may need to access other such components of the application.

Allows encapsulating various functionality of an application into Services in a structured way, with some lifecycle and access support.

The main class of an application could extend or contain a DefaultServiceProvider, to which other services are added with addService(). Call init() to initialize all added services, and shutdown() to shut them down. getService(serviceType) returns the service with the specified type (allowing access to services by using interfaces if desired, further decoupling different services from each other).

stream

Stream related utility functions.

strings

A large set of utility and extension functions for working with strings, e.g. escaping, prefixing, etc.

Also contains an interface CodeBuilding for classes that can build some kind of code representation (usually e.g. an abstract syntax tree or nested nodes). Has utilities for handling indent and such.

symbol

Symbol is a utility class that represents the concept of a unique, named string identifier. Attempts to make comparing Symbols efficient (O(1)) (by keeping integer ids internally and using them for equality checks). Symbols can be useful e.g. as object identifiers and hashtable keys. Symbol names must conform to the Java identifier format.

thread

Thread related utilities, e.g. threadLocal, which is a utility function for creating thread local object instances in a more streamlined way than the standard Java syntax.

time

Interface and class for keeping track of time that advances in steps, e.g. in a simulation or game.
Contains utility functions for getting total elapsed seconds, or seconds in the last time step. Has various implementations, either where the time is manually advanced, or where the time reflects the system time.

TimeUtils.kt also has some utility functions for working with calendar time and timestamps (although using a dedicated library or the newer date API in Java for that purpose is recommended instead).

updating

Contains the Updating interface, for something that can be updated and is passed a Time with the current time. Also has various update strategies, e.g. for handling updates that simulate a fixed amount of time. Useful for game logic code or simulations.

Reporting Issues

Please report any bugs or feature requests to the issue tracker at: https://github.com/fractalpixel/fractalutils/issues

Pull requests for fixes are welcome too.

You might also like...
MMDUtils is a library for read/write mmd related file in java

MMDUtils MMDUtils is a library for read/write mmd related file in java Features Read/Write VMD(Vocaloid Motion Data) file Read/Write PMX(Polygon Model

Android Utilities Library build in kotlin Provide user 100 of pre defined method to create advanced native android app.

Android Utilities Library build in kotlin Provide user 100 of pre defined method to create advanced native android app.

Tool to look for several security related Android application vulnerabilities

Quick Android Review Kit This tool is designed to look for several security related Android application vulnerabilities, either in source code or pack

Little utilities for more pleasant immutable data in Kotlin
Little utilities for more pleasant immutable data in Kotlin

What can KopyKat do? Mutable copy Nested mutation Nested collections Mapping copyMap copy for sealed hierarchies copy from supertypes copy for type al

A support library for VectorDrawable and AnimatedVectorDrawable classes introduced in Lollipop

vector-compat A support library for VectorDrawable and AnimatedVectorDrawable introduced in Lollipop with fully backwards compatible tint support (api

A set of helper classes for using dagger 1 with Android components such as Applications, Activities, Fragments, BroadcastReceivers, and Services.

##fb-android-dagger A set of helper classes for using dagger with Android components such as Applications, Activities, Fragments, BroadcastReceivers,

Catch `dd`, `ddd`, `dump`, `sleep` and `ray` functions in your code

catch-debug-code Template ToDo list Create a new IntelliJ Platform Plugin Template project. Get familiar with the template documentation. Verify the p

Utility for detecting and notifying when your Android app goes background / becomes foreground

Foredroid Utility for detecting and notifying when your Android app goes background / becomes foreground. API-level 14+. Usage: Initialise Foreground

λRPC allows using code with high-order functions as a service
λRPC allows using code with high-order functions as a service

λRPC Simple native RPC with high order functions support. Inspired by @altavir and Communicator. λRPC allows using code with high-order functions as a

Owner
null
General purpose utilities and hash functions for Android and Java (aka java-common)

Essentials Essentials are a collection of general-purpose classes we found useful in many occasions. Beats standard Java API performance, e.g. LongHas

Markus Junginger 1.4k Dec 29, 2022
General purpose utilities and hash functions for Android and Java (aka java-common)

Essentials Essentials are a collection of general-purpose classes we found useful in many occasions. Beats standard Java API performance, e.g. LongHas

Markus Junginger 1.4k Dec 29, 2022
Collection of source codes, utilities, templates and snippets for Android development.

Android Templates and Utilities [DEPRECATED] Android Templates and Utilities are deprecated. I started with this project in 2012. Android ecosystem ha

Petr Nohejl 1.1k Nov 30, 2022
Utility library that utilizes KSP to generate Room type converter classes.

Roomie Roomie is an annotation processing library that utilizes KSP to geaRoomie is an annotation processing library that utilizes KSP to generate TypeConverter classes for Room. TypeConverter classes most often involve same boiler-plate code and Roomie makes it really easy to quickly create them with a single annotation.nerate TypeConverter classes for Room. TypeConverter classes most often invol

Chukwuka Eze 12 Aug 26, 2022
CreditCardHelper 🖊️ A Jetpack-Compose library providing useful credit card utilities such as card type recognition and TextField ViewTransformations

CreditCardHelper ??️ A Jetpack-Compose library providing useful credit card utilities such as card type recognition and TextField ViewTransformations

Stelios Papamichail 18 Dec 19, 2022
Utilities I wish Android had but doesn't

wishlist Library of helpers and utilities that I wish were included in the Android SDK but aren't. If you think something in this library is already h

Kevin Sawicki 386 Nov 21, 2022
Various useful utilities for Android apps development

Android Commons Various useful utilities for Android apps development. API documentation provided as Javadoc. Usage Add dependency to your build.gradl

Alex Vasilkov 112 Nov 14, 2022
Android library that regroup bunch of dateTime utilities

DateTimeUtils This library is a package of functions that let you manipulate objects and or java date string. it combine the most common functions use

Thunder413 98 Nov 16, 2022
A Telegram bot utilities that help to reduce the code amount

Flume Party A Telegram bot utilities that help to reduce code amount. Real project examples Pull Party Bot: 19% of code has been reduced. Resistance B

pool party 1 Jun 8, 2022