{"id":19511692,"url":"https://github.com/thecodetherapy/color_ansi_rgb","last_synced_at":"2025-04-26T03:32:36.626Z","repository":{"id":149947208,"uuid":"112006028","full_name":"TheCodeTherapy/color_ansi_rgb","owner":"TheCodeTherapy","description":"A small Python 3 class to handle ANSI Escape Code and convert RGB hexadecimal color values (as in #FF3100) and text decorations to print fancy text on modern terminal emulators.","archived":false,"fork":false,"pushed_at":"2017-11-25T13:35:18.000Z","size":3,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-04T07:51:07.456Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TheCodeTherapy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-25T13:34:30.000Z","updated_at":"2023-10-01T12:44:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"d23ce14f-ad6d-4322-b633-97e195a7e16d","html_url":"https://github.com/TheCodeTherapy/color_ansi_rgb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheCodeTherapy%2Fcolor_ansi_rgb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheCodeTherapy%2Fcolor_ansi_rgb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheCodeTherapy%2Fcolor_ansi_rgb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheCodeTherapy%2Fcolor_ansi_rgb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheCodeTherapy","download_url":"https://codeload.github.com/TheCodeTherapy/color_ansi_rgb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250926949,"owners_count":21509059,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T23:22:17.558Z","updated_at":"2025-04-26T03:32:36.619Z","avatar_url":"https://github.com/TheCodeTherapy.png","language":"Python","readme":"# color_ansi_rgb\n\nThis is a small class that I wrote to be able to handle **ANSI escape code** on gnome-terminal / mate-terminal without importing fancy libs with lots of stuff that I don't actually need. It should work fine on any terminal emulator with 256 colors support as it basically handle ANSI escape codes. It can convert hexadecimal RGB values (as in *#FF3100*) into the closest ANSI value available, so you can use RGB colors to print to the terminal.\n\nAs I just needed to be able to handle foreground/background colors and font decoration I focused on that and wrote some methods to control it as straightforwardly as I could.\n\nTo handle all the possible colors, the class basically generates the 216 values in a 6x6x6 predefined ANSI cube matrix as per it's pre-determined value increments, besides attributing the standard ANSI values for the 16 basic colors and 16 shades of gray.\n\nAvailable text styles are:\n* 'normal'\n* 'bold'\n* 'dim'\n* 'italic'\n* 'underline'\n* 'blink' **(\\*)**\n* 'reverse'\n\n**NOTE\\*:** *Fortunately* most modern terminals and terminal emulators do not support blinking text style anymore. I added the escape sequence to control that though, as it's escape code may be implemented as an alternative looking highlighting style by some terminal emulators. On gnome-terminal or mate-terminal it will just show regular text.\n\n#### TO DO (when more free/bored time reveals itself available :):\n1. rewrite it with a test driven mindset.\n1. document it\n1. ?optimize the closest_rgb method as it feels a little bit *hackish* right now\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodetherapy%2Fcolor_ansi_rgb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecodetherapy%2Fcolor_ansi_rgb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodetherapy%2Fcolor_ansi_rgb/lists"}