Sen descrición https://github.com/anas-elgarhy/JColorfulConsole
Anas bde4bf1a17 chore: just bump the package ver | hai 1 ano | |
---|---|---|
.github | hai 1 ano | |
.idea | %!s(int64=2) %!d(string=hai) anos | |
.m2 | %!s(int64=2) %!d(string=hai) anos | |
Screenshots | %!s(int64=2) %!d(string=hai) anos | |
src | %!s(int64=2) %!d(string=hai) anos | |
.gitignore | %!s(int64=2) %!d(string=hai) anos | |
.mergify.yml | hai 1 ano | |
CODE_OF_CONDUCT.md | %!s(int64=2) %!d(string=hai) anos | |
CONTRIBUTING.md | %!s(int64=2) %!d(string=hai) anos | |
LICENSE.txt | %!s(int64=2) %!d(string=hai) anos | |
README.md | hai 1 ano | |
pom.xml | hai 1 ano | |
renovate.json | hai 1 ano |
Step 1. Add the JitPack repository to your build file
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Step 2. Add the dependency
<dependency>
<groupId>com.github.0x61nas</groupId>
<artifactId>JColorfulConsole</artifactId>
<version>1.0.4</version>
</dependency>
Step 1. Add the JitPack repository to your build file
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
implementation 'com.github.0x61nas:JColorfulConsole:1.0.4'
}
public class Example1 {
public static void main(String[] args) {
ColoredString hello = new ColoredString("Hello, ");
hello.setForegroundColor(TextColor.ANSI.BLUE); // Set text color to blue
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
}
}
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();
}
}