Package icyllis.modernui.graphics
Class ImageShader
java.lang.Object
icyllis.modernui.graphics.Shader
icyllis.modernui.graphics.ImageShader
Shader used to draw an image as a texture. The image can be repeated or
mirrored by setting the tiling mode.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic @interface
TheFilterMode
specifies the sampling method on transformed texture images.static @interface
TheMipmapMode
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
Modifier and TypeFieldDescriptionstatic final Object
Use bicubic sampling, the Catmull-Rom spline with B=0, C=0.5.static final Object
Use bicubic sampling, the cubic B-spline with B=1, C=0.static final Object
Use linear interpolation for minification, magnification; no mipmapping.static final Object
Use bicubic sampling, the Mitchell–Netravali filter with B=1/3, C=1/3.static final int
Interpolate between 2x2 sample points (bilinear interpolation).static final int
Single sample point (nearest neighbor).static final Object
Use bicubic sampling, the Photoshop bicubic filter with B=0, C=0.75.static final Object
Use nearest-neighbour sampling for minification, magnification; no mipmapping.static final int
Interpolate between the two nearest levels.static final int
Sample from the nearest level.static final int
Ignore mipmap levels, sample from the "base". -
Constructor Summary
ConstructorDescriptionImageShader
(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 TypeMethodDescriptionboolean
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.
-
Field Details
-
FILTER_MODE_NEAREST
public static final int FILTER_MODE_NEARESTSingle sample point (nearest neighbor).- See Also:
-
FILTER_MODE_LINEAR
public static final int FILTER_MODE_LINEARInterpolate between 2x2 sample points (bilinear interpolation).- See Also:
-
MIPMAP_MODE_NONE
public static final int MIPMAP_MODE_NONEIgnore mipmap levels, sample from the "base".- See Also:
-
MIPMAP_MODE_NEAREST
public static final int MIPMAP_MODE_NEARESTSample from the nearest level.- See Also:
-
MIPMAP_MODE_LINEAR
public static final int MIPMAP_MODE_LINEARInterpolate between the two nearest levels.- See Also:
-
FILTER_POINT
Use nearest-neighbour sampling for minification, magnification; no mipmapping. Also known as point sampling. -
FILTER_LINEAR
Use linear interpolation for minification, magnification; no mipmapping. Also known as triangle sampling and bilinear sampling. -
FILTER_CUBIC_BSPLINE
Use bicubic sampling, the cubic B-spline with B=1, C=0. -
FILTER_MITCHELL
Use bicubic sampling, the Mitchell–Netravali filter with B=1/3, C=1/3. -
FILTER_PHOTOSHOP_BICUBIC
Use bicubic sampling, the Photoshop bicubic filter with B=0, C=0.75. -
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 shadertileModeX
- the tiling mode on x-axis to draw the imagetileModeY
- the tiling mode on y-axis to draw the imagefilter
- the filter mode to draw the imagelocalMatrix
- 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 shadertileModeX
- the tiling mode on x-axis to draw the imagetileModeY
- the tiling mode on y-axis to draw the imagefilter
- the filter mode to draw the imagemipmap
- the mipmap mode to draw the imagelocalMatrix
- 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
andFILTER_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 shadertileModeX
- the tiling mode on x-axis to draw the imagetileModeY
- the tiling mode on y-axis to draw the imagefilter
- the filter to draw the imagelocalMatrix
- the local matrix, null means identity
-
-
Method Details
-
getLocalMatrix
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
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
-