No Description https://github.com/anas-elgarhy/JColorfulConsole
Anas Elgarhy 9ed352ca83 Add mirror action 🪞 | 2 years ago | |
---|---|---|
.github | 2 years ago | |
.idea | 2 years ago | |
.m2 | 2 years ago | |
Screenshots | 2 years ago | |
src | 2 years ago | |
.gitignore | 2 years ago | |
CODE_OF_CONDUCT.md | 2 years ago | |
LICENSE.txt | 2 years ago | |
README.md | 2 years ago | |
pom.xml | 2 years ago |
Step 1. Add the dependency
<dependency>
<groupId>com.anas.jcolorfulconsole</groupId>
<artifactId>jcolorfulconsole</artifactId>
<version>0.1.5</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.Anas-Elgarhy:JColorfulConsole:0.1.5'
}
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();
}
}