Gorgon
Show / Hide Table of Contents

Class GorgonV31AnimationJsonCodec

A codec used to read/write animations as a JSON formatted string value.

Inheritance
object
GorgonAnimationCodecCommon
GorgonV31AnimationJsonCodec
Implements
IGorgonAnimationCodec
IGorgonNamedObject
Inherited Members
GorgonAnimationCodecCommon.CurrentFileHeader
GorgonAnimationCodecCommon.CurrentVersion
GorgonAnimationCodecCommon.CodecDescription
GorgonAnimationCodecCommon.Codec
GorgonAnimationCodecCommon.Renderer
GorgonAnimationCodecCommon.Graphics
GorgonAnimationCodecCommon.FileExtensions
GorgonAnimationCodecCommon.GetAssociatedTextureNames(Stream)
GorgonAnimationCodecCommon.FromStream(Stream, int?, string, IEnumerable<GorgonTexture2DView>)
GorgonAnimationCodecCommon.FromFile(string, string, IEnumerable<GorgonTexture2DView>)
GorgonAnimationCodecCommon.Save(IGorgonAnimation, Stream)
GorgonAnimationCodecCommon.Save(IGorgonAnimation, string)
GorgonAnimationCodecCommon.IsReadable(Stream)
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: Gorgon.IO
Assembly: Gorgon.IO.Gorgon2D.dll
Syntax
public class GorgonV31AnimationJsonCodec : GorgonAnimationCodecCommon, IGorgonAnimationCodec, IGorgonNamedObject

Constructors

| Edit this page View Source

GorgonV31AnimationJsonCodec(Gorgon2D)

Initializes a new instance of the GorgonV3AnimationJsonCodec class.

Declaration
public GorgonV31AnimationJsonCodec(Gorgon2D renderer)
Parameters
Type Name Description
Gorgon2D renderer

The renderer used for resource handling.

Exceptions
Type Condition
ArgumentNullException

Thrown when the renderer is null.

Properties

| Edit this page View Source

CanDecode

Property to return whether or not the codec can decode animation data.

Declaration
public override bool CanDecode { get; }
Property Value
Type Description
bool
Overrides
GorgonAnimationCodecCommon.CanDecode
| Edit this page View Source

CanEncode

Property to return whether or not the codec can encode animation data.

Declaration
public override bool CanEncode { get; }
Property Value
Type Description
bool
Overrides
GorgonAnimationCodecCommon.CanEncode
| Edit this page View Source

Version

Property to return the version of animation data that the codec supports.

Declaration
public override Version Version { get; }
Property Value
Type Description
Version
Overrides
GorgonAnimationCodecCommon.Version

Methods

| Edit this page View Source

FromJson(Gorgon2D, string, string, IEnumerable<GorgonTexture2DView>)

Function to convert a JSON formatted string into a IGorgonAnimation object.

Declaration
public IGorgonAnimation FromJson(Gorgon2D renderer, string json, string name = null, IEnumerable<GorgonTexture2DView> textureOverrides = null)
Parameters
Type Name Description
Gorgon2D renderer

The renderer for the animation.

string json

The JSON string containing the animation data.

string name

[Optional] The name of the animation.

IEnumerable<GorgonTexture2DView> textureOverrides

[Optional] Textures to use in a texture animation track.

Returns
Type Description
IGorgonAnimation

A new IGorgonAnimation.

Remarks

When passing in a list of textureOverrides, the texture names should match the expected texture names in the key frame. For example, if the TextureName is "WalkingFrames", then the Name should also be "WalkingFrames".

Exceptions
Type Condition
ArgumentNullException

Thrown when the renderer, or the json parameter is null.

ArgumentEmptyException

Thrown when the json parameter is empty.

GorgonException

Thrown if the JSON string does not contain animation data, or there is a version mismatch.

| Edit this page View Source

OnGetAssociatedTextureNames(Stream)

Function to retrieve the names of the associated textures.

Declaration
protected override IReadOnlyList<string> OnGetAssociatedTextureNames(Stream stream)
Parameters
Type Name Description
Stream stream

The stream containing the texture data.

Returns
Type Description
IReadOnlyList<string>

The names of the texture associated with the animations, or an empty list if no textures were found.

Overrides
GorgonAnimationCodecCommon.OnGetAssociatedTextureNames(Stream)
| Edit this page View Source

OnIsReadable(Stream)

Function to determine if the data in a stream is readable by this codec.

Declaration
protected override bool OnIsReadable(Stream stream)
Parameters
Type Name Description
Stream stream

The stream containing the data.

Returns
Type Description
bool

true if the data can be read, or false if not.

Overrides
GorgonAnimationCodecCommon.OnIsReadable(Stream)
| Edit this page View Source

OnReadFromStream(string, Stream, int, IEnumerable<GorgonTexture2DView>)

Function to read the animation data from a stream.

Declaration
protected override IGorgonAnimation OnReadFromStream(string name, Stream stream, int byteCount, IEnumerable<GorgonTexture2DView> textureOverrides)
Parameters
Type Name Description
string name

The name of the animation.

Stream stream

The stream containing the animation.

int byteCount

The number of bytes to read from the stream.

IEnumerable<GorgonTexture2DView> textureOverrides

[Optional] Textures to use in a texture animation track.

Returns
Type Description
IGorgonAnimation

A new IGorgonAnimation.

Overrides
GorgonAnimationCodecCommon.OnReadFromStream(string, Stream, int, IEnumerable<GorgonTexture2DView>)
| Edit this page View Source

OnSaveToStream(IGorgonAnimation, Stream)

Function to save the animation data to a stream.

Declaration
protected override void OnSaveToStream(IGorgonAnimation animation, Stream stream)
Parameters
Type Name Description
IGorgonAnimation animation

The animation to serialize into the stream.

Stream stream

The stream that will contain the animation.

Overrides
GorgonAnimationCodecCommon.OnSaveToStream(IGorgonAnimation, Stream)

Implements

IGorgonAnimationCodec
IGorgonNamedObject

Extension Methods

GorgonDebugExtensions.ValidateObject<T>(T, string)
GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author