libgdx API

com.badlogic.gdx.utils
Enum Scaling

java.lang.Object
  extended by java.lang.Enum<Scaling>
      extended by com.badlogic.gdx.utils.Scaling
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Scaling>

public enum Scaling
extends java.lang.Enum<Scaling>

Various scaling types for fitting one rectangle into another.

Author:
Nathan Sweet

Enum Constant Summary
fill
          Scales the source to fill the target while keeping the same aspect ratio.
fillX
          Scales the source to fill the target in the x direction while keeping the same aspect ratio.
fillY
          Scales the source to fill the target in the y direction while keeping the same aspect ratio.
fit
          Scales the source to fit the target while keeping the same aspect ratio.
none
          The source is not scaled.
stretch
          Scales the source to fill the target.
stretchX
          Scales the source to fill the target in the x direction, without changing the y direction.
stretchY
          Scales the source to fill the target in the y direction, without changing the x direction.
 
Method Summary
 Vector2 apply(float sourceWidth, float sourceHeight, float targetWidth, float targetHeight)
          Returns the size of the source scaled to the target.
static Scaling valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static Scaling[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

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.


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 Detail

values

public static Scaling[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (Scaling c : Scaling.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static Scaling valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

apply

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


libgdx API

Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)