Texture

open class Texture

The Texture class stores the textures used for rendering, which are loaded from local images,and provides some methods for rotating this texture, and the ability of using caches to optimize the rendering performance. It uses TextureOp for rendering, you can implement your TextureOp, or just use the provided method to allocate the instances.

Provided TextureOp Methods

namereturn typeinstructions
rotateRotateOpProvides TextureOp can be used for rotating the texture around its center point.
averageConvolveConvolveOpProvides convolution filters that can remove the image noise of this texture.
averageConvolve33Convolve33OpProvides convolution filters that can remove the image noise of this texture, but with a 3 * 3 convolution kernel.
gaussianBlurConvolveConvolveOpProvides a convolution filter that can perform Gaussian blur processing on textures and with its convolution kernel follows a two-dimensional Gaussian distribution.
gaussianBlurConvolve33Convolve33OpProvides a convolution filter that can perform Gaussian blur processing on textures and with its convolution kernel which is in the size of 3 * 3, follows a two-dimensional Gaussian distribution.
sharpenConvolveConvolveOpProvides a convolution filter that can sharpen the texture.
strokeConvolveConvolveOpProvides a convolution filter that can stroke the texture.

Also, this class uses some method in top.kkoishi.stg.util.Mth to calculate, which will cache the results to optimize the performance of math calculation. And you can use Texture.renderPoint methods to calculate the right coordinates for rendering which make sure that the center of the texture will be rendered at the given coordinates.

There is a subclass using VRAM for rendering, Texture.Volatile, and it has the better hardware acceleration possibilities.

Author

KKoishi_

Inheritors

Types

Link copied to clipboard
abstract class AffineTextureOp(xform: AffineTransform, interpolationType: Int) : AffineTransformOp, Texture.TextureOp
Link copied to clipboard
object Companion
Link copied to clipboard
open class ConvolveOp(kernelData: FloatArray, length: Int) : Texture.TextureOp

This class implements a convolution from the source texture to the destination texture. Convolution using a convolution kernel is a spatial operation that computes the output pixel from an input pixel by multiplying the kernel with the surround of the input pixel. This allows the output pixel to be affected by the immediate neighborhood in a way that can be mathematically specified with a kernel, and the kernel size is length * length by passing in a float array with the length of length ^ 2.

Link copied to clipboard
interface TextureOp

An filiter/transform used for image processing.

Link copied to clipboard
class Volatile(texture: BufferedImage, val name: String = "") : Texture

A texture class using VolatileImage.

Properties

Link copied to clipboard
val height: Int

The height of the Texture.

Link copied to clipboard
Link copied to clipboard
val width: Int

The width of the Texture.

Functions

Link copied to clipboard

Return an instance of TextureOp which implements a convolution from the source texture to the destination texture with the ability removing the image noise of this texture.

Link copied to clipboard

Return an instance of TextureOp which implements a convolution from the source texture to the destination texture with the ability removing the image noise of this texture., and the kernel is a 3 * 3 matrix.

Link copied to clipboard

Return an instance of TextureOp which implements a convolution from the source texture to the destination texture. Convolution using a convolution kernel is a spatial operation that computes the output pixel from an input pixel by multiplying the kernel with the surround of the input pixel. This allows the output pixel to be affected by the immediate neighborhood in a way that can be mathematically specified with a kernel, and the kernel size is 3 * 3 by passing in a float array with the length of 9.

Link copied to clipboard
open fun cut(x: Int, y: Int, w: Int, h: Int, name: String = ""): Texture

Returns a sub-texture defined by a specified rectangular region. The returned Texture shares the same data array as the original.

Link copied to clipboard

Return an instance of TextureOp which implements a convolution from the source texture to the destination texture provided a Gaussian blur effect for textures, and its convolve kernel conforms to the Gaussian distribution with sum of 1, and the kernel is a 3 * 3 matrix, and the length should be odd.

Link copied to clipboard

Return an instance of TextureOp which implements a convolution from the source texture to the destination texture provided a Gaussian blur effect for textures, and its convolve kernel conforms to the Gaussian distribution with sum of 1, and the kernel is a 3 * 3 matrix.

Link copied to clipboard
operator fun invoke(): BufferedImage

Get the texture.

Link copied to clipboard

Returns a Texture operation without any change. The matrix is:

Link copied to clipboard
open fun paint(r: Graphics2D, op: Texture.TextureOp, x: Int, y: Int)

Renders a Texture that is filtered with a BufferedImageOp. The rendering attributes applied to include the Clip, Transform and Composite attributes.

Link copied to clipboard

Calculate and return the correct rendering coordinate, which can make the texture's center coincides with the given point specified by its coordinates.

fun renderPoint(x: Int, y: Int, rad: Double): Point
fun renderPoint(x: Int, y: Int, sin: Double, cos: Double): Point

Calculate and return the correct rendering coordinate, which can make center of the rotated texture, the rotate degree is specified in parameters, coincides with the given point specified by its coordinates.

Link copied to clipboard

Returns a TextureOp that can be used to rotate the texture.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun toString(): String