Class File
A class to represent a single Pixel Art Creator file.
public class File
- Inheritance
-
File
- Inherited Members
Constructors
File(File)
Creates a deep copy of the File.
public File(File file)
Parameters
file
File
File(string, int, int)
Creates a blank file.
public File(string name, int width, int height)
Parameters
Properties
height
public int height { get; }
Property Value
keyFrameIndices
The frame indices at which some layer has a key frame.
public int[] keyFrameIndices { get; }
Property Value
- int[]
layers
public List<Layer> layers { get; }
Property Value
liveRender
public Texture2D liveRender { get; }
Property Value
- Texture2D
mostRecentSavePath
public string mostRecentSavePath { get; }
Property Value
name
public string name { get; set; }
Property Value
numOfFrames
The number of frames the animation lasts for.
public int numOfFrames { get; set; }
Property Value
rect
public IntRect rect { get; }
Property Value
savedSinceLastEdit
public bool savedSinceLastEdit { get; }
Property Value
tiles
All the tile objects currently in the file.
public Tile[] tiles { get; }
Property Value
- Tile[]
width
public int width { get; }
Property Value
Methods
AddLayer(Layer)
Adds the given layer on top of all existing layers.
public void AddLayer(Layer layer)
Parameters
layer
Layer
AddLayer(Layer, int)
Adds the given layer at the given index. Throws an error if the layer is already in the file.
public void AddLayer(Layer layer, int index)
Parameters
AddLayers(params Layer[])
Adds the layers on top of all existing layers, retaining the order they have in the array - i.e. first layer in the array is the one on top, etc.
public void AddLayers(params Layer[] layers)
Parameters
layers
Layer[]
AddNormalLayer()
Adds a blank normal layer on top of all existing layers.
public void AddNormalLayer()
AddNormalLayer(int)
Adds a blank normal layer at the given index.
public void AddNormalLayer(int index)
Parameters
index
int
AddNormalLayer(Texture2D, int)
Adds a normal layer at the given index with the given texture.
public void AddNormalLayer(Texture2D texture, int index = 0)
Parameters
texture
Texture2Dindex
int
AddTile(File, IntVector2, int)
Adds the given file as a tile.
public void AddTile(File file, IntVector2 bottomLeft, int lowestLayer)
Parameters
file
FilebottomLeft
IntVector2lowestLayer
int
AddTile(Tile)
Adds the tile to the file.
public void AddTile(Tile tile)
Parameters
tile
Tile
AddTileLayer()
Adds a blank tile layer on top of all existing layers.
public void AddTileLayer()
AddTileLayer(int)
Adds a blank tile layer at the given index.
public void AddTileLayer(int index)
Parameters
index
int
ContainsTile(Tile)
public bool ContainsTile(Tile tile)
Parameters
tile
Tile
Returns
DeepCopy()
Creates a deep copy of the File.
public File DeepCopy()
Returns
ExportAnimation(string)
Exports each frame of the animation and puts them in a folder. The file path specifies the folder name and location, and the file extension to export each frame as.
public bool ExportAnimation(string filePath)
Parameters
filePath
string
Returns
ExportFrame(int, string)
Exports the frame to the file path, according to the file extension.
public bool ExportFrame(int frame, string filePath)
Parameters
Returns
Extend(int, int, int, int)
Extends the dimensions of the file in each direction by the given amounts.
public void Extend(int left, int right, int up, int down)
Parameters
Flip(FlipDirection)
Flips the file.
public void Flip(FlipDirection direction)
Parameters
direction
FlipDirection
ImportImage(string)
Adds the image at the file path as a new layer.
public void ImportImage(string filePath)
Parameters
filePath
string
ImportLayers(params Layer[])
Adds deep copies of the layers on top of all existing layers, retaining the order they have in the array - i.e. first layer in the array is the one on top, etc.
public void ImportLayers(params Layer[] layers)
Parameters
layers
Layer[]
IndexOfLayer(Layer)
Gets the index of the layer within the file.
public int IndexOfLayer(Layer layer)
Parameters
layer
Layer
Returns
- int
The index of the layer, or -1 if the layer is not in the file.
IsBlank()
Returns true if and only if all pixels on all layers are completely transparent.
public bool IsBlank()
Returns
MoveLayer(Layer, int)
Moves the layer to indexToMoveTo. Throws an error if the layer is not in the file.
public void MoveLayer(Layer layerToMove, int indexToMoveTo)
Parameters
MoveLayer(int, int)
Moves the layer at indexToMove to indexToMoveTo.
public void MoveLayer(int layerToMove, int indexToMoveTo)
Parameters
OpenFile(string)
Opens the file according to its file extension.
public static File OpenFile(string filePath)
Parameters
filePath
string
Returns
OpenImage(string)
Opens the file at the file path if it is an image file type, e.g. PNG or JPEG.
public static File OpenImage(string filePath)
Parameters
filePath
string
Returns
OpenJPEG(string)
Opens the JPEG/JPG file. Throws an error if the file is not a JPEG/JPG file.
public static File OpenJPEG(string filePath)
Parameters
filePath
string
Returns
OpenPAC(string)
Opens the PAC file. Throws an error if the file is not a PAC file.
public static File OpenPAC(string filePath)
Parameters
filePath
string
Returns
OpenPNG(string)
Opens the PNG file. Throws an error if the file is not a PNG file.
public static File OpenPNG(string filePath)
Parameters
filePath
string
Returns
RemoveAllLayers()
Removes all layers, then adds a blank normal layer.
public void RemoveAllLayers()
RemoveLayer(Layer)
Removes the layer from the file. Throws an error if the layer is not in the file.
public void RemoveLayer(Layer layer)
Parameters
layer
Layer
RemoveLayer(int)
Removes the layer at the given index.
public void RemoveLayer(int layer)
Parameters
layer
int
RemoveLayers(Layer[])
Removes the given layers from the file. Throws an error if a layer is not in the file.
public void RemoveLayers(Layer[] layers)
Parameters
layers
Layer[]
RemoveLayers(int[])
Removes the layers at the given indices.
public void RemoveLayers(int[] layers)
Parameters
layers
int[]
RemoveTile(Tile)
Removes the tile. Throws an error if the tile is not in the file.
public void RemoveTile(Tile tile)
Parameters
tile
Tile
Render(int)
Renders all layers down to a Texture2D. Does not apply the texture.
public Texture2D Render(int frame)
Parameters
frame
int
Returns
- Texture2D
RenderLayers(int, int, int, bool)
Renders all the layers with index between lowestLayer and highestLayer (inclusive iff inclusive == true) down to a Texture2D. highestLayer and lowestLayer are automatically clamped to be in the valid range of layers. Does not apply the texture.
public Texture2D RenderLayers(int highestLayer, int lowestLayer, int frame, bool inclusive = true)
Parameters
highestLayer
intThe higher layer (so lower index).
lowestLayer
intThe lower layer (so higher index).
frame
intinclusive
bool
Returns
- Texture2D
RenderLayers(int[], int)
Renders the layers at the given layer indices down to a Texture2D. Does not apply the texture.
public Texture2D RenderLayers(int[] layerIndices, int frame)
Parameters
layerIndices
int[]The layer indices in the order you want them to be rendered, from highest layer (so lowest index) to lowest.
frame
int
Returns
- Texture2D
RenderLayersAbove(int, int, bool)
Renders all layers that appear above the given layer (includes the layer iff inclusive == true) down to a Texture2D. Returns a blank texture if there are none. Does not apply the texture.
public Texture2D RenderLayersAbove(int layer, int frame, bool inclusive = false)
Parameters
Returns
- Texture2D
RenderLayersBelow(int, int, bool)
Renders all layers that appear strictly beneath the given layer (includes the layer iff inclusive == true) down to a Texture2D. Returns a blank texture if there are none. Does not apply the texture.
public Texture2D RenderLayersBelow(int layer, int frame, bool inclusive = false)
Parameters
Returns
- Texture2D
RenderPixel(IntVector2, int)
Renders the colour of the given pixel.
public Color RenderPixel(IntVector2 pixel, int frame)
Parameters
pixel
IntVector2frame
int
Returns
- Color
RenderPixel(IntVector2, int, int, int, bool)
public Color RenderPixel(IntVector2 pixel, int highestLayer, int lowestLayer, int frame, bool inclusive = true)
Parameters
pixel
IntVector2highestLayer
intlowestLayer
intframe
intinclusive
bool
Returns
- Color
RenderPixel(IntVector2, int[], int)
Renders the colour of the pixel on the layers at the given layer indices. Throws an error if there are no layer indices.
public Color RenderPixel(IntVector2 pixel, int[] layerIndices, int frame)
Parameters
pixel
IntVector2layerIndices
int[]frame
int
Returns
- Color
RenderPixel(int, int, int)
Renders the colour of the given pixel.
public Color RenderPixel(int x, int y, int frame)
Parameters
Returns
- Color
RenderPixel(int, int, int, int, int, bool)
public Color RenderPixel(int x, int y, int highestLayer, int lowestLayer, int frame, bool inclusive = true)
Parameters
Returns
- Color
RenderPixel(int, int, int[], int)
Renders the colour of pixel (x, y) on the layers at the given layer indices. Throws an error if there are no layer indices.
public Color RenderPixel(int x, int y, int[] layerIndices, int frame)
Parameters
Returns
- Color
ReplaceLayer(Layer, Layer)
Replaces the layer with the given layer. Throws an error if the layer to replace is not in the file, or if the layer to replace with is already in the file.
public void ReplaceLayer(Layer layerToReplace, Layer layerToReplaceWith)
Parameters
ReplaceLayer(int, Layer)
Replaces the layer at the given index with the given layer. Throws an error if the layer to replace with is already in the file.
public void ReplaceLayer(int layerToReplace, Layer layerToReplaceWith)
Parameters
Rotate(RotationAngle)
Rotates the file. Rotation is clockwise.
public void Rotate(RotationAngle angle)
Parameters
angle
RotationAngle
SaveAsPAC(string)
Saves the file as a PAC file at the given file path. Throws an error if the file is not a PAC file.
public void SaveAsPAC(string filePath)
Parameters
filePath
string
SavePAC()
Saves the file as a PAC file at the location it was most recently saved at. Throws an error if the file hasn't been saved before.
public void SavePAC()
Scale(int, int)
Resizes the file to the new width and height.
public void Scale(int newWidth, int newHeight)
Parameters
Scale(float)
Resizes the dimensions of the file by the scale factor.
public void Scale(float scaleFactor)
Parameters
scaleFactor
float
Scale(float, float)
Resizes the dimensions of the file by the scale factors.
public void Scale(float xScaleFactor, float yScaleFactor)
Parameters
SetLiveRenderFrame(int)
Sets the frame that the live render will be for.
public void SetLiveRenderFrame(int frame)
Parameters
frame
int
SubscribeToOnPixelsChanged(UnityAction<IntVector2[], Layer[], int[]>)
Event invoked when some pixels have been changed on a layer. Passes the pixels, layers and frames that were affected.
public void SubscribeToOnPixelsChanged(UnityAction<IntVector2[], Layer[], int[]> call)
Parameters
call
UnityAction<IntVector2[], Layer[], int[]>
SubscribeToOnSavedSinceEditChanged(UnityAction)
Event invoked when the a change to file is made or when the file is saved.
public void SubscribeToOnSavedSinceEditChanged(UnityAction call)
Parameters
call
UnityAction
SubscribeToOnTileAdded(UnityAction)
Event invoked when a tile is added to the file.
public void SubscribeToOnTileAdded(UnityAction call)
Parameters
call
UnityAction
SubscribeToOnTileRemoved(UnityAction)
Event invoked when a tile is removed from the file.
public void SubscribeToOnTileRemoved(UnityAction call)
Parameters
call
UnityAction