diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 8d9a428..9d14a8b 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -6,8 +6,10 @@ - + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..45875dc --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index db17962..6dc13aa 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/Screenshots/1.0.1-example1.png b/Screenshots/1.0.1-example1.png new file mode 100644 index 0000000..c02d52f Binary files /dev/null and b/Screenshots/1.0.1-example1.png differ diff --git a/Screenshots/1.0.1-example2.gif b/Screenshots/1.0.1-example2.gif new file mode 100644 index 0000000..4c988bf Binary files /dev/null and b/Screenshots/1.0.1-example2.gif differ diff --git a/src/main/java/test/Main.java b/src/main/java/test/Main.java deleted file mode 100644 index 692fdc9..0000000 --- a/src/main/java/test/Main.java +++ /dev/null @@ -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(); - } -}