{"action":"created","comment":{"url":"https://api.github.com/repos/gonum/plot/pulls/comments/89232014","pull_request_review_id":9776617,"id":89232014,"diff_hunk":"@@ -0,0 +1,229 @@\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\"image/color\"\n+\t\"math\"\n+)\n+\n+// rgb repesents a physically linear RGB color.\n+type rgb struct {\n+\tR, G, B float64\n+}\n+\n+// cieXYZ converts a linear RGB color to a CIE XYZ color.\n+func (c rgb) cieXYZ() 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+// sRGBA converts a linear RGB color to an sRGBA color, where alpha is the alpha\n+// channel value (between 0 and 1).\n+func (c rgb) sRGBA(alpha float64) sRGBA {\n+\treturn 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+}\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+// cieXYZ represents a color in CIE XYZ space.\n+type cieXYZ struct {\n+\tX, Y, Z float64\n+}\n+\n+// rgb converts a CIEXYZ color to physically linear RGB.\n+func (c cieXYZ) rgb() rgb {\n+\treturn rgb{\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+// cieLAB converts an CIE XYZ color to a CIE LAB color.\n+func (c cieXYZ) cieLAB() cieLAB {\n+\ttempX := xyz2labHelper(c.X / 0.9505)\n+\ttempY := xyz2labHelper(c.Y)\n+\ttempZ := xyz2labHelper(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+// xyz2labHelper is an intermediate step in converting from CIE XYZ to CIE LAB.\n+func xyz2labHelper(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+// sRGBA 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+// rgb converts the receiver to linear RGB space.\n+func (c sRGBA) rgb() rgb {\n+\treturn rgb{\n+\t\tR: sToLinear(c.R),\n+\t\tG: sToLinear(c.G),\n+\t\tB: sToLinear(c.B),\n+\t}\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+// 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+// cieLAB converts a sRGB color to a CIE LAB color.\n+func (c sRGBA) cieLAB() cieLAB {\n+\treturn c.rgb().cieXYZ().cieLAB()\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+\tif a == 0 {\n+\t\treturn sRGBA{}\n+\t}\n+\treturn sRGBA{\n+\t\tR: float64(r) / float64(a),\n+\t\tG: float64(g) / float64(a),\n+\t\tB: float64(b) / float64(a),\n+\t\tA: float64(a) / 65535.0,\n+\t}\n+}\n+\n+// clamp forces all channels in c to be within the range (0,1).\n+func (c *sRGBA) clamp() {\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+// sRGB converts a CIE LAB color to an sRGBA color, where alpha is opacity\n+// between 0 and 1.\n+func (c cieLAB) sRGBA(alpha float64) sRGBA {\n+\treturn c.cieXYZ().rgb().sRGBA(alpha)\n+}\n+\n+// cieXYZ converts a CIE LAB color to a CIE XYZ color.\n+func (c cieLAB) cieXYZ() 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 * lab2xyzHelper((c.A/500)+(c.L+16)/116),\n+\t\tY: yn * lab2xyzHelper((c.L+16.)/116.),\n+\t\tZ: zn * lab2xyzHelper((c.L+16.)/116.-(c.B/200.)),\n+\t}\n+}\n+\n+// lab2xyzHelper is an intermediate step in converting from CIE LAB to CIE XYZ.\n+func lab2xyzHelper(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+// MSH converts a cieLAB color to MSH space.\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+// MSH defines a color in Magnitude-Saturation-Hue color space.","path":"palette/moreland/convert.go","position":200,"original_position":200,"commit_id":"706ac1fd9906136df2665c7566f0ea870f269390","original_commit_id":"706ac1fd9906136df2665c7566f0ea870f269390","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":"s/defines/represents/","created_at":"2016-11-22T23:21:01Z","updated_at":"2016-11-22T23:41:41Z","html_url":"https://github.com/gonum/plot/pull/321#discussion_r89232014","pull_request_url":"https://api.github.com/repos/gonum/plot/pulls/321","_links":{"self":{"href":"https://api.github.com/repos/gonum/plot/pulls/comments/89232014"},"html":{"href":"https://github.com/gonum/plot/pull/321#discussion_r89232014"},"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-22T23:41:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0113b48dff19ad4b83173ff32b3911b219c82315","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/706ac1fd9906136df2665c7566f0ea870f269390","head":{"label":"gonum:moreland","ref":"moreland","sha":"706ac1fd9906136df2665c7566f0ea870f269390","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-22T17:40:26Z","pushed_at":"2016-11-22T16:58:58Z","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":6849,"stargazers_count":385,"watchers_count":385,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":48,"mirror_url":null,"open_issues_count":59,"forks":48,"open_issues":59,"watchers":385,"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-22T17:40:26Z","pushed_at":"2016-11-22T16:58:58Z","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":6849,"stargazers_count":385,"watchers_count":385,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":48,"mirror_url":null,"open_issues_count":59,"forks":48,"open_issues":59,"watchers":385,"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/706ac1fd9906136df2665c7566f0ea870f269390"}}}}
{"actor":{"display_login":"kortschak"}}