File builtin/vn/imagefx.lua

imagefx.lua Provides the 'built-in' VN image manipulation functions.

Functions

applyColorMatrix (t, rf, gf, bf, af) Creates a copy of the given texture, with a color matrix applied.
blur (t, kernelSize, borderExtend, cropResult) Creates a blurred copy of a texture
blurMultiple (t, levels, kernelSize, borderExtend) Creates a collection of progressively more blurred copies of a single image.
brighten (t, add) Creates a brightened copy of a texture
composite (args, w, h) Creates a new texture by blending together multiple source textures.
crop (t, x, y, w, h) Creates a cropped copy of the given texture
mipmap (t, level) Creates a copy of the given texture downscaled by a factor 2level.


Functions

applyColorMatrix (t, rf, gf, bf, af)
Creates a copy of the given texture, with a color matrix applied. Pseudocode:
r' = rf[1]*r + rf[2]*g + rf[3]*b + rf[4]*a + rf[5]
This assumes non-permultiplied color and color values ranging between 0.0 and 1.0.

Parameters:

  • t: The source texture
  • rf: A table containing the multiplication factors for the red channel.
  • gf: A table containing the multiplication factors for the green channel.
  • bf: A table containing the multiplication factors for the blue channel.
  • af: A table containing the multiplication factors for the alpha channel.

Return value:

    A new texture with the color matrix applied.
blur (t, kernelSize, borderExtend, cropResult)
Creates a blurred copy of a texture

Parameters:

  • t: The texture to create a blurred copy of
  • kernelSize: Determines the size of the blur kernel
  • borderExtend: Use true to pad the expanded image area with the image's border pixels, or false to pad with transparent pixels.
    You can also use an integer to only extend in certain directions, each digit corresponds to a numpad direction (example: 268 is bottom-right-top).
  • cropResult: Use true to crop the result texture to the same size as tex, otherwise the result texture will be padded on each side equal to half the size of the blur kernel. You can also use an integer to only crop in certain directions, each digit corresponds to a numpad direction (example: 486 is left-top-right).

Return value:

    A blurred copy of the input texture
blurMultiple (t, levels, kernelSize, borderExtend)
Creates a collection of progressively more blurred copies of a single image.

Parameters:

  • t: The texture to create blurred copies of
  • levels: The number of blur images to generate
  • kernelSize: Determines the size of the blur kernel
  • borderExtend: Use true to pad the expanded image area with the image's border pixels, or false to pad with transparent pixels.
    You can also use an integer to only extend in certain directions, each digit corresponds to a numpad direction (example: 268 is bottom-right-top).

Return value:

    A table containing the blurred copies.

See also:

brighten (t, add)
Creates a brightened copy of a texture

Parameters:

  • t: The texture to create a brightened copy of
  • add: A fraction between -1.0 and 1.0 that will be added to the color components of the input texture.

Return value:

    A brightened copy of the input texture
composite (args, w, h)
Creates a new texture by blending together multiple source textures.

Parameters:

  • args: A table of the form:
    { {tex=myTexture1}, {tex=myTexture2, pos={10, 10}} {tex=myTexture3} }

    The pos field is optional and assumed {0, 0} when omitted.
  • w: Width of the output texture
  • h: Height of the output texture

Return value:

    A new texture composed of all the argument textures blended together.
crop (t, x, y, w, h)
Creates a cropped copy of the given texture

Parameters:

  • t: The source texture
  • x: The top-left x-coordinate of the crop rectangle.
  • y: The top-left y-coordinate of the crop rectangle.
  • w: The crop rectangle's width.
  • h: The crop rectangle's height.

Return value:

    A new texture created from the specified pixels in the source texture.
mipmap (t, level)
Creates a copy of the given texture downscaled by a factor 2level.

Parameters:

  • t: The texture to create a downscaled copy of
  • level: The mipmap level

Return value:

    A new, downscaled texture.

Valid XHTML 1.0!