Most standard Lua libraries are available, and there are several non-standard functions and global variables I added to help out. These are detailed below. Note that most functions expect a color in the format of a table [r,g,b,a] where the properties range 0-1, NOT 0-255.
Function/Variable
|
Description
|
GetPixel(UVX,UVY,ImageIndex,OverFlowOption)
|
Returns the color of the specified pixel. [r,g,b,a]. Where UVX is the location of the pixel on the x-plane. This is UV coordinates though, so 0-1. UVY is the location of the pixel to sample on the y-plane, also in UV coordinates. ImageIndex is the index of the image you want to sample from. Lua starts arrays at 1, so your first image is 1, and every other image increments upward. Lastly, OverFlowOption controls how the function acts if you try and sample outside the 0-1 range. There are several global variables to help with this explained in more detail below.
|
Overflow_Loop
|
Global variable to define the OverFlow option when using GetPixel. In this case, if you try and sample outside the image (range 0 through 1), it will loop back to the other side of the image. (Example: Trying to sample 1.1 will return the pixel at 0.1)
|
Overflow_Edge
|
Global variable to define the OverFlow option when using GetPixel. In this case, if you try and sample outside the image (range 0 through 1), it will clamp your value so you always sample the nearest edge. (Example: Trying to sample 1.1 will return the pixel at 1)
|
Overflow_Stop
|
Global variable to define the OverFlow option when using GetPixel. In this case, if you try and sample outside the image (range 0 through 1), it will always return a solid black.
|
Overflow_Transparent
|
Global variable to define the OverFlow option when using GetPixel. In this case, if you try and sample outside the image (range 0 through 1), it will always return a transparent color.
|
ImageWidth
|
Global variable that returns the width of the final image to be drawn as you selected in the form.
|
ImageHeight
|
Global variable that returns the height of the final image to be drawn as you selected in the form.
|
NewColor(r, g, b, a)
|
Returns a new table to use as a color as [r,g,b,a] where r,g,b,a are in the range of 0-1
|
NewColorFromClassicRGB(r,g,b,a)
|
Returns a new table to use as a color as [r,g,b,a], however this will divide each parameter by 255 to bring a color from a classic range of 0-255 to the UV range of 0-1
|
Add(A, B)
|
Adds two color tables together [r,g,b,a] + [r,g,b,a] = [r,g,b,a]
|
Subtract(A, B)
|
Subtracts two color tables [r,g,b,a] - [r,g,b,a] = [r,g,b,a]
|
Dot(A, B)
|
Returns the dot product two color tables together [r,g,b,a] · [r,g,b,a] = [r,g,b,a]
|
Mod(a, b)
|
Returns the modulus of two a by b. a % b = c
|
Round(num, numDecimalPlaces)
|
Returns the rounded num by numDecimalPlaces
|
Min(A, B, C)
|
Returns the lowest number from a set of 3
|
Max(A, B, C)
|
Returns the largest number from a set of 3
|
RGBtoHSV(A)
|
Converts a color table A to HSV format. This will still return a color table as [r,g,b,a], but r = Hue, g = Saturation, b = Value, a=alpha
|
HSVtoRGB(A)
|
Converts a color table to RGB format. This will return a standard color table [r,g,b,a]
|
ProcessPass(x,y,uvx,uvy)
|
This is the function you must provide. This function will run once for each pixel in your output image. Where the parameters are the x and y of the pixel currently being considered, range of 0 to output width and height, uvx and uvy which is the uv coordinates of the pixel being considered, range of 0-1. It can be used to sample other images, do math, and finally return a color for your new output image. The output must be a single RGB color in a table as in [r,g,b,a] where r,g,b,a are in a range of 0-1.
|