{"action":"created","comment":{"url":"https://api.github.com/repos/dlang/phobos/pulls/comments/77788692","id":77788692,"diff_hunk":"@@ -0,0 +1,546 @@\n+// Written in the D programming language.\n+\n+/**\n+    This module implements the RGB _color type.\n+\n+    Authors:    Manu Evans\n+    Copyright:  Copyright (c) 2015, Manu Evans.\n+    License:    $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0)\n+    Source:     $(PHOBOSSRC std/experimental/color/rgb.d)\n+*/\n+module std.experimental.color.rgb;\n+\n+import std.experimental.color;\n+import std.experimental.color.colorspace;\n+import std.experimental.color.xyz : XYZ, isXYZ;\n+import std.experimental.normint;\n+\n+import std.traits : isInstanceOf, isNumeric, isIntegral, isFloatingPoint, isSomeChar, Unqual;\n+import std.typetuple : TypeTuple;\n+import std.typecons : tuple;\n+\n+@safe pure nothrow @nogc:\n+\n+\n+/**\n+Detect whether $(D T) is an RGB color.\n+*/\n+enum isRGB(T) = isInstanceOf!(RGB, T);\n+\n+///\n+unittest\n+{\n+    static assert(isRGB!(RGB!(\"bgr\", ushort)) == true);\n+    static assert(isRGB!LA8 == true);\n+    static assert(isRGB!int == false);\n+}\n+\n+\n+// DEBATE: which should it be?\n+template defaultAlpha(T)\n+{\n+/+\n+    enum defaultAlpha = isFloatingPoint!T ? T(1) : T.max;\n++/\n+    enum defaultAlpha = T(0);\n+}\n+\n+\n+/**\n+An RGB color, parameterised with components, component type, and color space specification.\n+\n+Params: components_ = Components that shall be available. Struct is populated with components in the order specified.\n+                      Valid components are:\n+                        \"r\" = red\n+                        \"g\" = green\n+                        \"b\" = blue\n+                        \"a\" = alpha\n+                        \"l\" = luminance\n+                        \"x\" = placeholder/padding (no significant value)\n+        ComponentType_ = Type for the color channels. May be a basic integer or floating point type.\n+        linear_ = Color is stored with linear luminance.\n+        colorSpace_ = Color will be within the specified color space.\n+*/\n+struct RGB(string components_, ComponentType_, bool linear_ = false, RGBColorSpace colorSpace_ = RGBColorSpace.sRGB)\n+    if(isNumeric!ComponentType_)\n+{\n+@safe pure nothrow @nogc:\n+\n+    // RGB colors may only contain components 'rgb', or 'l' (luminance)\n+    // They may also optionally contain an 'a' (alpha) component, and 'x' (unused) components\n+    static assert(allIn!(\"rgblax\", components), \"Invalid Color component '\"d ~ notIn!(\"rgblax\", components) ~ \"'. RGB colors may only contain components: r, g, b, l, a, x\"d);\n+    static assert(anyIn!(\"rgbal\", components), \"RGB colors must contain at least one component of r, g, b, l, a.\");\n+    static assert(!canFind!(components, 'l') || !anyIn!(\"rgb\", components), \"RGB colors may not contain rgb AND luminance components together.\");\n+\n+    static if(isFloatingPoint!ComponentType_)\n+    {\n+        /** Type of the color components. */\n+        alias ComponentType = ComponentType_;\n+    }\n+    else\n+    {\n+        /** Type of the color components. */\n+        alias ComponentType = NormalizedInt!ComponentType_;\n+    }\n+\n+    /** The color components that were specified. */\n+    enum string components = components_;\n+    /** The color space specified. */\n+    enum RGBColorSpace colorSpace = colorSpace_;\n+    /** If the color is stored linearly (without gamma applied). */\n+    enum bool linear = linear_;","path":"std/experimental/color/rgb.d","position":91,"original_position":91,"commit_id":"5efc34b7c0c8cfd2b710ac2e89ea55c93727fbd5","original_commit_id":"5efc34b7c0c8cfd2b710ac2e89ea55c93727fbd5","user":{"login":"TurkeyMan","id":1146706,"avatar_url":"https://avatars.githubusercontent.com/u/1146706?v=3","gravatar_id":"","url":"https://api.github.com/users/TurkeyMan","html_url":"https://github.com/TurkeyMan","followers_url":"https://api.github.com/users/TurkeyMan/followers","following_url":"https://api.github.com/users/TurkeyMan/following{/other_user}","gists_url":"https://api.github.com/users/TurkeyMan/gists{/gist_id}","starred_url":"https://api.github.com/users/TurkeyMan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TurkeyMan/subscriptions","organizations_url":"https://api.github.com/users/TurkeyMan/orgs","repos_url":"https://api.github.com/users/TurkeyMan/repos","events_url":"https://api.github.com/users/TurkeyMan/events{/privacy}","received_events_url":"https://api.github.com/users/TurkeyMan/received_events","type":"User","site_admin":false},"body":"Neat trick! ...that said, do you *really* think I should do that?","created_at":"2016-09-07T09:28:38Z","updated_at":"2016-09-07T09:28:38Z","html_url":"https://github.com/dlang/phobos/pull/2845#discussion_r77788692","pull_request_url":"https://api.github.com/repos/dlang/phobos/pulls/2845","_links":{"self":{"href":"https://api.github.com/repos/dlang/phobos/pulls/comments/77788692"},"html":{"href":"https://github.com/dlang/phobos/pull/2845#discussion_r77788692"},"pull_request":{"href":"https://api.github.com/repos/dlang/phobos/pulls/2845"}}},"pull_request":{"url":"https://api.github.com/repos/dlang/phobos/pulls/2845","id":26891491,"html_url":"https://github.com/dlang/phobos/pull/2845","diff_url":"https://github.com/dlang/phobos/pull/2845.diff","patch_url":"https://github.com/dlang/phobos/pull/2845.patch","issue_url":"https://api.github.com/repos/dlang/phobos/issues/2845","number":2845,"state":"open","locked":false,"title":"Added std.experimental.color","user":{"login":"TurkeyMan","id":1146706,"avatar_url":"https://avatars.githubusercontent.com/u/1146706?v=3","gravatar_id":"","url":"https://api.github.com/users/TurkeyMan","html_url":"https://github.com/TurkeyMan","followers_url":"https://api.github.com/users/TurkeyMan/followers","following_url":"https://api.github.com/users/TurkeyMan/following{/other_user}","gists_url":"https://api.github.com/users/TurkeyMan/gists{/gist_id}","starred_url":"https://api.github.com/users/TurkeyMan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TurkeyMan/subscriptions","organizations_url":"https://api.github.com/users/TurkeyMan/orgs","repos_url":"https://api.github.com/users/TurkeyMan/repos","events_url":"https://api.github.com/users/TurkeyMan/events{/privacy}","received_events_url":"https://api.github.com/users/TurkeyMan/received_events","type":"User","site_admin":false},"body":"There's talk about adding a std.colour type, here's a starting point for consideration.\r\nKnows about colour space and comprehensive format conversions.\r\nMore common colour spaces to come.","created_at":"2015-01-06T14:26:36Z","updated_at":"2016-09-07T09:28:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7d9d0c6946667da69ede05c0ef1016ba5ebf2298","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/dlang/phobos/pulls/2845/commits","review_comments_url":"https://api.github.com/repos/dlang/phobos/pulls/2845/comments","review_comment_url":"https://api.github.com/repos/dlang/phobos/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dlang/phobos/issues/2845/comments","statuses_url":"https://api.github.com/repos/dlang/phobos/statuses/5efc34b7c0c8cfd2b710ac2e89ea55c93727fbd5","head":{"label":"TurkeyMan:colour","ref":"colour","sha":"5efc34b7c0c8cfd2b710ac2e89ea55c93727fbd5","user":{"login":"TurkeyMan","id":1146706,"avatar_url":"https://avatars.githubusercontent.com/u/1146706?v=3","gravatar_id":"","url":"https://api.github.com/users/TurkeyMan","html_url":"https://github.com/TurkeyMan","followers_url":"https://api.github.com/users/TurkeyMan/followers","following_url":"https://api.github.com/users/TurkeyMan/following{/other_user}","gists_url":"https://api.github.com/users/TurkeyMan/gists{/gist_id}","starred_url":"https://api.github.com/users/TurkeyMan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TurkeyMan/subscriptions","organizations_url":"https://api.github.com/users/TurkeyMan/orgs","repos_url":"https://api.github.com/users/TurkeyMan/repos","events_url":"https://api.github.com/users/TurkeyMan/events{/privacy}","received_events_url":"https://api.github.com/users/TurkeyMan/received_events","type":"User","site_admin":false},"repo":{"id":3272507,"name":"phobos","full_name":"TurkeyMan/phobos","owner":{"login":"TurkeyMan","id":1146706,"avatar_url":"https://avatars.githubusercontent.com/u/1146706?v=3","gravatar_id":"","url":"https://api.github.com/users/TurkeyMan","html_url":"https://github.com/TurkeyMan","followers_url":"https://api.github.com/users/TurkeyMan/followers","following_url":"https://api.github.com/users/TurkeyMan/following{/other_user}","gists_url":"https://api.github.com/users/TurkeyMan/gists{/gist_id}","starred_url":"https://api.github.com/users/TurkeyMan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TurkeyMan/subscriptions","organizations_url":"https://api.github.com/users/TurkeyMan/orgs","repos_url":"https://api.github.com/users/TurkeyMan/repos","events_url":"https://api.github.com/users/TurkeyMan/events{/privacy}","received_events_url":"https://api.github.com/users/TurkeyMan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/TurkeyMan/phobos","description":"Runtime library for the D programming language","fork":true,"url":"https://api.github.com/repos/TurkeyMan/phobos","forks_url":"https://api.github.com/repos/TurkeyMan/phobos/forks","keys_url":"https://api.github.com/repos/TurkeyMan/phobos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TurkeyMan/phobos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TurkeyMan/phobos/teams","hooks_url":"https://api.github.com/repos/TurkeyMan/phobos/hooks","issue_events_url":"https://api.github.com/repos/TurkeyMan/phobos/issues/events{/number}","events_url":"https://api.github.com/repos/TurkeyMan/phobos/events","assignees_url":"https://api.github.com/repos/TurkeyMan/phobos/assignees{/user}","branches_url":"https://api.github.com/repos/TurkeyMan/phobos/branches{/branch}","tags_url":"https://api.github.com/repos/TurkeyMan/phobos/tags","blobs_url":"https://api.github.com/repos/TurkeyMan/phobos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TurkeyMan/phobos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TurkeyMan/phobos/git/refs{/sha}","trees_url":"https://api.github.com/repos/TurkeyMan/phobos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TurkeyMan/phobos/statuses/{sha}","languages_url":"https://api.github.com/repos/TurkeyMan/phobos/languages","stargazers_url":"https://api.github.com/repos/TurkeyMan/phobos/stargazers","contributors_url":"https://api.github.com/repos/TurkeyMan/phobos/contributors","subscribers_url":"https://api.github.com/repos/TurkeyMan/phobos/subscribers","subscription_url":"https://api.github.com/repos/TurkeyMan/phobos/subscription","commits_url":"https://api.github.com/repos/TurkeyMan/phobos/commits{/sha}","git_commits_url":"https://api.github.com/repos/TurkeyMan/phobos/git/commits{/sha}","comments_url":"https://api.github.com/repos/TurkeyMan/phobos/comments{/number}","issue_comment_url":"https://api.github.com/repos/TurkeyMan/phobos/issues/comments{/number}","contents_url":"https://api.github.com/repos/TurkeyMan/phobos/contents/{+path}","compare_url":"https://api.github.com/repos/TurkeyMan/phobos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TurkeyMan/phobos/merges","archive_url":"https://api.github.com/repos/TurkeyMan/phobos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TurkeyMan/phobos/downloads","issues_url":"https://api.github.com/repos/TurkeyMan/phobos/issues{/number}","pulls_url":"https://api.github.com/repos/TurkeyMan/phobos/pulls{/number}","milestones_url":"https://api.github.com/repos/TurkeyMan/phobos/milestones{/number}","notifications_url":"https://api.github.com/repos/TurkeyMan/phobos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TurkeyMan/phobos/labels{/name}","releases_url":"https://api.github.com/repos/TurkeyMan/phobos/releases{/id}","deployments_url":"https://api.github.com/repos/TurkeyMan/phobos/deployments","created_at":"2012-01-26T09:23:24Z","updated_at":"2015-01-10T02:32:11Z","pushed_at":"2016-09-07T05:06:11Z","git_url":"git://github.com/TurkeyMan/phobos.git","ssh_url":"git@github.com:TurkeyMan/phobos.git","clone_url":"https://github.com/TurkeyMan/phobos.git","svn_url":"https://github.com/TurkeyMan/phobos","homepage":"d-programming-language.org","size":47594,"stargazers_count":6,"watchers_count":6,"language":"D","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":6,"default_branch":"master"}},"base":{"label":"dlang:master","ref":"master","sha":"caba440978da91759e3f6db754066b1a74096ee3","user":{"login":"dlang","id":565913,"avatar_url":"https://avatars.githubusercontent.com/u/565913?v=3","gravatar_id":"","url":"https://api.github.com/users/dlang","html_url":"https://github.com/dlang","followers_url":"https://api.github.com/users/dlang/followers","following_url":"https://api.github.com/users/dlang/following{/other_user}","gists_url":"https://api.github.com/users/dlang/gists{/gist_id}","starred_url":"https://api.github.com/users/dlang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlang/subscriptions","organizations_url":"https://api.github.com/users/dlang/orgs","repos_url":"https://api.github.com/users/dlang/repos","events_url":"https://api.github.com/users/dlang/events{/privacy}","received_events_url":"https://api.github.com/users/dlang/received_events","type":"Organization","site_admin":false},"repo":{"id":1257084,"name":"phobos","full_name":"dlang/phobos","owner":{"login":"dlang","id":565913,"avatar_url":"https://avatars.githubusercontent.com/u/565913?v=3","gravatar_id":"","url":"https://api.github.com/users/dlang","html_url":"https://github.com/dlang","followers_url":"https://api.github.com/users/dlang/followers","following_url":"https://api.github.com/users/dlang/following{/other_user}","gists_url":"https://api.github.com/users/dlang/gists{/gist_id}","starred_url":"https://api.github.com/users/dlang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlang/subscriptions","organizations_url":"https://api.github.com/users/dlang/orgs","repos_url":"https://api.github.com/users/dlang/repos","events_url":"https://api.github.com/users/dlang/events{/privacy}","received_events_url":"https://api.github.com/users/dlang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dlang/phobos","description":"The standard library of the D programming language","fork":false,"url":"https://api.github.com/repos/dlang/phobos","forks_url":"https://api.github.com/repos/dlang/phobos/forks","keys_url":"https://api.github.com/repos/dlang/phobos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dlang/phobos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dlang/phobos/teams","hooks_url":"https://api.github.com/repos/dlang/phobos/hooks","issue_events_url":"https://api.github.com/repos/dlang/phobos/issues/events{/number}","events_url":"https://api.github.com/repos/dlang/phobos/events","assignees_url":"https://api.github.com/repos/dlang/phobos/assignees{/user}","branches_url":"https://api.github.com/repos/dlang/phobos/branches{/branch}","tags_url":"https://api.github.com/repos/dlang/phobos/tags","blobs_url":"https://api.github.com/repos/dlang/phobos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dlang/phobos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dlang/phobos/git/refs{/sha}","trees_url":"https://api.github.com/repos/dlang/phobos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dlang/phobos/statuses/{sha}","languages_url":"https://api.github.com/repos/dlang/phobos/languages","stargazers_url":"https://api.github.com/repos/dlang/phobos/stargazers","contributors_url":"https://api.github.com/repos/dlang/phobos/contributors","subscribers_url":"https://api.github.com/repos/dlang/phobos/subscribers","subscription_url":"https://api.github.com/repos/dlang/phobos/subscription","commits_url":"https://api.github.com/repos/dlang/phobos/commits{/sha}","git_commits_url":"https://api.github.com/repos/dlang/phobos/git/commits{/sha}","comments_url":"https://api.github.com/repos/dlang/phobos/comments{/number}","issue_comment_url":"https://api.github.com/repos/dlang/phobos/issues/comments{/number}","contents_url":"https://api.github.com/repos/dlang/phobos/contents/{+path}","compare_url":"https://api.github.com/repos/dlang/phobos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dlang/phobos/merges","archive_url":"https://api.github.com/repos/dlang/phobos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dlang/phobos/downloads","issues_url":"https://api.github.com/repos/dlang/phobos/issues{/number}","pulls_url":"https://api.github.com/repos/dlang/phobos/pulls{/number}","milestones_url":"https://api.github.com/repos/dlang/phobos/milestones{/number}","notifications_url":"https://api.github.com/repos/dlang/phobos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dlang/phobos/labels{/name}","releases_url":"https://api.github.com/repos/dlang/phobos/releases{/id}","deployments_url":"https://api.github.com/repos/dlang/phobos/deployments","created_at":"2011-01-15T07:00:06Z","updated_at":"2016-09-05T14:44:16Z","pushed_at":"2016-09-07T09:13:23Z","git_url":"git://github.com/dlang/phobos.git","ssh_url":"git@github.com:dlang/phobos.git","clone_url":"https://github.com/dlang/phobos.git","svn_url":"https://github.com/dlang/phobos","homepage":"dlang.org/phobos","size":76238,"stargazers_count":735,"watchers_count":735,"language":"D","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":511,"mirror_url":null,"open_issues_count":87,"forks":511,"open_issues":87,"watchers":735,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dlang/phobos/pulls/2845"},"html":{"href":"https://github.com/dlang/phobos/pull/2845"},"issue":{"href":"https://api.github.com/repos/dlang/phobos/issues/2845"},"comments":{"href":"https://api.github.com/repos/dlang/phobos/issues/2845/comments"},"review_comments":{"href":"https://api.github.com/repos/dlang/phobos/pulls/2845/comments"},"review_comment":{"href":"https://api.github.com/repos/dlang/phobos/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dlang/phobos/pulls/2845/commits"},"statuses":{"href":"https://api.github.com/repos/dlang/phobos/statuses/5efc34b7c0c8cfd2b710ac2e89ea55c93727fbd5"}}}}
{"actor":{"display_login":"TurkeyMan"}}