Skip to content
This repository was archived by the owner on Apr 19, 2024. It is now read-only.

Commit 584a55c

Browse files
committed
more summaries
1 parent ed92074 commit 584a55c

3 files changed

Lines changed: 47 additions & 2 deletions

File tree

ProjectStarlight.Interchange.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<DefineConstants>TRACE</DefineConstants>
3232
<ErrorReport>prompt</ErrorReport>
3333
<WarningLevel>4</WarningLevel>
34+
<DocumentationFile>bin\Release\ProjectStarlight.Interchange.xml</DocumentationFile>
3435
</PropertyGroup>
3536
<ItemGroup>
3637
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">

TextureGIF.cs

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,59 @@
55

66
namespace ProjectStarlight.Interchange
77
{
8-
// TODO: GIF looping
8+
/// <summary>
9+
/// Simple class containing GIF data for drawing and updating.
10+
/// </summary>
911
public class TextureGIF
1012
{
13+
/// <summary>
14+
/// The width of the GIF.
15+
/// </summary>
1116
public int Width { get; private set; }
1217

18+
/// <summary>
19+
/// The height of the GIF.
20+
/// </summary>
1321
public int Height { get; private set; }
1422

23+
/// <summary>
24+
/// Whether the GIF is paused.
25+
/// </summary>
1526
public bool IsPaused { get; private set; }
1627

28+
/// <summary>
29+
/// Whether the GIF has ended. Never true of the GIF loops (<seealso cref="ShouldLoop"/>).
30+
/// </summary>
1731
public bool HasEnded => FrameIndex >= Frames.Length && FrameTick >= TicksPerFrame && !ShouldLoop;
1832

33+
/// <summary>
34+
/// Whether the GIF loops. Prevents the GIF from ending unless <seealso cref="Stop"/> is called.
35+
/// </summary>
1936
public bool ShouldLoop { get; set; }
2037

38+
/// <summary>
39+
/// The amount of ticks per frame. Once the tick threshold is reached, goes to a new frame.
40+
/// </summary>
2141
public int TicksPerFrame { get; set; }
2242

43+
/// <summary>
44+
/// The current tick the frame is on.
45+
/// </summary>
2346
public int FrameTick { get; private set; }
2447

48+
/// <summary>
49+
/// The index of <seealso cref="Frames"/> that should be drawn.
50+
/// </summary>
2551
public int FrameIndex { get; private set; }
2652

27-
public Texture2D[] Frames { get; set; }
53+
/// <summary>
54+
/// An array of <seealso cref="Texture2D"/>s representing the frames of a GIF.
55+
/// </summary>
56+
public Texture2D[] Frames { get; private set; }
2857

58+
/// <summary>
59+
/// Gets the current frame in accordance to <seealso cref="Frames"/>, using <seealso cref="FrameIndex"/> as the index.
60+
/// </summary>
2961
public Texture2D CurrentFrame => HasEnded ? Frames.Last() : Frames[FrameIndex];
3062

3163
/// <summary>
@@ -123,12 +155,18 @@ public void Draw(SpriteBatch spriteBatch, Rectangle destinationRectangle, Rectan
123155
spriteBatch.Draw(CurrentFrame, destinationRectangle, sourceRectangle, color, rotation, origin, effects,
124156
layerDepth);
125157

158+
/// <summary>
159+
/// Increment ticks by one if the GIF is not paused and has not ended.
160+
/// </summary>
126161
public void UpdateGIF()
127162
{
128163
if (!IsPaused && !HasEnded)
129164
ForwardTicks(1);
130165
}
131166

167+
/// <summary>
168+
/// Increments the specified amount of ticks. You can use this to skip frames as well.
169+
/// </summary>
132170
public void ForwardTicks(int tickAmount)
133171
{
134172
for (int i = 0; i < tickAmount; i++)

Utilities/GIFBuilder.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public static class GIFBuilder
1919
public static TextureGIF FromArray(Texture2D[] frames, int ticksPerFrame) =>
2020
new TextureGIF(frames, ticksPerFrame);
2121

22+
/// <summary>
23+
/// Creates a <see cref="TextureGIF"/> from a <see cref="FileStream"/>, opened and read from the <paramref name="filePath"/>.
24+
/// </summary>
2225
public static TextureGIF FromGIFFile(string filePath, GraphicsDevice graphicsDevice, int ticksPerFrame)
2326
{
2427
TextureGIF gif;
@@ -32,6 +35,9 @@ public static TextureGIF FromGIFFile(string filePath, GraphicsDevice graphicsDev
3235
}
3336

3437
// https://dejanstojanovic.net/aspnet/2018/march/getting-gif-image-information-using-c/
38+
/// <summary>
39+
/// Creates a <see cref="TextureGIF"/> from a <see cref="FileStream"/>.
40+
/// </summary>
3541
public static TextureGIF FromGIFFile(FileStream stream, GraphicsDevice graphicsDevice, int ticksPerFrame)
3642
{
3743
using (Image image = Image.FromStream(stream))

0 commit comments

Comments
 (0)