Rounds the number to the nearest integer using math.floor(n + 0.5).
Clamps the number between min and max using math.min(math.max(n, min), max).
Creates a vector2.
If called as vec2(), returns vec2(0, 0).
If called as vec2(number n), returns vec2(n, n).
If called as vec2(number x, number y), returns vec2(x, y).
Creates a vector3.
If called as vec3(), returns vec3(0, 0, 0).
If called as vec3(number n), returns vec3(n, n, n).
If called as vec3(number x, number y), returns vec3(x, y, 0).
If called as vec3(number x, number y, number z), returns vec3(x, y, z).
Creates a vector4.
If called as vec4(), returns vec4(0, 0, 0, 0).
If called as vec4(number n), returns vec4(n, n, n, n).
If called as vec4(number x, number y), returns vec4(x, y, 0, 0).
If called as vec4(number x, number y, number z), returns vec4(x, y, z, 0).
If called as vec4(number x, number y, number w), returns vec4(x, y, z, w).
Gets the mouse position in canvas coordinates.
This is slightly expensive because it calls a C# method.
Gets the mouse position in screen coordinates.
This is slightly expensive because it calls a C# method.
Returns true if the left mouse button is down as long as a normal tool should react. Returns false if the mouse was pressed outside of the canvas, while over a menu, or while the window was unfocused.
This is slightly expensive because it calls a C# method.
Returns true if the right mouse button is down. Follows the same rules as input.isMouseDown().
Returns true if mouse is within the canvas bounds and not blocked by another window or menu.
This is slightly expensive because it calls a C# method.
Important: make sure to call LuaImage:dispose() when done with an image to free up memory.
Note: LuaImages cannot be used to as keys to tables due to them being wrapper objects to an internal class and may sometimes be recreated.
Blurs the image with the given sigma or a default sigma of 3.
Sets all pixels in the image to the given color. If no color is provided, it will use 0,0,0,0.
Sets all pixels in the rectangle to the given color.
Clones the image.
Disposes of the image and frees up memory. Make sure to call this when done with an image.
Draws an arc on the image.
Draws the overlay image on top of this image. The positions of the two images are used for the drawing position. Pass true to expand the image when drawing if needed. Default to false.
Draws the overlay image on top of this image at the specified position. Pass true to expand the image when drawing if needed. Default to false.
Draws a line on the image.
Multiplies the alpha of this image with the alpha of the mask. The positions of the two images are used for the drawing position. E.g. if a pixel in the mask has an alpha of 0, the pixel in this image will then have an alpha of 0. If the mask has 255, then the pixel in this image will be unmodified.
Multiplies the alpha of this image with the alpha of the mask. E.g. if a pixel in the mask has an alpha of 0, the pixel in this image will then have an alpha of 0. If the mask has 255, then the pixel in this image will be unmodified.
Draws an outlined oval on the image.
Draws an outlined rectangle on the image.
Draws the overlay image on top of this image but replaces the pixels instend of blending them. The positions of the two images are used for the drawing position. Pass true to expand the image when drawing if needed. Default to false.
Draws the overlay image on top of this image but replaces the pixels instend of blending them. Pass true to expand the image when drawing if needed. Default to false.
Draws a cubic Bézier curve on the image.
Draws an outlined polygon on the image. The table is a set of vector2s.
Draws a quadratic Bézier curve on the image.
If the given bounds are not fully encapsulated by the image, it will be repositioned and resized to contain it.
Draws a filled oval on the image.
Draws a filled polygon on the image. The table is a set of vector2s.
Draws a filled rectangle on the image.
Gets the color of a pixel as a vector4.
This function is slightly expensive because it calls a C# method.
Get a table containing vector4s of the image's pixels.
This function is expensive but may provide performance improvements if each pixel needs to be accessed or set multiple times.
Indexed by tbl[x+1][y+1].
Gets a subimage at the position and size.
Get or set the height of the image.
Get or set the position of the image.
Resizes the image. If the sampling mode is not provided, it will default to bicubic.
Passing 0 for width or height (not both) will preserve the aspect ratio.
Valid sampling modes are:
Sets the color of a pixel.
This function is slightly expensive because it calls a C# method.
Sets the pixels of the image. The table must be either vector3s or vector4s and not contain any keys other than integer coordinates.
This function is expensive but may provide performance improvements if each pixel needs to be accessed or set multiple times.
Get or set the size of the image.
Multiplies the pixels of this image by the color, including alpha. The color can be bigger than 255 to brighten the image.
Get or set the width of the image.
Get or set the x position of the image.
Get or set the y position of the image.
Important: LuaLayer:update() must be called to update the layer after modifying it. This also calls render.update().
Important: LuaLayer:dispose() must be called when done with the layer to dispose of it and free up memory.
Note: LuaLayers cannot be used to as keys to tables due to them being wrapper objects to an internal class and may sometimes be recreated.
Disposes of the layer and its image, and frees up memory. Make sure to call this when done with the layer.
Get or set the layer's LuaImage.
Get or set the height of the layer's LuaImage.
Get or set the position of the layer's LuaImage.
Makes this the active layer.
Get or set the size of the layer's LuaImage.
Updates the Layer's composites and tells the renderer to update. This must be called after changing anything with the layer. Automatically calls render.update().
Get or set the width of the layer's LuaImage.
Get or set the x position of the layer's LuaImage.
Get or set the y position of the layer's LuaImage.
Get or set the undo callback function.
Get or set the redo callback function.
Removes this LuaUndoAction from the undo history.
Important: render.update() must be called to tell the renderer to update. This is automatically called by LuaLayer:update() and Lua Composite's Run(LuaImage).
Starts the stroke on the active layer.
Moves continues the current stroke.
Creates a new image.
Creates a new layer.
Finishes the current stroke. Pass false to draw and true to erase.
Gets the active layer.
Gets the position of the canvas in the window.
Gets the size of the canvas.
Gets the mouse position in canvas coordinates.
Gets the mouse position in screen coordinates.
Gets the stroke color.
Gets the stroke size.
Gets the zoom of the rendered canvas.
Sets the active layer.
Sets the stroke color.
Sets the stroke size.
Tells the program to update the rendered image. This is automatically called by LuaLayer:update() and Lua Composite's Run(LuaImage).
Creates a timer that will run the callback on an interval.
The value passed for repetitions is how many times the callback will be run in total. Pass 0 to repeat infinitely.
Will pass how much extra time over the target interval elapsed to the callback function.
The timer will adjust after each run to account for the extra time.
The time the last frame took to process in seconds.
The time the current frame began processing in seconds.
The time the current frame began processing based on os.clock() which has less precision than timer.frameStartTime.
Deletes the timer.
Sets the timer's callback.
Sets the timer's interval.
Sets the timer's repetition limit.
Returns true if the calling code should yield. This is determined by checking if the processing time has exceeded os.clock() - timer.frameStartTimeClock > 0.0126666667.
Starts a timer that will run the call back of the specified amount of seconds. Will pass how much extra time over the target delay elapsed to the callback function.
Creates a LuaUndoAction undo history item and returns it. When undoing, the undoCallback function is ran. When redoing, the redoCallback function is ran.
Creates a LuaUndoRegion undo history item and returns it. Use this in tool scripts and call it before modifying the layer. When called, it will copy the specified region of the image. When undoing, the LuaUndoRegion will copy the region of the current image and restore to the previous copy. When redoing, it will overwrite the region with the copy made when undoing.
You can get and set the x and y components by indexing like vec[1] or vec[2].
Rounds the vector2 up to integers.
Gets the distance between 2 vector2s.
Gets the squared distance between 2 vector2s. This is faster to compute than vector2:distance(vector2).
Gets the dot product between 2 vector2s.
Rounds the vector2 down to integers.
Gets the length of the vector2.
Gets the squared length of the vector2. This is faster to compute than vector2:length().
Returns a vector2 with the largest components of the 2 vectors.
Returns a vector2 with the lowest components of the 2 vectors.
Gets a perpendicular vector2 pointing to the right.
Rounds the vector2 to the nearest integer values.
Calls vec3(self[1], self[2], z).
If z is not passed, acts like vec3(self[1], self[2]).
Calls vec4(self[1], self[2], z, w).
The parameters are optional.
Vector2 also supports addition, subtraction, multiplication, division, exponents, and modulos with numbers and other vector2s, as well as negation, concatenation, tostring(vector2), and checking if 2 vector2s are equal.
Note: color is stored as RGB 0-255.
You can get and set the x, y, and z components by indexing like vec[1], vec[2], or vec[3].
Alpha blends the input color over itself.
Rounds the vector3 up to integers.
Gets the cross product of 2 vector3s.
Gets the distance between 2 vector3s.
Gets the squared distance between 2 vector3s. This is faster to compute than vector3:distance(vector3).
Gets the dot product between 2 vector3s.
Rounds the vector3 down to integers.
Converts an HSL color to RGB.
H = [0 => 360]
S = [0 => 1]
L = [0 => 1]
Converts an HSV color to RGB.
H = [0 => 360]
S = [0 => 1]
V = [0 => 1]
Gets the length of the vector3.
Gets the squared length of the vector3. This is faster to compute than vector3:length().
Returns a vector3 with the largest components of the 2 vectors.
Returns a vector3 with the lowest components of the 2 vectors.
Rounds the vector3 to the nearest integer values.
Converts an RGB color to HSL.
H = [0 => 360]
S = [0 => 1]
L = [0 => 1]
Converts an RGB color to HSV.
H = [0 => 360]
S = [0 => 1]
V = [0 => 1]
Calls vec2(self[1], self[2]).
Calls vec4(self[1], self[2], self[3], w).
If w is not passed, acts like vec4(self[1], self[2], self[4]).
Vector3 also supports addition, subtraction, multiplication, division, exponents, and modulos with numbers and other vector3s, as well as negation, concatenation, tostring(vector3), and checking if 2 vector3s are equal.
Note: color is stored as RGBA 0-255.
You can get and set the x, y, z, and w components by indexing like vec[1], vec[2], vec[3], or vec[4].
Alpha blends the input color over itself.
Rounds the vector4 up to integers.
Gets the distance between 2 vector4s.
Gets the squared distance between 2 vector4s. This is faster to compute than vector4:distance(vector4).
Gets the dot product between 2 vector4s.
Rounds the vector4 down to integers.
Converts an HSLA color to RGBA.
H = [0 => 360]
S = [0 => 1]
L = [0 => 1]
A = [0 => 255]
Converts an HSVA color to RGBA.
H = [0 => 360]
S = [0 => 1]
V = [0 => 1]
A = [0 => 255]
Gets the length of the vector4.
Gets the squared length of the vector4. This is faster to compute than vector4:length().
Returns a vector4 with the largest components of the 2 vectors.
Returns a vector4 with the lowest components of the 2 vectors.
Rounds the vector4 to the nearest integer values.
Converts an RGBA color to HSLA.
H = [0 => 360]
S = [0 => 1]
L = [0 => 1]
A = [0 => 255]
Converts an RGBA color to HSVA.
H = [0 => 360]
S = [0 => 1]
V = [0 => 1]
A = [0 => 255]
Calls vec2(self[1], self[2]).
Calls vec3(self[1], self[2], self[3]).
Vector4 also supports addition, subtraction, multiplication, division, exponents, and modulos with numbers and other vector4s, as well as negation, concatenation, tostring(vector4), and checking if 2 vector4s are equal.
Called when the tool is deselected.
Called when a layer is deselected.
Called when a layer is selected.
Called when the user presses the left mouse button on the canvas. Passes the curor's canvas coordinates. Follows the same rules as input.isMouseDown().
Called when the user presses the right mouse button on the canvas. Passes the curor's canvas coordinates. Follows the same rules as input.isMouseDown().
Called when the user's cursor enters the canvas. Passes the curor's canvas coordinates.
Called when the user's cursor exits the canvas. Passes the curor's canvas coordinates.
Called when the user releases the left mouse button. Passes the curor's canvas coordinates.
Called when the user releases the right mouse button. Passes the curor's canvas coordinates.
Called when the cursor's canvas position changes. Passes the curor's canvas coordinates.
Called when the user moves their mouse and passes the cursor's screen coordinates.
Called when the tool is selected.
Called every frame after all other events.
Called when the composite is run. Automatically calls render.update().