{"action":"created","comment":{"url":"https://api.github.com/repos/gonum/plot/pulls/comments/86284347","pull_request_review_id":6947726,"id":86284347,"diff_hunk":"@@ -0,0 +1,228 @@\n+// Copyright ©2016 The gonum Authors. All rights reserved.\n+// Use of this source code is governed by a BSD-style\n+// license that can be found in the LICENSE file.\n+\n+package moreland\n+\n+import (\n+\t\"fmt\"\n+\t\"image/color\"\n+\t\"math\"\n+)\n+\n+// linearToS converts from a linear RGB component to an sRGB component.\n+func linearToS(v float64) float64 {\n+\tif v > 0.0031308 {\n+\t\treturn 1.055*math.Pow(v, 1/2.4) - 0.055\n+\t}\n+\treturn 12.92 * v\n+}\n+\n+// sToLinear converts from an sRGB component to a linear RGB component.\n+func sToLinear(v float64) float64 {\n+\tif v > 0.04045 {\n+\t\treturn math.Pow((v+0.055)/1.055, 2.4)\n+\t}\n+\treturn v / 12.92\n+}\n+\n+// linearRGB repesents a physically linear RGB color.\n+type linearRGB struct {\n+\tR, G, B float64\n+}\n+\n+// XYZ converts a linear RGB color to a CIE XYZ color.\n+func (c linearRGB) XYZ() cieXYZ {\n+\treturn cieXYZ{\n+\t\tX: 0.4124*c.R + 0.3576*c.G + 0.1805*c.B,\n+\t\tY: 0.2126*c.R + 0.7152*c.G + 0.0722*c.B,\n+\t\tZ: 0.0193*c.R + 0.1192*c.G + 0.9505*c.B,\n+\t}\n+}\n+\n+// linearRGB converts a CIEXYZ color to physically linear RGB.\n+func (c cieXYZ) linearRGB() linearRGB {\n+\treturn linearRGB{\n+\t\tR: c.X*3.2406 + c.Y*-1.5372 + c.Z*-0.4986,\n+\t\tG: c.X*-0.9689 + c.Y*1.8758 + c.Z*0.0415,\n+\t\tB: c.X*0.0557 + c.Y*-0.204 + c.Z*1.057,\n+\t}\n+}\n+\n+// labTemp is an intermediate step in converting from CIE XYZ to CIE LAB.\n+func labTemp(v float64) float64 {\n+\tif v > 0.008856 {\n+\t\treturn math.Pow(v, 1.0/3.0)\n+\t}\n+\treturn 7.787*v + 16.0/116.0\n+}\n+\n+// LAB converts an CIE XYZ color to a CIE LAB color.\n+func (c cieXYZ) LAB() cieLAB {\n+\ttempX := labTemp(c.X / 0.9505)\n+\ttempY := labTemp(c.Y)\n+\ttempZ := labTemp(c.Z / 1.089)\n+\treturn cieLAB{\n+\t\tL: (116.0 * tempY) - 16.0,\n+\t\tA: 500.0 * (tempX - tempY),\n+\t\tB: 200 * (tempY - tempZ),\n+\t}\n+}\n+\n+// sRGB represents a color within the sRGB color space, with an alpha channel\n+// but not premultiplied.\n+type sRGBA struct {\n+\tR, G, B, A float64\n+}\n+\n+func (c sRGBA) linearRGB() linearRGB {\n+\treturn linearRGB{\n+\t\tR: sToLinear(c.R),\n+\t\tG: sToLinear(c.G),\n+\t\tB: sToLinear(c.B),\n+\t}\n+}\n+\n+// RGBA implements the color.Color interface.\n+func (c sRGBA) RGBA() (r, g, b, a uint32) {\n+\treturn uint32(c.R * c.A * 65535.0), uint32(c.G * c.A * 65535.0), uint32(c.B * c.A * 65535.0), uint32(c.A * 65535.0)\n+}\n+\n+// LAB converts a sRGB color to a CIE LAB color.\n+func (c sRGBA) LAB() cieLAB {\n+\treturn c.linearRGB().XYZ().LAB()\n+}\n+\n+// sRGB converts a CIE LAB color to an sRGBA color, where alpha is opacity\n+// between 0 and 1.\n+func (c cieLAB) sRGB(alpha float64) sRGBA {\n+\treturn c.XYZ().linearRGB().S(alpha)\n+}\n+\n+// colorTosRGBA converts a color to an sRGBA.\n+func colorTosRGBA(c color.Color) sRGBA {\n+\tr, g, b, a := c.RGBA()\n+\talpha := float64(a) / 65535.0\n+\treturn sRGBA{\n+\t\tR: float64(r) / alpha / 65535.0,\n+\t\tG: float64(g) / alpha / 65535.0,\n+\t\tB: float64(b) / alpha / 65535.0,\n+\t\tA: alpha,\n+\t}\n+}\n+\n+// ColorToMSH converts a color to MSH space.\n+func ColorToMSH(c color.Color) MSH {\n+\treturn colorTosRGBA(c).LAB().MSH()\n+}\n+\n+// S converts a linear RGB color to an sRGBA color, where alpha is the alpha\n+// channel value (between 0 and 1).\n+func (c linearRGB) S(alpha float64) sRGBA {\n+\tsc := sRGBA{\n+\t\tR: linearToS(c.R),\n+\t\tG: linearToS(c.G),\n+\t\tB: linearToS(c.B),\n+\t\tA: alpha,\n+\t}\n+\treturn sc\n+}\n+\n+// check returns an error if any of the channels in c are out of range.\n+func (c sRGBA) check() error {\n+\tif c.R > 1 || c.G > 1 || c.B > 1 || c.A > 1 || c.R < 0 || c.G < 0 || c.B < 0 || c.A < 0 {\n+\t\treturn fmt.Errorf(\"moreland: invalid color r:%g, g:%g, b:%g, a:%g\", c.R, c.G, c.B, c.A)\n+\t}\n+\treturn nil\n+}\n+\n+// fix forces all channels in c to be within the range (0,1).\n+func (c *sRGBA) fix() {\n+\tif c.R > 1 {\n+\t\tc.R = 1\n+\t}\n+\tif c.G > 1 {\n+\t\tc.G = 1\n+\t}\n+\tif c.B > 1 {\n+\t\tc.B = 1\n+\t}\n+\tif c.A > 1 {\n+\t\tc.A = 1\n+\t}\n+\tif c.R < 0 {\n+\t\tc.R = 0\n+\t}\n+\tif c.G < 0 {\n+\t\tc.G = 0\n+\t}\n+\tif c.B < 0 {\n+\t\tc.B = 0\n+\t}\n+\tif c.A < 0 {\n+\t\tc.A = 0\n+\t}\n+}\n+\n+// cieLAB represents a color in CIE LAB space.\n+type cieLAB struct {\n+\tL, A, B float64\n+}\n+\n+// cieXYZ represents a color in CIE XYZ space.\n+type cieXYZ struct {\n+\tX, Y, Z float64\n+}\n+\n+// xyzTemp is an intermediate step in converting from CIE LAB to CIE XYZ.\n+func xyzTemp(v float64) float64 {\n+\tconst (\n+\t\txlim = 0.008856\n+\t\ta    = 7.787\n+\t\tb    = 16. / 116.\n+\t\tylim = a*xlim + b\n+\t)\n+\tif v > ylim {\n+\t\treturn v * v * v\n+\t}\n+\treturn (v - b) / a\n+}\n+\n+// XYZ converts a CIELAB color to a CIEXYZ color.\n+func (c cieLAB) XYZ() cieXYZ {\n+\t// Reference white-point D65\n+\tconst xn, yn, zn = 0.95047, 1.0, 1.08883\n+\treturn cieXYZ{\n+\t\tX: xn * xyzTemp((c.A/500)+(c.L+16)/116),\n+\t\tY: yn * xyzTemp((c.L+16.)/116.),\n+\t\tZ: zn * xyzTemp((c.L+16.)/116.-(c.B/200.)),\n+\t}\n+}\n+\n+func (c cieLAB) MSH() MSH {\n+\tm := math.Pow(c.L*c.L+c.A*c.A+c.B*c.B, 0.5)\n+\treturn MSH{\n+\t\tM: m,\n+\t\tS: math.Acos(c.L / m),\n+\t\tH: math.Atan2(c.B, c.A),\n+\t}\n+}\n+\n+// lab converts a MSH color to a CIELAB color.\n+func (c MSH) lab() cieLAB {\n+\treturn cieLAB{\n+\t\tL: c.M * math.Cos(c.S),\n+\t\tA: c.M * math.Sin(c.S) * math.Cos(c.H),\n+\t\tB: c.M * math.Sin(c.S) * math.Sin(c.H),\n+\t}\n+}\n+\n+// MSH defines a color in Magnitude-Saturation-Hue color space.\n+type MSH struct {","path":"palette/moreland/convert.go","position":221,"original_position":221,"commit_id":"3a88785a3ca11b3b6d58ee6730395db111e69b81","original_commit_id":"3a88785a3ca11b3b6d58ee6730395db111e69b81","user":{"login":"kortschak","id":275221,"avatar_url":"https://avatars.githubusercontent.com/u/275221?v=3","gravatar_id":"","url":"https://api.github.com/users/kortschak","html_url":"https://github.com/kortschak","followers_url":"https://api.github.com/users/kortschak/followers","following_url":"https://api.github.com/users/kortschak/following{/other_user}","gists_url":"https://api.github.com/users/kortschak/gists{/gist_id}","starred_url":"https://api.github.com/users/kortschak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kortschak/subscriptions","organizations_url":"https://api.github.com/users/kortschak/orgs","repos_url":"https://api.github.com/users/kortschak/repos","events_url":"https://api.github.com/users/kortschak/events{/privacy}","received_events_url":"https://api.github.com/users/kortschak/received_events","type":"User","site_admin":false},"body":"Make MSH implement color.Color.","created_at":"2016-11-03T04:09:10Z","updated_at":"2016-11-03T04:23:16Z","html_url":"https://github.com/gonum/plot/pull/321#discussion_r86284347","pull_request_url":"https://api.github.com/repos/gonum/plot/pulls/321","_links":{"self":{"href":"https://api.github.com/repos/gonum/plot/pulls/comments/86284347"},"html":{"href":"https://github.com/gonum/plot/pull/321#discussion_r86284347"},"pull_request":{"href":"https://api.github.com/repos/gonum/plot/pulls/321"}}},"pull_request":{"url":"https://api.github.com/repos/gonum/plot/pulls/321","id":91535864,"html_url":"https://github.com/gonum/plot/pull/321","diff_url":"https://github.com/gonum/plot/pull/321.diff","patch_url":"https://github.com/gonum/plot/pull/321.patch","issue_url":"https://api.github.com/repos/gonum/plot/issues/321","number":321,"state":"open","locked":false,"title":"Added moreland color maps","user":{"login":"ctessum","id":6193153,"avatar_url":"https://avatars.githubusercontent.com/u/6193153?v=3","gravatar_id":"","url":"https://api.github.com/users/ctessum","html_url":"https://github.com/ctessum","followers_url":"https://api.github.com/users/ctessum/followers","following_url":"https://api.github.com/users/ctessum/following{/other_user}","gists_url":"https://api.github.com/users/ctessum/gists{/gist_id}","starred_url":"https://api.github.com/users/ctessum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ctessum/subscriptions","organizations_url":"https://api.github.com/users/ctessum/orgs","repos_url":"https://api.github.com/users/ctessum/repos","events_url":"https://api.github.com/users/ctessum/events{/privacy}","received_events_url":"https://api.github.com/users/ctessum/received_events","type":"User","site_admin":false},"body":"These palettes/color maps supplement the ones that are currently available in that they are designed for pseudocoloring continuous variable (the brewer palettes are designed more for categorical variables) and they follow what I understand to be best practices for doing so, which the rainbow palette (although popular) does not.\n\nPlease take a look and let me know what you think!\n\nThis is related to issues #304 and #17.\n","created_at":"2016-10-30T20:53:02Z","updated_at":"2016-11-03T04:23:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1549a23878e64fb7b4d40e89d497fcbd5051555f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/gonum/plot/pulls/321/commits","review_comments_url":"https://api.github.com/repos/gonum/plot/pulls/321/comments","review_comment_url":"https://api.github.com/repos/gonum/plot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gonum/plot/issues/321/comments","statuses_url":"https://api.github.com/repos/gonum/plot/statuses/3a88785a3ca11b3b6d58ee6730395db111e69b81","head":{"label":"gonum:moreland","ref":"moreland","sha":"3a88785a3ca11b3b6d58ee6730395db111e69b81","user":{"login":"gonum","id":3771091,"avatar_url":"https://avatars.githubusercontent.com/u/3771091?v=3","gravatar_id":"","url":"https://api.github.com/users/gonum","html_url":"https://github.com/gonum","followers_url":"https://api.github.com/users/gonum/followers","following_url":"https://api.github.com/users/gonum/following{/other_user}","gists_url":"https://api.github.com/users/gonum/gists{/gist_id}","starred_url":"https://api.github.com/users/gonum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gonum/subscriptions","organizations_url":"https://api.github.com/users/gonum/orgs","repos_url":"https://api.github.com/users/gonum/repos","events_url":"https://api.github.com/users/gonum/events{/privacy}","received_events_url":"https://api.github.com/users/gonum/received_events","type":"Organization","site_admin":false},"repo":{"id":11601889,"name":"plot","full_name":"gonum/plot","owner":{"login":"gonum","id":3771091,"avatar_url":"https://avatars.githubusercontent.com/u/3771091?v=3","gravatar_id":"","url":"https://api.github.com/users/gonum","html_url":"https://github.com/gonum","followers_url":"https://api.github.com/users/gonum/followers","following_url":"https://api.github.com/users/gonum/following{/other_user}","gists_url":"https://api.github.com/users/gonum/gists{/gist_id}","starred_url":"https://api.github.com/users/gonum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gonum/subscriptions","organizations_url":"https://api.github.com/users/gonum/orgs","repos_url":"https://api.github.com/users/gonum/repos","events_url":"https://api.github.com/users/gonum/events{/privacy}","received_events_url":"https://api.github.com/users/gonum/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gonum/plot","description":"A repository for plotting and visualizing data","fork":false,"url":"https://api.github.com/repos/gonum/plot","forks_url":"https://api.github.com/repos/gonum/plot/forks","keys_url":"https://api.github.com/repos/gonum/plot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gonum/plot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gonum/plot/teams","hooks_url":"https://api.github.com/repos/gonum/plot/hooks","issue_events_url":"https://api.github.com/repos/gonum/plot/issues/events{/number}","events_url":"https://api.github.com/repos/gonum/plot/events","assignees_url":"https://api.github.com/repos/gonum/plot/assignees{/user}","branches_url":"https://api.github.com/repos/gonum/plot/branches{/branch}","tags_url":"https://api.github.com/repos/gonum/plot/tags","blobs_url":"https://api.github.com/repos/gonum/plot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gonum/plot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gonum/plot/git/refs{/sha}","trees_url":"https://api.github.com/repos/gonum/plot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gonum/plot/statuses/{sha}","languages_url":"https://api.github.com/repos/gonum/plot/languages","stargazers_url":"https://api.github.com/repos/gonum/plot/stargazers","contributors_url":"https://api.github.com/repos/gonum/plot/contributors","subscribers_url":"https://api.github.com/repos/gonum/plot/subscribers","subscription_url":"https://api.github.com/repos/gonum/plot/subscription","commits_url":"https://api.github.com/repos/gonum/plot/commits{/sha}","git_commits_url":"https://api.github.com/repos/gonum/plot/git/commits{/sha}","comments_url":"https://api.github.com/repos/gonum/plot/comments{/number}","issue_comment_url":"https://api.github.com/repos/gonum/plot/issues/comments{/number}","contents_url":"https://api.github.com/repos/gonum/plot/contents/{+path}","compare_url":"https://api.github.com/repos/gonum/plot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gonum/plot/merges","archive_url":"https://api.github.com/repos/gonum/plot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gonum/plot/downloads","issues_url":"https://api.github.com/repos/gonum/plot/issues{/number}","pulls_url":"https://api.github.com/repos/gonum/plot/pulls{/number}","milestones_url":"https://api.github.com/repos/gonum/plot/milestones{/number}","notifications_url":"https://api.github.com/repos/gonum/plot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gonum/plot/labels{/name}","releases_url":"https://api.github.com/repos/gonum/plot/releases{/id}","deployments_url":"https://api.github.com/repos/gonum/plot/deployments","created_at":"2013-07-23T07:01:13Z","updated_at":"2016-11-01T20:36:50Z","pushed_at":"2016-10-30T21:10:19Z","git_url":"git://github.com/gonum/plot.git","ssh_url":"git@github.com:gonum/plot.git","clone_url":"https://github.com/gonum/plot.git","svn_url":"https://github.com/gonum/plot","homepage":"","size":6608,"stargazers_count":375,"watchers_count":375,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":45,"mirror_url":null,"open_issues_count":56,"forks":45,"open_issues":56,"watchers":375,"default_branch":"master"}},"base":{"label":"gonum:CheckPlot","ref":"CheckPlot","sha":"73a60a40e50829979cb6753e2b6f5fa053dd70a8","user":{"login":"gonum","id":3771091,"avatar_url":"https://avatars.githubusercontent.com/u/3771091?v=3","gravatar_id":"","url":"https://api.github.com/users/gonum","html_url":"https://github.com/gonum","followers_url":"https://api.github.com/users/gonum/followers","following_url":"https://api.github.com/users/gonum/following{/other_user}","gists_url":"https://api.github.com/users/gonum/gists{/gist_id}","starred_url":"https://api.github.com/users/gonum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gonum/subscriptions","organizations_url":"https://api.github.com/users/gonum/orgs","repos_url":"https://api.github.com/users/gonum/repos","events_url":"https://api.github.com/users/gonum/events{/privacy}","received_events_url":"https://api.github.com/users/gonum/received_events","type":"Organization","site_admin":false},"repo":{"id":11601889,"name":"plot","full_name":"gonum/plot","owner":{"login":"gonum","id":3771091,"avatar_url":"https://avatars.githubusercontent.com/u/3771091?v=3","gravatar_id":"","url":"https://api.github.com/users/gonum","html_url":"https://github.com/gonum","followers_url":"https://api.github.com/users/gonum/followers","following_url":"https://api.github.com/users/gonum/following{/other_user}","gists_url":"https://api.github.com/users/gonum/gists{/gist_id}","starred_url":"https://api.github.com/users/gonum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gonum/subscriptions","organizations_url":"https://api.github.com/users/gonum/orgs","repos_url":"https://api.github.com/users/gonum/repos","events_url":"https://api.github.com/users/gonum/events{/privacy}","received_events_url":"https://api.github.com/users/gonum/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gonum/plot","description":"A repository for plotting and visualizing data","fork":false,"url":"https://api.github.com/repos/gonum/plot","forks_url":"https://api.github.com/repos/gonum/plot/forks","keys_url":"https://api.github.com/repos/gonum/plot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gonum/plot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gonum/plot/teams","hooks_url":"https://api.github.com/repos/gonum/plot/hooks","issue_events_url":"https://api.github.com/repos/gonum/plot/issues/events{/number}","events_url":"https://api.github.com/repos/gonum/plot/events","assignees_url":"https://api.github.com/repos/gonum/plot/assignees{/user}","branches_url":"https://api.github.com/repos/gonum/plot/branches{/branch}","tags_url":"https://api.github.com/repos/gonum/plot/tags","blobs_url":"https://api.github.com/repos/gonum/plot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gonum/plot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gonum/plot/git/refs{/sha}","trees_url":"https://api.github.com/repos/gonum/plot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gonum/plot/statuses/{sha}","languages_url":"https://api.github.com/repos/gonum/plot/languages","stargazers_url":"https://api.github.com/repos/gonum/plot/stargazers","contributors_url":"https://api.github.com/repos/gonum/plot/contributors","subscribers_url":"https://api.github.com/repos/gonum/plot/subscribers","subscription_url":"https://api.github.com/repos/gonum/plot/subscription","commits_url":"https://api.github.com/repos/gonum/plot/commits{/sha}","git_commits_url":"https://api.github.com/repos/gonum/plot/git/commits{/sha}","comments_url":"https://api.github.com/repos/gonum/plot/comments{/number}","issue_comment_url":"https://api.github.com/repos/gonum/plot/issues/comments{/number}","contents_url":"https://api.github.com/repos/gonum/plot/contents/{+path}","compare_url":"https://api.github.com/repos/gonum/plot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gonum/plot/merges","archive_url":"https://api.github.com/repos/gonum/plot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gonum/plot/downloads","issues_url":"https://api.github.com/repos/gonum/plot/issues{/number}","pulls_url":"https://api.github.com/repos/gonum/plot/pulls{/number}","milestones_url":"https://api.github.com/repos/gonum/plot/milestones{/number}","notifications_url":"https://api.github.com/repos/gonum/plot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gonum/plot/labels{/name}","releases_url":"https://api.github.com/repos/gonum/plot/releases{/id}","deployments_url":"https://api.github.com/repos/gonum/plot/deployments","created_at":"2013-07-23T07:01:13Z","updated_at":"2016-11-01T20:36:50Z","pushed_at":"2016-10-30T21:10:19Z","git_url":"git://github.com/gonum/plot.git","ssh_url":"git@github.com:gonum/plot.git","clone_url":"https://github.com/gonum/plot.git","svn_url":"https://github.com/gonum/plot","homepage":"","size":6608,"stargazers_count":375,"watchers_count":375,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":45,"mirror_url":null,"open_issues_count":56,"forks":45,"open_issues":56,"watchers":375,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gonum/plot/pulls/321"},"html":{"href":"https://github.com/gonum/plot/pull/321"},"issue":{"href":"https://api.github.com/repos/gonum/plot/issues/321"},"comments":{"href":"https://api.github.com/repos/gonum/plot/issues/321/comments"},"review_comments":{"href":"https://api.github.com/repos/gonum/plot/pulls/321/comments"},"review_comment":{"href":"https://api.github.com/repos/gonum/plot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gonum/plot/pulls/321/commits"},"statuses":{"href":"https://api.github.com/repos/gonum/plot/statuses/3a88785a3ca11b3b6d58ee6730395db111e69b81"}}}}
{"actor":{"display_login":"kortschak"}}