Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

method for converting colors (rgb) into a string of ANSI Escape code … #278

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/org/fusesource/jansi/io/Colors.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,8 @@ private static double pivotXyz(double n) {
private static double sqr(double n) {
return n * n;
}

public static String rgbToAnsi(int r, int g, int b) {
return String.format("\u001B[38;2;%d;%d;%dm", r, g, b);
}
}
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
16 changes: 8 additions & 8 deletions src/main/resources/org/fusesource/jansi/jansi.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[?7h
┌──┐┌─────┐ ┌─────┐ ┌──────┬──┐
│██├┘█████└┬┘█████└┬┘██████│▐▌│
┌──┐ │██│██▄▄▄██│██┌─┐██│██▄▄▄▄ │▄▄│
│▒▒└─┘▒█│▒█┌─┐▒█│▒█│ │▒█│ ▀▀▀▀▒█│▒█│
└┐▓▓▓▓▓┌┤▓▓│ │▓▓│▓▓│ │▓▓│▀▓▓▓▓▓▀│▓▓│
└─────┘└──┘ └──┴──┘ └──┴───────┴──┘

[?7h
┌──┐┌─────┐ ┌─────┐ ┌──────┬──┐
│██├┘█████└┬┘█████└┬┘██████│▐▌│
┌──┐ │██│██▄▄▄██│██┌─┐██│██▄▄▄▄ │▄▄│
│▒▒└─┘▒█│▒█┌─┐▒█│▒█│ │▒█│ ▀▀▀▀▒█│▒█│
└┐▓▓▓▓▓┌┤▓▓│ │▓▓│▓▓│ │▓▓│▀▓▓▓▓▓▀│▓▓│
└─────┘└──┘ └──┴──┘ └──┴───────┴──┘

Empty file modified src/test/java/org/fusesource/jansi/AnsiConsoleExample2.java
100755 → 100644
Empty file.
13 changes: 13 additions & 0 deletions src/test/java/org/fusesource/jansi/RbgToAnsiExample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.fusesource.jansi;

import org.fusesource.jansi.io.Colors;

public class RbgToAnsiExample {


public static void main(String[] args){
System.out.println(Colors.rgbToAnsi(100,200,200));
System.out.println("text");
}

}
16 changes: 8 additions & 8 deletions src/test/resources/jansi.ans
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[?7h
��Ŀ�����Ŀ �����Ŀ ���������Ŀ
�������������������������������
��Ŀ ���������������Ŀ��������� ����
������������Ŀ������ ���� ���߱�����
�������ڴ��� ������� ����߲���������
����������� ������� ���������������

[?7h
��Ŀ�����Ŀ �����Ŀ ���������Ŀ
�������������������������������
��Ŀ ���������������Ŀ��������� ����
������������Ŀ������ ���� ���߱�����
�������ڴ��� ������� ����߲���������
����������� ������� ���������������