Package arc.util

Enum Class Scaling

All Implemented Interfaces:
Serializable, Comparable<Scaling>, Constable

public enum Scaling extends Enum<Scaling>
Various scaling types for fitting one rectangle into another.
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Scales the source to fit the target if it is larger, otherwise does not scale.
    Scales the source to fill the target while keeping the same aspect ratio.
    Scales the source to fill the target in the x direction while keeping the same aspect ratio.
    Scales the source to fill the target in the y direction while keeping the same aspect ratio.
    Scales the source to fit the target while keeping the same aspect ratio.
    The source is not scaled.
    Scales the source to fill the target.
    Scales the source to fill the target in the x direction, without changing the y direction.
    Scales the source to fill the target in the y direction, without changing the x direction.
  • Method Summary

    Modifier and Type
    Method
    Description
    apply(float sourceWidth, float sourceHeight, float targetWidth, float targetHeight)
    Returns the size of the source scaled to the target.
    static Scaling
    Returns the enum constant of this class with the specified name.
    static Scaling[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • fit

      public static final Scaling fit
      Scales the source to fit the target while keeping the same aspect ratio. This may cause the source to be smaller than the target in one direction.
    • bounded

      public static final Scaling bounded
      Scales the source to fit the target if it is larger, otherwise does not scale.
    • fill

      public static final Scaling fill
      Scales the source to fill the target while keeping the same aspect ratio. This may cause the source to be larger than the target in one direction.
    • fillX

      public static final Scaling fillX
      Scales the source to fill the target in the x direction while keeping the same aspect ratio. This may cause the source to be smaller or larger than the target in the y direction.
    • fillY

      public static final Scaling fillY
      Scales the source to fill the target in the y direction while keeping the same aspect ratio. This may cause the source to be smaller or larger than the target in the x direction.
    • stretch

      public static final Scaling stretch
      Scales the source to fill the target. This may cause the source to not keep the same aspect ratio.
    • stretchX

      public static final Scaling stretchX
      Scales the source to fill the target in the x direction, without changing the y direction. This may cause the source to not keep the same aspect ratio.
    • stretchY

      public static final Scaling stretchY
      Scales the source to fill the target in the y direction, without changing the x direction. This may cause the source to not keep the same aspect ratio.
    • none

      public static final Scaling none
      The source is not scaled.
  • Method Details

    • values

      public static Scaling[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Scaling valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • apply

      public Vec2 apply(float sourceWidth, float sourceHeight, float targetWidth, float targetHeight)
      Returns the size of the source scaled to the target. Note the same Vec2 instance is always returned and should never be cached.