Class File
A class to represent a single Pixel Art Creator file.
public class File
- Inheritance
-
File
- Inherited Members
- Extension Methods
Constructors
File(File)
Creates a deep copy of the File.
public File(File file)
Parameters
fileFile
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
layerLayer
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
layersLayer[]
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
indexint
AddNormalLayer(Texture2D, int)
Adds a normal layer at the given index with the given texture.
public void AddNormalLayer(Texture2D texture, int index = 0)
Parameters
textureTexture2Dindexint
AddTile(File, IntVector2, int)
Adds the given file as a tile.
public void AddTile(File file, IntVector2 bottomLeft, int lowestLayer)
Parameters
fileFilebottomLeftIntVector2lowestLayerint
AddTile(Tile)
Adds the tile to the file.
public void AddTile(Tile tile)
Parameters
tileTile
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
indexint
ContainsTile(Tile)
public bool ContainsTile(Tile tile)
Parameters
tileTile
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
filePathstring
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(CardinalAxis)
Flips the file.
public void Flip(CardinalAxis axis)
Parameters
axisCardinalAxis
ImportImage(string)
Adds the image at the file path as a new layer.
public void ImportImage(string filePath)
Parameters
filePathstring
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
layersLayer[]
IndexOfLayer(Layer)
Gets the index of the layer within the file.
public int IndexOfLayer(Layer layer)
Parameters
layerLayer
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
filePathstring
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
filePathstring
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
filePathstring
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
filePathstring
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
filePathstring
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
layerLayer
RemoveLayer(int)
Removes the layer at the given index.
public void RemoveLayer(int layer)
Parameters
layerint
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
layersLayer[]
RemoveLayers(int[])
Removes the layers at the given indices.
public void RemoveLayers(int[] layers)
Parameters
layersint[]
RemoveTile(Tile)
Removes the tile. Throws an error if the tile is not in the file.
public void RemoveTile(Tile tile)
Parameters
tileTile
Render(int)
Renders all layers down to a Texture2D. Does not apply the texture.
public Texture2D Render(int frame)
Parameters
frameint
Returns
- Texture2D
RenderLayers(IEnumerable<int>, int)
Renders the layers at the given layer indices down to a Texture2D. Does not apply the texture.
public Texture2D RenderLayers(IEnumerable<int> layerIndices, int frame)
Parameters
layerIndicesIEnumerable<int>The layer indices in the order you want them to be rendered, from highest layer (so lowest index) to lowest.
frameint
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
highestLayerintThe higher layer (so lower index).
lowestLayerintThe lower layer (so higher index).
frameintinclusivebool
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, IEnumerable<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, IEnumerable<int> layerIndices, int frame)
Parameters
pixelIntVector2layerIndicesIEnumerable<int>frameint
Returns
- Color
RenderPixel(IntVector2, int)
Renders the colour of the given pixel.
public Color RenderPixel(IntVector2 pixel, int frame)
Parameters
pixelIntVector2frameint
Returns
- Color
RenderPixel(IntVector2, int, int, int, bool)
public Color RenderPixel(IntVector2 pixel, int highestLayer, int lowestLayer, int frame, bool inclusive = true)
Parameters
pixelIntVector2highestLayerintlowestLayerintframeintinclusivebool
Returns
- Color
RenderPixel(int, int, IEnumerable<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, IEnumerable<int> layerIndices, int frame)
Parameters
xintyintlayerIndicesIEnumerable<int>frameint
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
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(QuadrantalAngle)
Rotates the file. Rotation is clockwise.
public void Rotate(QuadrantalAngle angle)
Parameters
angleQuadrantalAngle
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
filePathstring
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
scaleFactorfloat
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
frameint
SubscribeToOnPixelsChanged(UnityAction<IEnumerable<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<IEnumerable<IntVector2>, Layer[], int[]> call)
Parameters
callUnityAction<IEnumerable<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
callUnityAction
SubscribeToOnTileAdded(UnityAction)
Event invoked when a tile is added to the file.
public void SubscribeToOnTileAdded(UnityAction call)
Parameters
callUnityAction
SubscribeToOnTileRemoved(UnityAction)
Event invoked when a tile is removed from the file.
public void SubscribeToOnTileRemoved(UnityAction call)
Parameters
callUnityAction