FxPixelGrid ​
This module contains functions for editing the pixel grid of an active PixelLayer node or the pixel grid - also known as texture - of an active MeshLayer node. A node is said to be active if it is selected and either the only selected node or the first selected node. To activate a node, either use a select function of FxNode or the Activate function of this module.
The active grid is the pixel grid of the active PixelLayer or MeshLayer node.
Load ​
FxPixelGrid = require "FxPixelGrid";Functions ​
| Function | Description |
|---|---|
| Activate (NodeID) | Activates a pixel grid. |
| Deselect () | Deselects all pixels of the active grid. |
| EditLine (StartX, StartY, EndX, EndY, EditMethod, Pixel) | Edits pixels in a straight line . |
| EditPoint (X, Y, EditMethod, Pixel) | Edits a single pixel. |
| EditRect (X, Y, Width, Height, EditMethod, Pixel) | Edits a rectangular area. |
| InvertSelection () | Inverts pixel selection. |
| IsAnySelected () | Returns whether any pixel of the grid is selected. |
| IsSelected (X, Y) | Returns whether a pixel of the grid is selected. |
| IsSolid (X, Y) | Returns whether a pixel of the grid is solid. |
| Read (X, Y) | Returns the pixel at a position. |
| SelectAll () | Selects all pixels. |
| Write (X, Y, Pixel) | Sezs the pixel at a position. |
Activate (NodeID) ​
This function activates the specified node if it is a PixelLayer or MeshLayer node. The pixel grid of the active PixelLayer node or the texture of the active MeshLayer node becomes the active grid.
Parameters ​
NodeID : The NodeID of the PixelLayer node or MeshLayer node to activate
Errors ​
Possible errors include FX_REQUIRED_ASSET_UNAVAILABLE, FX_NODE_NOT_FOUND
Since ​
Version 1.0
Example ​
-- activate pixel grid of layer1
FxPixelGrid.Activate("layer1");
-- if layer1 is a PixelLayer or MeshLayer the above code is the same as:
FxNode.SelectEx("layer1");
-- or:
FxNode.Select("*", false);
FxNode.Select("layer1", true);Deselect () ​
This function deselects all pixels of the active grid.
Errors ​
Possible errors include FX_REQUIRED_GRID_UNAVAILABLE
Since ​
Version 1.0
Example ​
FxPixelGrid.Deselect();EditLine (StartX, StartY, EndX, EndY, EditMethod, Pixel) ​
This function edits a straight line between the two specified coordinates using the specified edit method and pixel. Depending on the edit method the whole pixel, only parts of it, or none of it will be used. For example, if the edit method is paint, only the color of the pixel is used. Or, if the edit method is erase then the pixel is ignored.
Parameters ​
- StartX: The X coordinate of the start of the line
- StartY: The Y coordinate of the start of the line
- EndX: The X coordinate of the end of the line
- EndY: The Y coordinate of the end of the line
- EditMethod: The EditMethod
- Pixel: The FoxelPixel
Errors ​
Possible errors include FX_REQUIRED_GRID_UNAVAILABLE, FX_VALUE_INVALID
Since ​
Version 1.0
Example ​
-- draw a line from (0,0) to (5,5)
FxPixelGrid.EditLine(0, 0, 5, 5, 1, pixel);EditPoint (X, Y, EditMethod, Pixel) ​
This function edits a single pixel at the specified coordinates using the specified edit method and pixel. Depending on the edit method the whole pixel, only parts of it, or none of it will be used. For example, if the edit method is paint, only the color of the pixel is used. Or, if the edit method is erase then the pixel is ignored.
Parameters ​
- X: The X coordinate of the point
- Y: The Y coordinate of the point
- EditMethod: The EditMethod
- Pixel: The FoxelPixel
Errors ​
Possible errors include FX_REQUIRED_GRID_UNAVAILABLE, FX_VALUE_INVALID
Since ​
Version 1.0
Example ​
-- paint a point with color 20 at (2,3)
pixel = FxPixel.Create(20, 0);
FxPixelGrid.EditPoint(2, 3, 2, pixel);EditRect (X, Y, Width, Height, EditMethod, Pixel) ​
This function edits the specified rectangular area using the specified edit method and pixel. Depending on the edit method the whole pixel, only parts of it, or none of it will be used. For example, if the edit method is paint, only the color of the pixel is used. Or, if the edit method is erase then the pixel is ignored.
Parameters ​
- X: The X coordinate of the rectangle position
- Y: The Y coordinate of the rectangle position
- Width: The rectangle width
- Height: The rectangle height
- EditMethod: The EditMethod
- Pixel: The FoxelPixel
Errors ​
Possible errors include FX_REQUIRED_GRID_UNAVAILABLE, FX_VALUE_INVALID
Since ​
Version 1.0
Example ​
-- coat a rectangle with material 10
pixel = FxPixel.Create(0, 10);
FxPixelGrid.EditRect(0, 0, 5, 5, 3, pixel);InvertSelection () ​
This function toggles the selection state of all solid pixels of the active grid.
Errors ​
Possible errors include FX_REQUIRED_GRID_UNAVAILABLE
Since ​
Version 1.0
Example ​
-- select all solid pixels that are outside of a rect:
FxPixelGrid.EditRect(5, 5, 10, 10, 11);
FxPixelGrid.InvertSelection();IsAnySelected () ​
This function returns if any voxel of the active grid is selected.
Returns ​
The selection state
Errors ​
Possible errors include FX_REQUIRED_GRID_UNAVAILABLE
Since ​
Version 1.0
Example ​
if FxPixelGrid.IsAnySelected() then
-- do something
endIsSelected (X, Y) ​
This function returns whether the pixel at the given coordinates is selected.
Parameters ​
- X: The X coordinate of the pixel
- Y: The Y coordinate of the pixel
Returns ​
Selection state
Errors ​
Possible errors include FX_REQUIRED_GRID_UNAVAILABLE
Since ​
Version 1.0
Example ​
if FxPixelGrid.IsSelected(0, 0) then
-- do something
endIsSolid (X, Y) ​
This function returns whether the voxel at the given coordinates is solid.
Parameters ​
- X: The X coordinate of the pixel
- Y: The Y coordinate of the pixel
Returns ​
The solid state
Errors ​
Possible errors include FX_REQUIRED_GRID_UNAVAILABLE
Since ​
Version 1.0
Example ​
if FxPixelGrid.IsSolid(0, 0) then
-- do something
endRead (X, Y) ​
This function returns the pixel at the given coordinates.
Parameters ​
- X: The X coordinate of the pixel
- Y: The Y coordinate of the pixel
Returns ​
The FoxelPixel
Errors ​
Possible errors include FX_REQUIRED_GRID_UNAVAILABLE
Since ​
Version 1.0
Example ​
pixel = FxPixelGrid.Read(4, 5);SelectAll () ​
This function selects all solid pixels of the active grid.
Errors ​
Possible errors include FX_REQUIRED_GRID_UNAVAILABLE
Since ​
Version 1.0
Example ​
FxPixelGrid.SelectAll();Write (X, Y, Pixel) ​
This function sets the pixel at the given coordinates.
Parameters ​
- X: The X coordinate of the pixel
- Y: The Y coordinate of the pixel
- Pixel: The new FoxelPixel
Errors ​
Possible errors include FX_REQUIRED_GRID_UNAVAILABLE, FX_VALUE_INVALID
Since ​
Version 1.0
Example ​
-- copy pixel from (3,5) to (4,5)
pixel = FxPixelGrid.Read(3, 5);
FxPixelGrid.Write(4, 5, pixel);