{"id":167749,"date":"2022-04-09T08:57:43","date_gmt":"2022-04-09T00:57:43","guid":{"rendered":"http:\/\/www.idc.net\/help\/167749\/"},"modified":"2022-04-09T08:57:43","modified_gmt":"2022-04-09T00:57:43","slug":"%e5%90%8e%e6%b5%aa%e4%ba%91python%e6%95%99%e7%a8%8b%ef%bc%9acolorsys-%e9%a2%9c%e8%89%b2%e7%b3%bb%e7%bb%9f%e9%97%b4%e7%9a%84%e8%bd%ac%e6%8d%a2","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/167749\/","title":{"rendered":"\u540e\u6d6a\u4e91Python\u6559\u7a0b\uff1acolorsys \u2014- \u989c\u8272\u7cfb\u7edf\u95f4\u7684\u8f6c\u6362"},"content":{"rendered":"<h1>colorsys \u2014- \u989c\u8272\u7cfb\u7edf\u95f4\u7684\u8f6c\u6362<\/h1>\n<p><strong>\u6e90\u4ee3\u7801\uff1a<\/strong> Lib\/colorsys.py<\/p>\n<hr>\n<p>colorsys \u6a21\u5757\u5b9a\u4e49\u4e86\u8ba1\u7b97\u673a\u663e\u793a\u5668\u6240\u7528\u7684 RGB (Red Green Blue) \u8272\u5f69\u7a7a\u95f4\u4e0e\u4e09\u79cd\u5176\u4ed6\u8272\u5f69\u5750\u6807\u7cfb\u7edf YIQ, HLS (Hue Lightness Saturation) \u548c HSV (Hue Saturation Value) \u8868\u793a\u7684\u989c\u8272\u503c\u4e4b\u95f4\u7684\u53cc\u5411\u8f6c\u6362\u3002 \u6240\u6709\u8fd9\u4e9b\u8272\u5f69\u7a7a\u95f4\u7684\u5750\u6807\u90fd\u4f7f\u7528\u6d6e\u70b9\u6570\u503c\u6765\u8868\u793a\u3002 \u5728 YIQ \u7a7a\u95f4\u4e2d\uff0cY \u5750\u6807\u53d6\u503c\u4e3a 0 \u548c 1 \u4e4b\u95f4\uff0c\u800c I \u548c Q \u5750\u6807\u5747\u53ef\u4ee5\u4e3a\u6b63\u6570\u6216\u8d1f\u6570\u3002 \u5728\u6240\u6709\u5176\u4ed6\u7a7a\u95f4\u4e2d\uff0c\u5750\u6807\u53d6\u503c\u5747\u4e3a 0 \u548c 1 \u4e4b\u95f4\u3002<\/p>\n<p>\u53c2\u89c1<\/p>\n<p>\u6709\u5173\u8272\u5f69\u7a7a\u95f4\u7684\u66f4\u591a\u4fe1\u606f\u53ef\u8bbf\u95ee https:\/\/poynton.ca\/ColorFAQ.html \u548c https:\/\/www.cambridgeincolour.com\/tutorials\/color-spaces.htm\u3002<\/p>\n<p>colorsys \u6a21\u5757\u5b9a\u4e49\u4e86\u5982\u4e0b\u51fd\u6570\uff1a<\/p>\n<p>colorsys.rgb_to_yiq(<em>r<\/em>, <em>g<\/em>, <em>b<\/em>)<\/p>\n<p>\u628a\u989c\u8272\u4eceRGB\u503c\u8f6c\u4e3aYIQ\u503c\u3002<\/p>\n<p>colorsys.yiq_to_rgb(<em>y<\/em>, <em>i<\/em>, <em>q<\/em>)<\/p>\n<p>\u628a\u989c\u8272\u4eceYIQ\u503c\u8f6c\u4e3aRGB\u503c\u3002<\/p>\n<p>colorsys.rgb_to_hls(<em>r<\/em>, <em>g<\/em>, <em>b<\/em>)<\/p>\n<p>\u628a\u989c\u8272\u4eceRGB\u503c\u8f6c\u4e3aHLS\u503c\u3002<\/p>\n<p>colorsys.hls_to_rgb(<em>h<\/em>, <em>l<\/em>, <em>s<\/em>)<\/p>\n<p>\u628a\u989c\u8272\u4eceHLS\u503c\u8f6c\u4e3aRGB\u503c\u3002<\/p>\n<p>colorsys.rgb_to_hsv(<em>r<\/em>, <em>g<\/em>, <em>b<\/em>)<\/p>\n<p>\u628a\u989c\u8272\u4eceRGB\u503c\u8f6c\u4e3aHSV\u503c\u3002<\/p>\n<p>colorsys.hsv_to_rgb(<em>h<\/em>, <em>s<\/em>, <em>v<\/em>)<\/p>\n<p>\u628a\u989c\u8272\u4eceHSV\u503c\u8f6c\u4e3aRGB\u503c\u3002<\/p>\n<p>\u793a\u4f8b:<\/p>\n<pre>\n \n \n \n <ol>\n  \n  \n  \n  <li><code><span>&gt;&gt;&gt;<\/span><span> <\/span><span>import<\/span><span> colorsys<\/span><\/code><\/li>\n  \n  \n  \n  <li><code><span>&gt;&gt;&gt;<\/span><span> colorsys<\/span><span>.<\/span><span>rgb_to_hsv<\/span><span>(<\/span><span>0.2<\/span><span>,<\/span><span> <\/span><span>0.4<\/span><span>,<\/span><span> <\/span><span>0.4<\/span><span>)<\/span><\/code><\/li>\n  \n  \n  \n  <li><code><span>(<\/span><span>0.5<\/span><span>,<\/span><span> <\/span><span>0.5<\/span><span>,<\/span><span> <\/span><span>0.4<\/span><span>)<\/span><\/code><\/li>\n  \n  \n  \n  <li><code><span>&gt;&gt;&gt;<\/span><span> colorsys<\/span><span>.<\/span><span>hsv_to_rgb<\/span><span>(<\/span><span>0.5<\/span><span>,<\/span><span> <\/span><span>0.5<\/span><span>,<\/span><span> <\/span><span>0.4<\/span><span>)<\/span><\/code><\/li>\n  \n  \n  \n  <li><code><span>(<\/span><span>0.2<\/span><span>,<\/span><span> <\/span><span>0.4<\/span><span>,<\/span><span> <\/span><span>0.4<\/span><span>)<\/span><\/code><\/li>\n \n \n \n <\/ol><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>colorsys \u2014- \u989c\u8272\u7cfb\u7edf\u95f4\u7684\u8f6c\u6362 \u6e90\u4ee3\u7801\uff1a Lib\/colorsys.py colorsys \u6a21\u5757\u5b9a\u4e49 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[182397],"tags":[],"class_list":["post-167749","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/167749","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=167749"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/167749\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=167749"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=167749"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=167749"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}