mirror of
https://github.com/anas-elgarhy/JColorfulConsole.git
synced 2024-08-14 23:57:19 +00:00
commit
eb383d9c6f
6 changed files with 54 additions and 27 deletions
|
@ -6,8 +6,10 @@
|
||||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
<outputRelativeToContentRoot value="true" />
|
<outputRelativeToContentRoot value="true" />
|
||||||
<module name="JColorfulConsole" />
|
|
||||||
</profile>
|
</profile>
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
|
<bytecodeTargetLevel>
|
||||||
|
<module name="examples" target="1.8" />
|
||||||
|
</bytecodeTargetLevel>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/examples.iml" filepath="$PROJECT_DIR$/examples.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
43
README.md
43
README.md
|
@ -43,6 +43,49 @@ allprojects {
|
||||||
|
|
||||||
## Usage:
|
## 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:
|
## Requirements for development:
|
||||||
- Maven
|
- Maven
|
||||||
- jdk 17
|
- jdk 17
|
||||||
|
|
BIN
Screenshots/1.0.1-example1.png
Normal file
BIN
Screenshots/1.0.1-example1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
BIN
Screenshots/1.0.1-example2.gif
Normal file
BIN
Screenshots/1.0.1-example2.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 67 KiB |
|
@ -1,26 +0,0 @@
|
||||||
package test;
|
|
||||||
|
|
||||||
import com.anas.jcolorfulconsole.ColoredString;
|
|
||||||
import com.anas.jcolorfulconsole.TextStyle;
|
|
||||||
import com.anas.jcolorfulconsole.lanterna.TextColor;
|
|
||||||
|
|
||||||
public class Main {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
ColoredString coloredString = new ColoredString("Hello World", null, "blue", TextStyle.BOLD, TextStyle.ITALIC);
|
|
||||||
System.out.println(coloredString);
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue