{"id":4520,"date":"2016-08-11T02:27:32","date_gmt":"2016-08-10T17:27:32","guid":{"rendered":"http:\/\/mirror.boy.jp\/?p=2439"},"modified":"2016-08-11T02:27:32","modified_gmt":"2016-08-10T17:27:32","slug":"hsl-to-rgb-%e5%a4%89%e6%8f%9b-js-%e3%82%aa%e3%83%96%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88-max7","status":"publish","type":"post","link":"https:\/\/inage.ksd6700.net\/?p=4520","title":{"rendered":"HSL to RGB \u5909\u63db JS \u30aa\u30d6\u30b8\u30a7\u30af\u30c8 #max7"},"content":{"rendered":"<h2>JS\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u7528\u30b3\u30fc\u30c9<\/h2>\n<pre class=\"brush: plain; title: ; notranslate\">\r\nfunction rgbToHsl(r, g, b){\r\n\r\n\tr \/= 255, g \/= 255, b \/= 255;\r\n\r\n\tvar max = Math.max(r, g, b), min = Math.min(r, g, b);\r\n\r\n\tvar h, s, l = (max + min) \/ 2;\r\n\r\nif(max == min){\r\nh = s = 0; \/\/ achromatic\r\n}else{\r\nvar d = max - min;\r\ns = l &amp;amp;gt; 0.5 ? d \/ (2 - max - min) : d \/ (max + min);\r\nswitch(max){\r\ncase r: h = (g - b) \/ d + (g &amp;amp;lt; b ? 6 : 0); break;\r\ncase g: h = (b - r) \/ d + 2; break;\r\ncase b: h = (r - g) \/ d + 4; break;\r\n}\r\nh \/= 6;\r\n}\r\noutlet(0, h, s, l);\r\n}\r\n\r\nfunction hslToRgb(h, s, l){\r\nvar r, g, b;\r\n\r\nif(s == 0){\r\nr = g = b = l; \/\/ achromatic\r\n}else{\r\nfunction hue2rgb(p, q, t){\r\nif(t &amp;amp;lt; 0) t += 1; if(t &amp;amp;gt; 1) t -= 1;\r\nif(t &amp;amp;lt; 1\/6) return p + (q - p) * 6 * t;\r\nif(t &amp;amp;lt; 1\/2) return q;\r\nif(t &amp;amp;lt; 2\/3) return p + (q - p) * (2\/3 - t) * 6;\r\nreturn p;\r\n}\r\n\r\nvar q = l &amp;amp;lt; 0.5 ? l * (1 + s) : l + s - l * s;\r\nvar p = 2 * l - q;\r\nr = hue2rgb(p, q, h + 1\/3);\r\ng = hue2rgb(p, q, h);\r\nb = hue2rgb(p, q, h - 1\/3);\r\n}\r\nr = Math.round(r*255);\r\ng = Math.round(g*255);\r\nb = Math.round(b*255);\r\noutlet(0,r, g, b);\r\n}\r\n<\/pre>\n<h2>\u5f15\u7528\u5143<\/h2>\n<p><a href=\"https:\/\/cycling74.com\/forums\/topic\/rgb-to-hsl-conversion\/#.V6tjZmV5HDI\">RGB to HSL conversion<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>JS&#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#29992;&#12467;&#12540;&#12489; &#24341;&#29992;&#20803; RGB to HSL convers &#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=\/wp\/v2\/posts\/4520"}],"collection":[{"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4520"}],"version-history":[{"count":1,"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=\/wp\/v2\/posts\/4520\/revisions"}],"predecessor-version":[{"id":5365,"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=\/wp\/v2\/posts\/4520\/revisions\/5365"}],"wp:attachment":[{"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}