Giter VIP home page Giter VIP logo

jregions's Introduction

jregions

Maven Central Maven Central (snapshot) Codecov Java Version

com.io7m.jregions

JVM Platform Status
OpenJDK (Temurin) Current Linux Build (OpenJDK (Temurin) Current, Linux)
OpenJDK (Temurin) LTS Linux Build (OpenJDK (Temurin) LTS, Linux)
OpenJDK (Temurin) Current Windows Build (OpenJDK (Temurin) Current, Windows)
OpenJDK (Temurin) LTS Windows Build (OpenJDK (Temurin) LTS, Windows)

jregions

The jregions package provides a set of immutable area types specialized to most of the Java numeric types. The area types come with an extensive set of functions for aligning and moving areas.

Features

  • Extensive set of functions for scaling, aligning, moving boxes.
  • Written in pure Java 21.
  • High coverage test suite.
  • OSGi-ready
  • JPMS-ready
  • ISC license.

jregions's People

Contributors

io7m avatar dependabot[bot] avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar  avatar

jregions's Issues

Overlaps() is incorrect

Right now, an area {minimumX=0, maximumX=10, minimumY=0, maximumY=10} is considered to overlap an area {minimumX=10, maximumX=20, minimumY=10, maximumY=20}. This is incorrect! maximumX and maximumY are exclusive upper bounds.

Add clamping

The clamp function ensures that the minimums and maximums of a region are always less than and greater than those of another region.

Replace generators with jqwik

We're using jqwik in projects now, instead of the unmaintained Java quickcheck.

Convert the generators to jqwik arbitraries.

Stop using terms like width and height

This ascribes meaning to axes that programmers using jregions may not be using.

width -> sizeX
height -> sizeY
depth -> sizeZ

Removes any possibility of ambiguity.

Extract a common "values" area type

APIs such as jcanephora need to be able to work with area types regardless of whether the concrete implementation is a PArea or plain Area. In other words, right now an API such as jcanephora will end up forcing the user to use either PAreas or Areas even though the types are functionally identical.

Upgrade to junit 5

Most of the unit tests are generated anyway, so it's just a matter of using the newer annotations and the Assertions class.

Add moveRelativeClamped()

We currently have:

  /**
   * Move the given area by {@code (x, y)}.
   *
   * @param area The area
   * @param x    The amount to move on the X axis
   * @param y    The amount to move on the Y axis
   * @param <S>  The coordinate space of the area
   *
   * @return A moved area
   */

  public static <S> PAreaD<S> moveRelative(
    final PAreaD<S> area,
    final double x,
    final double y)
  {

I'd like a:

  /**
   * Move the given area by {@code (x, y)}, without allowing {@code area} to leave {@code container}.
   *
   * @param area The area
   * @param container The container area
   * @param x    The amount to move on the X axis
   * @param y    The amount to move on the Y axis
   * @param <S>  The coordinate space of the area
   *
   * @return A moved area
   */

  public static <S> PAreaD<S> moveRelativeClamped(
    final PAreaD<S> area,
    final PAreaD<S> container,
    final double x,
    final double y)
  {

If container doesn't contain area, the function throws PreconditionViolationException. The function
maintains the invariants:

  • ∀ a b x y. contains(b, a) = contains(b, moveRelativeClamped(a, b, x, y)).
  • ∀ a b x y. size(a) = size(moveRelativeClamped(a, b, x, y)).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.