{"id":26895899,"url":"https://github.com/magarcia/python-x256","last_synced_at":"2025-05-12T20:17:56.428Z","repository":{"id":3270774,"uuid":"4310138","full_name":"magarcia/python-x256","owner":"magarcia","description":"Find the nearest xterm 256 color index for an RGB.","archived":false,"fork":false,"pushed_at":"2022-01-30T09:34:47.000Z","size":27,"stargazers_count":25,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-02T03:45:59.395Z","etag":null,"topics":["x256","xterm"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/magarcia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-05-12T22:14:13.000Z","updated_at":"2025-02-07T04:01:14.000Z","dependencies_parsed_at":"2022-08-26T02:51:20.142Z","dependency_job_id":null,"html_url":"https://github.com/magarcia/python-x256","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/magarcia%2Fpython-x256","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magarcia%2Fpython-x256/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magarcia%2Fpython-x256/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magarcia%2Fpython-x256/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magarcia","download_url":"https://codeload.github.com/magarcia/python-x256/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253815028,"owners_count":21968563,"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":["x256","xterm"],"created_at":"2025-04-01T02:59:01.869Z","updated_at":"2025-05-12T20:17:56.401Z","avatar_url":"https://github.com/magarcia.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# x256 [![Tests](https://github.com/magarcia/python-x256/actions/workflows/test.yml/badge.svg)](https://github.com/magarcia/python-x256/actions/workflows/test.yml) [![Code Analysis](https://github.com/magarcia/python-x256/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/magarcia/python-x256/actions/workflows/codeql-analysis.yml) [![PyPI version](https://badge.fury.io/py/x256.svg)](https://pypi.org/project/x256/)\n\n_This is a python version from [node-x256](https://github.com/substack/node-x256)_\n\nReturn the nearest\n[xterm 256 color code](http://www.frexx.de/xterm-256-notes/)\nfor rgb inputs.\n\n# Example\n\nYou can just print the index:\n\n```python\nfrom x256 import x256\nix = x256.from_rgb(220, 40, 150)\nprint ix # 162\n```\n\nor you can use raw ansi escape codes:\n\n```python\nfrom x256 import x256\nix = x256.from_rgb(220, 40, 150)\nprint '\\x1b[38;5;' + str(ix) + 'mBEEEEEP'\n```\n\noutput:\n\n![x256 raw beep](./screenshots/x256_raw_beep.png)\n\n# Methods\n\n## x256.from_rgb(red, green, blue)\n\nReturn the nearest xterm 256 color code for the 24-bit `[red, green, blue]`\nvalues.\n\n`red`, `green`, and `blue` should each be integers from 0 through 255,\ninclusive.\n\n## x256.from_hex(hex)\n\nReturn the nearest xterm 256 color code for the hexadecimal color\nvalues.\n\n`hex` should be string without 0x.\n\n## x256.to_rgb(ix)\n\nReturn 24-bit `[red, green, blue]` values from xterm 256 color code.\n\n`ix` should be integer.\n\n## x256.to_hex(ix)\n\nReturn hexadecimal color from xterm 256 color code.\n\n`ix` should be integer.\n\n# Install\n\n```shell\npython -m pip install x256\n```\n\n# License\n\nCopyright (c) 2012 Martin Garcia (newluxfero@gmail.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagarcia%2Fpython-x256","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagarcia%2Fpython-x256","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagarcia%2Fpython-x256/lists"}