Skip to content

Commit

Permalink
Merge pull request #1 from ThatcherDev/develop
Browse files Browse the repository at this point in the history
Updated documentation
  • Loading branch information
thatcherclough authored Nov 9, 2019
2 parents 52d1615 + 1b7ac57 commit ea74f21
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 27 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
AsciiAnimator is a stop motion ASCII art animator.

## Features
AsciiAnimator can uses plain text files and stop motion to animate ASCII art frame by frame.
AsciiAnimator uses plain text files and stop motion to animate ASCII art frame by frame.

See [syntax](https://github.com/ThatcherDev/AsciiAnimator#syntax) for animation file syntax.

Expand All @@ -12,7 +12,7 @@ See [syntax](https://github.com/ThatcherDev/AsciiAnimator#syntax) for animation
Note: the cursor flickering was not present in real-time.

## Requirements
- A Java JDK distribution must be installed and added to PATH.
- A Java JDK distribution >=8 must be installed and added to PATH.

## Compatibility
AsciiAnimator is compatible with Windows, Mac, and Linux.
Expand Down Expand Up @@ -41,7 +41,7 @@ Alternatively, you can download the jar from the [release page](https://github.c

## Usage
```
java -jar AsciiAnimator.jar
java -jar asciianimator.jar
AsciiAnimator: A stop motion ASCII art animator (1.0.0)
Usage:
Expand All @@ -50,8 +50,8 @@ Usage:
Arguments:
-h, --help Display this message.
-v, --version Display current version.
-f, --file Specify file to use for animation. (See README for syntax)
-l, --loop Specify if the animation should loop. (Set to false if not specified)
-f, --file Specify file to use for animation. (See README.md for syntax)
-l, --loop Specify if the animation should loop. (Set to false by default)
-fps, --frames-per-second Specify FPS for animation. (Must be an integer greater than 0)
Note: When running, CTRL + C can be used to terminate.
Expand All @@ -60,7 +60,7 @@ Note: When running, CTRL + C can be used to terminate.
## Syntax
Any plain text file can be used with AsciiAnimator.
This file must contain each frame of the animation.
These framed must be followed by "[frame]" to indicate the end of the frame.
These frames must be followed by "[frame]" to indicate the end of the frame.
Below is an example of 2 frames:
```
__
Expand All @@ -84,4 +84,4 @@ An example of a valid animation file can be found in src/main/resources/.

## License
- [MIT](https://choosealicense.com/licenses/mit/)
- Copyright 2019 ThatcherDev.
- Copyright 2019 ©️ ThatcherDev.
32 changes: 18 additions & 14 deletions src/main/java/com/github/thatcherdev/asciianimator/Animator.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ public class Animator {
private int wait;

/**
* Construct a new Animator.
* Constructs a new Animator.
* <p>
* Construct a new Animator and setup AnsiConsole to be used for cursor
* movement.
* Sets {@link #file} to the file with the name {@link inFile}, sets
* {@link #loop} to {@link inLoop}, sets {@link #wait} to {@link inWait}, and
* starts AnsiConsole using {@link AnsiConsole.systemInstall()} to be used for
* cursor movement.
*
* @param inFile name of file with frames to animate
* @param inLoop if animation should loop
* @param inWait milliseconds to wait before displaying next frame
* @param inWait milliseconds to wait before displaying each frame
* @return
*/
public Animator(String inFile, boolean inLoop, int inWait) {
Expand All @@ -32,10 +34,12 @@ public Animator(String inFile, boolean inLoop, int inWait) {
}

/**
* Start animator.
* Starts animator.
* <p>
* Get lines from file {@link file}. Use {@link #animate(ArrayList<String>)} to
* start animation with these lines.
* Gets lines from file {@link #file} using {@link #getLines()}. Starts a loop
* that continuously uses {@link #animate(ArrayList<String>)} to animate
* {@link lines}, unless {@link #loop} is false, in which case the loop is only
* run once.
*
* @throws FileNotFoundException
* @throws InterruptedException
Expand All @@ -50,12 +54,12 @@ public void start() throws FileNotFoundException, InterruptedException {
}

/**
* Start animation of {@link #lines}.
* Starts stop motion animation of {@link lines}.
* <p>
* Cycle though {@link #lines}. Either display line or move cursor to (0,0),
* wait {@link #wait} milliseconds, and clear screen.
* Cycles though {@link lines}. If line is "[frame]", moves cursor to (0,0),
* waits {@link #wait} milliseconds, and clears screen. Otherwise, prints line.
*
* @param lines lines from animation file
* @param lines lines to animate
* @throws InterruptedException
*/
private void animate(ArrayList<String> lines) throws InterruptedException {
Expand All @@ -71,9 +75,9 @@ private void animate(ArrayList<String> lines) throws InterruptedException {
}

/**
* Get all lines from {@link #file}.
* Gets all lines from {@link #file}.
*
* @return ArrayList<String> lines from {@link #file}.
* @return ArrayList<String> of lines from {@link #file}
* @throws FileNotFoundException
*/
private ArrayList<String> getLines() throws FileNotFoundException {
Expand All @@ -84,4 +88,4 @@ private ArrayList<String> getLines() throws FileNotFoundException {
in.close();
return lines;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ public class AsciiAnimator {
private static String file;
private static boolean loop;
private static int wait;
private static String help = "AsciiAnimator: A stop motion ASCII art animator (1.0.0)\n\nUsage:\n\tjava -jar asciianimator.jar [-h] [-v] [-f FILE -l BOOLEAN -fps INTEGER]\n\n"
+ "Arguments:\n\t-h, --help\t\t\tDisplay this message.\n\t-v, --version\t\t\tDisplay current version.\n\t-f, --file\t\t\tSpecify file to use for animation. (See README for syntax)\n"
+ "\t-l, --loop\t\t\tSpecify if the animation should loop. (Set to false if not specified)\n\t-fps, --frames-per-second\tSpecify FPS for animation. (Must be an integer greater than 0)\n\n"
final private static String help = "AsciiAnimator: A stop motion ASCII art animator (1.0.1)\n\nUsage:\n\tjava -jar asciianimator.jar [-h] [-v] [-f FILE -l BOOLEAN -fps INTEGER]\n\n"
+ "Arguments:\n\t-h, --help\t\t\tDisplay this message.\n\t-v, --version\t\t\tDisplay current version.\n\t-f, --file\t\t\tSpecify file to use for animation. (See README.md for syntax)\n"
+ "\t-l, --loop\t\t\tSpecify if the animation should loop. (Set to false by default)\n\t-fps, --frames-per-second\tSpecify FPS for animation. (Must be an integer greater than 0)\n\n"
+ "Note: When running, CTRL + C can be used to terminate.";
private static Thread clear = new Thread() {
final private static Thread clear = new Thread() {
public void run() {
System.out.print(Ansi.ansi().eraseScreen().cursor(0, 0).reset());
}
};

/**
* Start AsciiAnimator with given {@link args}.
* Starts AsciiAnimator based on command line arguments {@link args}.
*
* @param args command line arguments
*/
Expand Down Expand Up @@ -56,4 +56,4 @@ else if (args[k].equals("-fps") || args[k].equals("--frames-per-second"))
System.exit(0);
}
}
}
}

0 comments on commit ea74f21

Please sign in to comment.