Skip to content
This repository was archived by the owner on Sep 3, 2023. It is now read-only.

Commit

Permalink
Add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
0x61nas committed Jun 16, 2022
1 parent fb8ba71 commit 3cce7ba
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 27 deletions.
4 changes: 3 additions & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,49 @@ allprojects {

## Usage:

```java
public class Example1 {
public static void main(String[] args) {
ColoredString hello = new ColoredString("Hello, ");
hello.setForegroundColor(TextColor.ANSI.BLUE); // Set text color to red
hello.setBackgroundColor("magenta"); // Set background color to magenta
hello.addStyle(TextStyle.BOLD); // Add bold style

ColoredString world = new ColoredString();
world.setStr("World!"); // Set string to "World!"
world.setForegroundColor("#542413"); // Set text color
world.setBackgroundColor(new TextColor.RGB(34, 139, 34)); // Set background color
world.addStyle(TextStyle.ITALIC); // Add italic style

System.out.print(hello); // Print colored string
System.out.print(world); // Print colored string

}
}
```
![Result of example 1](./Screenshots/1.0.1-example1.png)

```java
public class Example2 {
public static void main(String[] args) {
new Thread(() -> {
while (true) {
System.out.println(new ColoredString("Hi",
new TextColor.RGB((int) (Math.random() * 255), (int) (Math.random() * 255), (int) (Math.random() * 255)),
new TextColor.RGB((int) (Math.random() * 255), (int) (Math.random() * 255), (int) (Math.random() * 255)),
TextStyle.values()[(int) (Math.random() * TextStyle.values().length)]));
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}).start();
}
}
```
![Result of example 2](./Screenshots/1.0.1-example2.gif)

## Requirements for development:
- Maven
- jdk 17
Expand Down
Binary file added Screenshots/1.0.1-example1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/1.0.1-example2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 0 additions & 26 deletions src/main/java/test/Main.java

This file was deleted.

0 comments on commit 3cce7ba

Please sign in to comment.