Package icyllis.modernui.graphics

# Class ImageShader

java.lang.Object
icyllis.modernui.graphics.Shader
icyllis.modernui.graphics.ImageShader

public class ImageShader extends Shader
Shader used to draw an image as a texture. The image can be repeated or mirrored by setting the tiling mode.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static @interface`
  `ImageShader.FilterMode`
  The `FilterMode` specifies the sampling method on transformed texture images.
  `static @interface`
  `ImageShader.MipmapMode`
  The `MipmapMode` specifies the interpolation method for MIP image levels when down-sampling texture images.

  ## Nested classes/interfaces inherited from class icyllis.modernui.graphics.Shader

  `Shader.TileMode`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final Object`
  `FILTER_CATMULLROM`
  Use bicubic sampling, the Catmull-Rom spline with B=0, C=0.5.
  `static final Object`
  `FILTER_CUBIC_BSPLINE`
  Use bicubic sampling, the cubic B-spline with B=1, C=0.
  `static final Object`
  `FILTER_LINEAR`
  Use linear interpolation for minification, magnification; no mipmapping.
  `static final Object`
  `FILTER_MITCHELL`
  Use bicubic sampling, the Mitchell–Netravali filter with B=1/3, C=1/3.
  `static final int`
  `FILTER_MODE_LINEAR`
  Interpolate between 2x2 sample points (bilinear interpolation).
  `static final int`
  `FILTER_MODE_NEAREST`
  Single sample point (nearest neighbor).
  `static final Object`
  `FILTER_PHOTOSHOP_BICUBIC`
  Use bicubic sampling, the Photoshop bicubic filter with B=0, C=0.75.
  `static final Object`
  `FILTER_POINT`
  Use nearest-neighbour sampling for minification, magnification; no mipmapping.
  `static final int`
  `MIPMAP_MODE_LINEAR`
  Interpolate between the two nearest levels.
  `static final int`
  `MIPMAP_MODE_NEAREST`
  Sample from the nearest level.
  `static final int`
  `MIPMAP_MODE_NONE`
  Ignore mipmap levels, sample from the "base".

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ImageShader(Image image, Shader.TileMode tileModeX, Shader.TileMode tileModeY, int filter, int mipmap, Matrix localMatrix)`
  Create a new shader for the given image.
  `ImageShader(Image image, Shader.TileMode tileModeX, Shader.TileMode tileModeY, int filter, Matrix localMatrix)`
  Create a new shader for the given image.
  `ImageShader(Image image, Shader.TileMode tileModeX, Shader.TileMode tileModeY, Object filter, Matrix localMatrix)`
  Create a new shader for the given image.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `getLocalMatrix(Matrix localMatrix)`
  Return true if the shader has a non-identity local matrix.
  `boolean`
  `localMatrixEquals(Matrix localMatrix)`
  Return true if the local matrix of the shader is equal to the given local matrix.

  ### Methods inherited from class icyllis.modernui.graphics.Shader

  `release`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### FILTER_MODE_NEAREST

    public static final int FILTER_MODE_NEAREST
    Single sample point (nearest neighbor).
    See Also:
      - Constant Field Values

  - ### FILTER_MODE_LINEAR

    public static final int FILTER_MODE_LINEAR
    Interpolate between 2x2 sample points (bilinear interpolation).
    See Also:
      - Constant Field Values

  - ### MIPMAP_MODE_NONE

    public static final int MIPMAP_MODE_NONE
    Ignore mipmap levels, sample from the "base".
    See Also:
      - Constant Field Values

  - ### MIPMAP_MODE_NEAREST

    public static final int MIPMAP_MODE_NEAREST
    Sample from the nearest level.
    See Also:
      - Constant Field Values

  - ### MIPMAP_MODE_LINEAR

    public static final int MIPMAP_MODE_LINEAR
    Interpolate between the two nearest levels.
    See Also:
      - Constant Field Values

  - ### FILTER_POINT

    public static final Object FILTER_POINT
    Use nearest-neighbour sampling for minification, magnification; no mipmapping. Also known as point sampling.

  - ### FILTER_LINEAR

    public static final Object FILTER_LINEAR
    Use linear interpolation for minification, magnification; no mipmapping. Also known as triangle sampling and bilinear sampling.

  - ### FILTER_CUBIC_BSPLINE

    public static final Object FILTER_CUBIC_BSPLINE
    Use bicubic sampling, the cubic B-spline with B=1, C=0.

  - ### FILTER_MITCHELL

    public static final Object FILTER_MITCHELL
    Use bicubic sampling, the Mitchell–Netravali filter with B=1/3, C=1/3.

  - ### FILTER_PHOTOSHOP_BICUBIC

    public static final Object FILTER_PHOTOSHOP_BICUBIC
    Use bicubic sampling, the Photoshop bicubic filter with B=0, C=0.75.

  - ### FILTER_CATMULLROM

    public static final Object FILTER_CATMULLROM
    Use bicubic sampling, the Catmull-Rom spline with B=0, C=0.5.

- ## Constructor Details

  - ### ImageShader

    public ImageShader(@NonNull Image image, @NonNull Shader.TileMode tileModeX, @NonNull Shader.TileMode tileModeY, int filter, @Nullable Matrix localMatrix)
    Create a new shader for the given image.

    If local matrix is not null, then it transforms image's local coordinates to geometry's local coordinates.

    Parameters:
      `image` - the image to use inside the shader
      `tileModeX` - the tiling mode on x-axis to draw the image
      `tileModeY` - the tiling mode on y-axis to draw the image
      `filter` - the filter mode to draw the image
      `localMatrix` - the local matrix, null means identity

  - ### ImageShader

    public ImageShader(@NonNull Image image, @NonNull Shader.TileMode tileModeX, @NonNull Shader.TileMode tileModeY, int filter, int mipmap, @Nullable Matrix localMatrix)
    Create a new shader for the given image.

    If the image has no mipmaps, then mipmap mode will be ignored when drawing.

    If local matrix is not null, then it transforms image's local coordinates to geometry's local coordinates.

    Parameters:
      `image` - the image to use inside the shader
      `tileModeX` - the tiling mode on x-axis to draw the image
      `tileModeY` - the tiling mode on y-axis to draw the image
      `filter` - the filter mode to draw the image
      `mipmap` - the mipmap mode to draw the image
      `localMatrix` - the local matrix, null means identity

  - ### ImageShader

    public ImageShader(@NonNull Image image, @NonNull Shader.TileMode tileModeX, @NonNull Shader.TileMode tileModeY, @NonNull Object filter, @Nullable Matrix localMatrix)
    Create a new shader for the given image.

    The filter must be one of constants in this class, which are `FILTER_POINT`, `FILTER_LINEAR`, `FILTER_CUBIC_BSPLINE`, `FILTER_MITCHELL`, `FILTER_PHOTOSHOP_BICUBIC` and `FILTER_CATMULLROM`.

    If local matrix is not null, then it transforms image's local coordinates to geometry's local coordinates.

    Parameters:
      `image` - the image to use inside the shader
      `tileModeX` - the tiling mode on x-axis to draw the image
      `tileModeY` - the tiling mode on y-axis to draw the image
      `filter` - the filter to draw the image
      `localMatrix` - the local matrix, null means identity

- ## Method Details

  - ### getLocalMatrix

    public boolean getLocalMatrix(@NonNull Matrix localMatrix)
    Return true if the shader has a non-identity local matrix.
    Parameters:
      `localMatrix` - Set to the local matrix of the shader, if the shader's matrix is non-null.
    Returns:
      true if the shader has a non-identity local matrix

  - ### localMatrixEquals

    public boolean localMatrixEquals(@Nullable Matrix localMatrix)
    Return true if the local matrix of the shader is equal to the given local matrix.
    Parameters:
      `localMatrix` - the local matrix to compare, null means identity
    Returns:
      true if local matrix equals