{"id":407410,"date":"2024-06-29T19:32:41","date_gmt":"2024-06-29T19:32:41","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=407410"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=407410","title":{"rendered":"<span>\u041a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f ( \u043e\u0442 \u0427\u0411 \u0434\u043e 24bit )<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441 \u043e\u0442 \u0427\u0411 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0434\u043e 24 bit \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438  <\/p>\n<ol>\n<li>\n<p>\u0427\u0411  <\/p>\n<\/li>\n<li>\n<p>48 \u0446\u0432\u0435\u0442\u043e\u0432  <\/p>\n<\/li>\n<li>\n<p>216 \u0446\u0432\u0435\u0442\u043e\u0432  <\/p>\n<\/li>\n<li>\n<p>24bit  <\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c37\/101\/4af\/c371014af50ec85f02a88a2499ed4e64.png\" alt=\"\u043c\u043e\u044f \u043f\u043b\u044e\u0448\u0435\u0432\u0430\u044f \u0438\u0433\u0440\u0443\u0448\u043a\u0430 \u043d\u0430 \u0444\u043e\u043d\u0435 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0430, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438\" title=\"\u043c\u043e\u044f \u043f\u043b\u044e\u0448\u0435\u0432\u0430\u044f \u0438\u0433\u0440\u0443\u0448\u043a\u0430 \u043d\u0430 \u0444\u043e\u043d\u0435 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0430, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438\" width=\"1592\" height=\"1107\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c37\/101\/4af\/c371014af50ec85f02a88a2499ed4e64.png\"\/><figcaption>\u043c\u043e\u044f \u043f\u043b\u044e\u0448\u0435\u0432\u0430\u044f \u0438\u0433\u0440\u0443\u0448\u043a\u0430 \u043d\u0430 \u0444\u043e\u043d\u0435 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0430, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438<\/figcaption><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/7a1\/4a7\/396\/7a14a7396fd3b46c5c2645fa68893d1e.jpg\" alt=\"\u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438\" title=\"\u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438\" width=\"1600\" height=\"1200\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7a1\/4a7\/396\/7a14a7396fd3b46c5c2645fa68893d1e.jpg\" data-blurred=\"true\"\/><figcaption>\u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438<\/figcaption><\/figure>\n<h2>\u0422\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u043f\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u044e\u0449\u0435\u0439 \u044f\u0440\u043a\u043e\u0441\u0442\u0438<\/p>\n<pre><code class=\"python\">block_table: list[str] = [\" \", \"\u2582\", \"\u2583\", \"\u2584\",                           \"\u2585\", \"\u2586\", \"\u2587\", \"\u2588\"] <\/code><\/pre>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0439\u0442\u0435 PIL.Image<\/p>\n<p>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u044c\u0442\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438:<\/p>\n<ul>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0432\u0435\u0434\u0438\u0442\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 RGB<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u044e<\/p>\n<\/li>\n<li>\n<p>\u0421\u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u043a\u043e\u043f\u0438\u044e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 Grayscale<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">from PIL.Image import Image  size: tuple[int, int] = (..., ...) image: Image = Image.open(\"filepath.extension\").resize(size) image = image.convert(\"RGB\") image_grayscale: Image = image.convert(\"L\") <\/code><\/pre>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u044f\u0440\u043a\u043e\u0441\u0442\u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0432 \u0441\u0438\u043c\u0432\u043e\u043b \u043d\u0430\u0448\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/p>\n<details class=\"spoiler\">\n<summary>\u0427\u0435\u0440\u0435\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u044e<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def bright_to_symbol(bright: int) -> str:   return block_table[round(bright \/ 255 * (len(block_table) - 1))] <\/code><\/pre>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0427\u0435\u0440\u0435\u0437 \u043b\u044f\u043c\u0431\u0434\u0443<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">bright_to_symbol: typing.Callable[[int], str] = \\ lambda bright: block_table[   round(bright \/ 255 * (len(block_table) - 1))]<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u043f\u043e grayscale \u043a\u043e\u043f\u0438\u0438 \u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u044f\u0440\u043a\u043e\u0441\u0442\u044c \u0432 \u0441\u0438\u043c\u0432\u043e\u043b\u044b, \u0432\u044b\u0432\u043e\u0434\u044f \u0432\u0441\u0451 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c<\/p>\n<pre><code class=\"python\">for i in range(image.height):   for j in range(image.width):     print(bright_to_symbol(        image_grayscale.getpixel((j, i))),          end = \"\") print()   <\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2d4\/664\/195\/2d46641958fe184abbe9e9b93ea12082.png\" alt=\"\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0438\u0437 \u043c\u0430\u0439\u043d\u043a\u0440\u0430\u0444\u0442\u0430 \u0441 \u0448\u0435\u0439\u0434\u0435\u0440\u0430\u043c\u0438\" title=\"\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0438\u0437 \u043c\u0430\u0439\u043d\u043a\u0440\u0430\u0444\u0442\u0430 \u0441 \u0448\u0435\u0439\u0434\u0435\u0440\u0430\u043c\u0438\" width=\"1596\" height=\"1115\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2d4\/664\/195\/2d46641958fe184abbe9e9b93ea12082.png\"\/><figcaption>\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0438\u0437 \u043c\u0430\u0439\u043d\u043a\u0440\u0430\u0444\u0442\u0430 \u0441 \u0448\u0435\u0439\u0434\u0435\u0440\u0430\u043c\u0438<\/figcaption><\/figure>\n<h2>48 \u0446\u0432\u0435\u0442\u043e\u0432<\/h2>\n<p>8 \u0438 16 \u0446\u0432\u0435\u0442\u043e\u0432 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0432\u043e\u043e\u0431\u0449\u0435 \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e<\/p>\n<p>\u0414\u043b\u044f \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f 48 \u0446\u0432\u0435\u0442\u043e\u0432 \u0438\u0437 16 \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0430\u0445 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0438\u043b\u0438 BRIGHT \u0438 DIM, \u0447\u0442\u043e\u0431\u044b \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0446\u0432\u0435\u0442\u0443 \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u0442\u044c 2 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0441\u0442\u0438\u043b\u044f\u043c\u0438<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0430\u043b\u0438\u0442\u0440\u0443 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043b\u0430\u043d\u0430<\/p>\n<pre><code class=\"python\">colors: typing.Dict[str, typing.List[str]] = \\     {\"GREEN\": [colorama.Style.DIM + colorama.Fore.GREEN,                colorama.Fore.GREEN,                colorama.Style.BRIGHT + colorama.Fore.GREEN,                colorama.Style.DIM + colorama.Fore.LIGHTGREEN_EX,                colorama.Fore.LIGHTGREEN_EX, colorama.Style.BRIGHT +                colorama.Fore.LIGHTGREEN_EX                ], ... : [...]     } <\/code><\/pre>\n<p>\u041f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0446\u0432\u0435\u0442\u043e\u0432\u044b\u0435 \u0433\u0440\u0430\u043d\u0438\u0446\u044b<\/p>\n<pre><code class=\"python\">def color_it48(color: typing.Tuple[int, int, int]) -> str:     \"\"\"48 colors\"\"\"     if all([col > 240 for col in color]) \\             and color[0] * 3 - 10 &lt; sum(color) &lt; color[0] * 3 + 10:         return colors[\"WHITE\"][             round((len(colors[\"WHITE\"]) - 1)                   \/ 255 * (color[1] + color[2]) \/ 2)]     if all([col &lt; 30 for col in color]) \\             and color[0] * 3 - 10 &lt; sum(color) &lt; color[0] * 3 + 10:         return colors[\"BLACK\"][             round((len(colors[\"BLACK\"]) - 1)                   \/ 255 * (color[1] + color[2]) \/ 2)]     if max(color) == color[1] and color[1] > color[0] + color[2] - 20:         return colors[\"GREEN\"][             round((len(colors[\"GREEN\"]) - 1)                   \/ 255 * color[1])]     if max(color) == color[0] and color[0] > sum(color[1:3]) - 20:         return colors[\"RED\"][             round((len(colors[\"RED\"]) - 1)                   \/ 255 * color[0])]     if max(color) == color[2] and color[2] > sum(color[0:2]) - 20:         return colors[\"BLUE\"][             round((len(colors[\"BLUE\"]) - 1)                   \/ 255 * color[0])]     if color[1] + color[2] > color[0] * 2 + 40:         return colors[\"CYAN\"][             round((len(colors[\"CYAN\"]) - 1)                   \/ 255 * (color[1] + color[2]) \/ 2)]     if color[0] + color[2] > color[1] * 2 + 40:         return colors[\"MAGENTA\"][             round((len(colors[\"MAGENTA\"]) - 1)                   \/ 255 * (color[2] + color[1]) \/ 2)]     if sum(color[0:2]) > color[2] * 2 + 40:         return colors[\"YELLOW\"][             round((len(colors[\"YELLOW\"]) - 1)                   \/ 255 * (color[1] + color[0]) \/ 2)]     return \"\"   <\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0446\u0432\u0435\u0442\u0430 \u0432 \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442<\/p>\n<pre><code class=\"python\">for i in range(0, image.height):   for j in range(0, image.width):     print(color_it48(image.getpixel((j, i))) +           bright_to_symbol(image_grayscale.getpixel((j, i))),           end='')   print() <\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/399\/423\/3fe\/3994233fe306420d6131404297a4a348.png\" alt=\"48 \u0446\u0432\u0435\u0442\u043e\u0432, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u0442\u0440\u0430\u0448\u043d\u043e\" title=\"48 \u0446\u0432\u0435\u0442\u043e\u0432, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u0442\u0440\u0430\u0448\u043d\u043e\" width=\"1589\" height=\"1119\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/399\/423\/3fe\/3994233fe306420d6131404297a4a348.png\"\/><figcaption>48 \u0446\u0432\u0435\u0442\u043e\u0432, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u0442\u0440\u0430\u0448\u043d\u043e<\/figcaption><\/figure>\n<h2>216 \u0446\u0432\u0435\u0442\u043e\u0432<\/h2>\n<p>\u0414\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0440\u0430\u0441\u0446\u0432\u0435\u0442\u043a\u0438 \u0432\u0430\u0448 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c xterm-256colors<\/p>\n<p><a href=\"https:\/\/robotmoon.com\/256-colors\/\" rel=\"noopener noreferrer nofollow\">https:\/\/robotmoon.com\/256-colors\/<\/a><br \/>\u0415\u0441\u043b\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c RGB \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0446\u0432\u0435\u0442\u043e\u0432, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438  \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c<\/p>\n<pre><code class=\"python\">pal: typing.List[int] = [0, 95, 135, 175, 215, 255] <\/code><\/pre>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f RGB \u0446\u0432\u0435\u0442\u043e\u0432 \u043a xterm-256colors \u043d\u043e\u043c\u0435\u0440\u0443 \u0446\u0432\u0435\u0442\u0430 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442 \u043a \u043a\u0430\u043a\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c \u0431\u043b\u0438\u0436\u0435 \u0432\u0441\u0435\u0433\u043e \u0446\u0432\u0435\u0442<br \/>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 (100, 100, 100) -> [1, 1, 1] \u0442.\u0435 (95, 95, 95)<\/p>\n<pre><code class=\"python\">def get_pal(color: typing.Tuple[int, int, int]) -> typing.List[int]:     \"\"\"Get nearest value of pal to color's rgb\"\"\"     col_data: typing.List[int] = []     for col in color:         added: bool = False         for i in enumerate(pal[1:]):             added = False             if (col - pal[i[0]]) \/ (i[1] - pal[i[0]]) &lt; 0.5:                 col_data.append(i[0])                 added = True                 break         if not added:             col_data.append(len(pal) - 1)     return col_data   <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u044d\u0442\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0432 \u043d\u043e\u043c\u0435\u0440 xterm \u0446\u0432\u0435\u0442\u0430, \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0435 16 \u0446\u0432\u0435\u0442\u043e\u0432 \u0437\u0430\u043d\u044f\u0442\u044b \u0438 \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/p>\n<pre><code class=\"python\">def color_it216(color: typing.Tuple[int, int, int]) -> str:     \"\"\"216 colors\"\"\"     color_data: typing.List[int] = get_pal(color)     color_num: int = sum([6 ** (len(color_data) - index - 1) * data                           for index, data in enumerate(color_data)])     return f\"\\033[38;05;\" \\            f\"{16 + color_num }m\"<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0ad\/335\/cac\/0ad335caca37de3b668cf232b37a13a7.png\" alt=\"\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0443\u0434\u0430 \u043f\u0440\u0438\u044f\u0442\u043d\u0435\u0435\" title=\"\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0443\u0434\u0430 \u043f\u0440\u0438\u044f\u0442\u043d\u0435\u0435\" width=\"1583\" height=\"1105\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0ad\/335\/cac\/0ad335caca37de3b668cf232b37a13a7.png\"\/><figcaption>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0443\u0434\u0430 \u043f\u0440\u0438\u044f\u0442\u043d\u0435\u0435<\/figcaption><\/figure>\n<h2>24bit<\/h2>\n<p>\u041d\u0430 \u0443\u0434\u0438\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0430\u043c\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0447\u0430\u0441\u0442\u044c, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u043e\u0432<br \/><a href=\"https:\/\/gist.github.com\/XVilka\/8346728\" rel=\"noopener noreferrer nofollow\">https:\/\/gist.github.com\/XVilka\/8346728<\/a><\/p>\n<pre><code class=\"python\">def color_it_full(color: typing.Tuple[int, int, int]) -> str:     \"\"\"Full rgb\"\"\"     return f\"\\033[38;02;{color[0]};{color[1]};{color[2]}m\"<\/code><\/pre>\n<p>\u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u0438 \u0432\u0441\u0451:D<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/23f\/945\/36c\/23f94536c08dff7625899719338503dd.png\" alt=\"\u0412\u043e\u0442 \u044d\u0442\u043e \u043a\u0440\u0430\u0441\u043e\u0442\u0430\" title=\"\u0412\u043e\u0442 \u044d\u0442\u043e \u043a\u0440\u0430\u0441\u043e\u0442\u0430\" width=\"1600\" height=\"1171\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/23f\/945\/36c\/23f94536c08dff7625899719338503dd.png\"\/><figcaption>\u0412\u043e\u0442 \u044d\u0442\u043e \u043a\u0440\u0430\u0441\u043e\u0442\u0430<\/figcaption><\/figure>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 (\u0442\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u043f\u043e\u043a\u0430\u0437 \u0433\u0438\u0444\u043e\u043a \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438): <a href=\"https:\/\/github.com\/LedinecMing\/console_images\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/LedinecMing\/console_images<\/a><\/p>\n<h2>\u0426\u0432\u0435\u0442\u043d\u044b\u0435 \u043a\u0440\u0443\u0433\u0438 \u0432\u0441\u0435\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432<\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/dc1\/203\/5b7\/dc12035b73e0331519149a819e8cc59f.png\" width=\"1593\" height=\"1064\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/dc1\/203\/5b7\/dc12035b73e0331519149a819e8cc59f.png\"\/><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bf7\/171\/60e\/bf717160e841108e469298bd2d7ede84.png\" width=\"1593\" height=\"1114\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bf7\/171\/60e\/bf717160e841108e469298bd2d7ede84.png\"\/><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cbc\/ab7\/b3e\/cbcab7b3e31701d9f27308786e5fbb4f.png\" width=\"1588\" height=\"1116\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cbc\/ab7\/b3e\/cbcab7b3e31701d9f27308786e5fbb4f.png\"\/><figcaption><\/figcaption><\/figure>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/589017\/\"> https:\/\/habr.com\/ru\/articles\/589017\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441 \u043e\u0442 \u0427\u0411 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0434\u043e 24 bit \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438  <\/p>\n<ol>\n<li>\n<p>\u0427\u0411  <\/p>\n<\/li>\n<li>\n<p>48 \u0446\u0432\u0435\u0442\u043e\u0432  <\/p>\n<\/li>\n<li>\n<p>216 \u0446\u0432\u0435\u0442\u043e\u0432  <\/p>\n<\/li>\n<li>\n<p>24bit  <\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><figcaption>\u043c\u043e\u044f \u043f\u043b\u044e\u0448\u0435\u0432\u0430\u044f \u0438\u0433\u0440\u0443\u0448\u043a\u0430 \u043d\u0430 \u0444\u043e\u043d\u0435 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0430, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438<\/figcaption><\/figure>\n<figure class=\"full-width\"><figcaption>\u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438<\/figcaption><\/figure>\n<h2>\u0422\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u043f\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u044e\u0449\u0435\u0439 \u044f\u0440\u043a\u043e\u0441\u0442\u0438<\/p>\n<pre><code class=\"python\">block_table: list[str] = [\" \", \"\u2582\", \"\u2583\", \"\u2584\",                           \"\u2585\", \"\u2586\", \"\u2587\", \"\u2588\"] <\/code><\/pre>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0439\u0442\u0435 PIL.Image<\/p>\n<p>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u044c\u0442\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438:<\/p>\n<ul>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0432\u0435\u0434\u0438\u0442\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 RGB<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u044e<\/p>\n<\/li>\n<li>\n<p>\u0421\u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u043a\u043e\u043f\u0438\u044e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 Grayscale<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">from PIL.Image import Image  size: tuple[int, int] = (..., ...) image: Image = Image.open(\"filepath.extension\").resize(size) image = image.convert(\"RGB\") image_grayscale: Image = image.convert(\"L\") <\/code><\/pre>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u044f\u0440\u043a\u043e\u0441\u0442\u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0432 \u0441\u0438\u043c\u0432\u043e\u043b \u043d\u0430\u0448\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/p>\n<details class=\"spoiler\">\n<summary>\u0427\u0435\u0440\u0435\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u044e<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def bright_to_symbol(bright: int) -> str:   return block_table[round(bright \/ 255 * (len(block_table) - 1))] <\/code><\/pre>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0427\u0435\u0440\u0435\u0437 \u043b\u044f\u043c\u0431\u0434\u0443<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">bright_to_symbol: typing.Callable[[int], str] = \\ lambda bright: block_table[   round(bright \/ 255 * (len(block_table) - 1))]<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u043f\u043e grayscale \u043a\u043e\u043f\u0438\u0438 \u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u044f\u0440\u043a\u043e\u0441\u0442\u044c \u0432 \u0441\u0438\u043c\u0432\u043e\u043b\u044b, \u0432\u044b\u0432\u043e\u0434\u044f \u0432\u0441\u0451 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c<\/p>\n<pre><code class=\"python\">for i in range(image.height):   for j in range(image.width):     print(bright_to_symbol(        image_grayscale.getpixel((j, i))),          end = \"\") print()   <\/code><\/pre>\n<figure class=\"full-width\"><figcaption>\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0438\u0437 \u043c\u0430\u0439\u043d\u043a\u0440\u0430\u0444\u0442\u0430 \u0441 \u0448\u0435\u0439\u0434\u0435\u0440\u0430\u043c\u0438<\/figcaption><\/figure>\n<h2>48 \u0446\u0432\u0435\u0442\u043e\u0432<\/h2>\n<p>8 \u0438 16 \u0446\u0432\u0435\u0442\u043e\u0432 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0432\u043e\u043e\u0431\u0449\u0435 \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e<\/p>\n<p>\u0414\u043b\u044f \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f 48 \u0446\u0432\u0435\u0442\u043e\u0432 \u0438\u0437 16 \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0430\u0445 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0438\u043b\u0438 BRIGHT \u0438 DIM, \u0447\u0442\u043e\u0431\u044b \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0446\u0432\u0435\u0442\u0443 \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u0442\u044c 2 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0441\u0442\u0438\u043b\u044f\u043c\u0438<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0430\u043b\u0438\u0442\u0440\u0443 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043b\u0430\u043d\u0430<\/p>\n<pre><code class=\"python\">colors: typing.Dict[str, typing.List[str]] = \\     {\"GREEN\": [colorama.Style.DIM + colorama.Fore.GREEN,                colorama.Fore.GREEN,                colorama.Style.BRIGHT + colorama.Fore.GREEN,                colorama.Style.DIM + colorama.Fore.LIGHTGREEN_EX,                colorama.Fore.LIGHTGREEN_EX, colorama.Style.BRIGHT +                colorama.Fore.LIGHTGREEN_EX                ], ... : [...]     } <\/code><\/pre>\n<p>\u041f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0446\u0432\u0435\u0442\u043e\u0432\u044b\u0435 \u0433\u0440\u0430\u043d\u0438\u0446\u044b<\/p>\n<pre><code class=\"python\">def color_it48(color: typing.Tuple[int, int, int]) -> str:     \"\"\"48 colors\"\"\"     if all([col > 240 for col in color]) \\             and color[0] * 3 - 10 &lt; sum(color) &lt; color[0] * 3 + 10:         return colors[\"WHITE\"][             round((len(colors[\"WHITE\"]) - 1)                   \/ 255 * (color[1] + color[2]) \/ 2)]     if all([col &lt; 30 for col in color]) \\             and color[0] * 3 - 10 &lt; sum(color) &lt; color[0] * 3 + 10:         return colors[\"BLACK\"][             round((len(colors[\"BLACK\"]) - 1)                   \/ 255 * (color[1] + color[2]) \/ 2)]     if max(color) == color[1] and color[1] > color[0] + color[2] - 20:         return colors[\"GREEN\"][             round((len(colors[\"GREEN\"]) - 1)                   \/ 255 * color[1])]     if max(color) == color[0] and color[0] > sum(color[1:3]) - 20:         return colors[\"RED\"][             round((len(colors[\"RED\"]) - 1)                   \/ 255 * color[0])]     if max(color) == color[2] and color[2] > sum(color[0:2]) - 20:         return colors[\"BLUE\"][             round((len(colors[\"BLUE\"]) - 1)                   \/ 255 * color[0])]     if color[1] + color[2] > color[0] * 2 + 40:         return colors[\"CYAN\"][             round((len(colors[\"CYAN\"]) - 1)                   \/ 255 * (color[1] + color[2]) \/ 2)]     if color[0] + color[2] > color[1] * 2 + 40:         return colors[\"MAGENTA\"][             round((len(colors[\"MAGENTA\"]) - 1)                   \/ 255 * (color[2] + color[1]) \/ 2)]     if sum(color[0:2]) > color[2] * 2 + 40:         return colors[\"YELLOW\"][             round((len(colors[\"YELLOW\"]) - 1)                   \/ 255 * (color[1] + color[0]) \/ 2)]     return \"\"   <\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0446\u0432\u0435\u0442\u0430 \u0432 \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442<\/p>\n<pre><code class=\"python\">for i in range(0, image.height):   for j in range(0, image.width):     print(color_it48(image.getpixel((j, i))) +           bright_to_symbol(image_grayscale.getpixel((j, i))),           end='')   print() <\/code><\/pre>\n<figure class=\"full-width\"><figcaption>48 \u0446\u0432\u0435\u0442\u043e\u0432, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u0442\u0440\u0430\u0448\u043d\u043e<\/figcaption><\/figure>\n<h2>216 \u0446\u0432\u0435\u0442\u043e\u0432<\/h2>\n<p>\u0414\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0440\u0430\u0441\u0446\u0432\u0435\u0442\u043a\u0438 \u0432\u0430\u0448 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c xterm-256colors<\/p>\n<p><a href=\"https:\/\/robotmoon.com\/256-colors\/\" rel=\"noopener noreferrer nofollow\">https:\/\/robotmoon.com\/256-colors\/<\/a><br \/>\u0415\u0441\u043b\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c RGB \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0446\u0432\u0435\u0442\u043e\u0432, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438  \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c<\/p>\n<pre><code class=\"python\">pal: typing.List[int] = [0, 95, 135, 175, 215, 255] <\/code><\/pre>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f RGB \u0446\u0432\u0435\u0442\u043e\u0432 \u043a xterm-256colors \u043d\u043e\u043c\u0435\u0440\u0443 \u0446\u0432\u0435\u0442\u0430 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442 \u043a \u043a\u0430\u043a\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c \u0431\u043b\u0438\u0436\u0435 \u0432\u0441\u0435\u0433\u043e \u0446\u0432\u0435\u0442<br \/>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 (100, 100, 100) -> [1, 1, 1] \u0442.\u0435 (95, 95, 95)<\/p>\n<pre><code class=\"python\">def get_pal(color: typing.Tuple[int, int, int]) -> typing.List[int]:     \"\"\"Get nearest value of pal to color's rgb\"\"\"     col_data: typing.List[int] = []     for col in color:         added: bool = False         for i in enumerate(pal[1:]):             added = False             if (col - pal[i[0]]) \/ (i[1] - pal[i[0]]) &lt; 0.5:                 col_data.append(i[0])                 added = True                 break         if not added:             col_data.append(len(pal) - 1)     return col_data   <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u044d\u0442\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0432 \u043d\u043e\u043c\u0435\u0440 xterm \u0446\u0432\u0435\u0442\u0430, \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0435 16 \u0446\u0432\u0435\u0442\u043e\u0432 \u0437\u0430\u043d\u044f\u0442\u044b \u0438 \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/p>\n<pre><code class=\"python\">def color_it216(color: typing.Tuple[int, int, int]) -> str:     \"\"\"216 colors\"\"\"     color_data: typing.List[int] = get_pal(color)     color_num: int = sum([6 ** (len(color_data) - index - 1) * data                           for index, data in enumerate(color_data)])     return f\"\\033[38;05;\" \\            f\"{16 + color_num }m\"<\/code><\/pre>\n<figure class=\"full-width\"><figcaption>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0443\u0434\u0430 \u043f\u0440\u0438\u044f\u0442\u043d\u0435\u0435<\/figcaption><\/figure>\n<h2>24bit<\/h2>\n<p>\u041d\u0430 \u0443\u0434\u0438\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0430\u043c\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0447\u0430\u0441\u0442\u044c, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u043e\u0432<br \/><a href=\"https:\/\/gist.github.com\/XVilka\/8346728\" rel=\"noopener noreferrer nofollow\">https:\/\/gist.github.com\/XVilka\/8346728<\/a><\/p>\n<pre><code class=\"python\">def color_it_full(color: typing.Tuple[int, int, int]) -> str:     \"\"\"Full rgb\"\"\"     return f\"\\033[38;02;{color[0]};{color[1]};{color[2]}m\"<\/code><\/pre>\n<p>\u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u0438 \u0432\u0441\u0451:D<\/p>\n<figure class=\"full-width\"><figcaption>\u0412\u043e\u0442 \u044d\u0442\u043e \u043a\u0440\u0430\u0441\u043e\u0442\u0430<\/figcaption><\/figure>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 (\u0442\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u043f\u043e\u043a\u0430\u0437 \u0433\u0438\u0444\u043e\u043a \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438): <a href=\"https:\/\/github.com\/LedinecMing\/console_images\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/LedinecMing\/console_images<\/a><\/p>\n<h2>\u0426\u0432\u0435\u0442\u043d\u044b\u0435 \u043a\u0440\u0443\u0433\u0438 \u0432\u0441\u0435\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432<\/h2>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/589017\/\"> https:\/\/habr.com\/ru\/articles\/589017\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-407410","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/407410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=407410"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/407410\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=407410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=407410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=407410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}