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.
  • Field Details

    • FILTER_MODE_NEAREST

      public static final int FILTER_MODE_NEAREST
      Single sample point (nearest neighbor).
      See Also:
    • FILTER_MODE_LINEAR

      public static final int FILTER_MODE_LINEAR
      Interpolate between 2x2 sample points (bilinear interpolation).
      See Also:
    • MIPMAP_MODE_NONE

      public static final int MIPMAP_MODE_NONE
      Ignore mipmap levels, sample from the "base".
      See Also:
    • MIPMAP_MODE_NEAREST

      public static final int MIPMAP_MODE_NEAREST
      Sample from the nearest level.
      See Also:
    • MIPMAP_MODE_LINEAR

      public static final int MIPMAP_MODE_LINEAR
      Interpolate between the two nearest levels.
      See Also:
    • 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