{"action":"created","issue":{"url":"https://api.github.com/repos/Ogeon/palette/issues/31","repository_url":"https://api.github.com/repos/Ogeon/palette","labels_url":"https://api.github.com/repos/Ogeon/palette/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/Ogeon/palette/issues/31/comments","events_url":"https://api.github.com/repos/Ogeon/palette/issues/31/events","html_url":"https://github.com/Ogeon/palette/issues/31","id":130285660,"number":31,"title":"Common RGB struct","user":{"login":"sidred","id":6623285,"avatar_url":"https://avatars.githubusercontent.com/u/6623285?v=3","gravatar_id":"","url":"https://api.github.com/users/sidred","html_url":"https://github.com/sidred","followers_url":"https://api.github.com/users/sidred/followers","following_url":"https://api.github.com/users/sidred/following{/other_user}","gists_url":"https://api.github.com/users/sidred/gists{/gist_id}","starred_url":"https://api.github.com/users/sidred/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sidred/subscriptions","organizations_url":"https://api.github.com/users/sidred/orgs","repos_url":"https://api.github.com/users/sidred/repos","events_url":"https://api.github.com/users/sidred/events{/privacy}","received_events_url":"https://api.github.com/users/sidred/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2016-02-01T07:45:21Z","updated_at":"2016-02-13T01:48:22Z","closed_at":null,"body":"Have a common rgb struct \r\n\r\n```\r\nstruct RgbColor<RgbVariant, WP, T> {\r\n    r: T,\r\n    g: T,\r\n    b: T,\r\n    _color_space: PhantomData<RGBVariant>,\r\n    _white_point: PhantomData<WP>,\r\n}\r\n```\r\n\r\nthen we can define the individual colors as \r\n\r\n```\r\nconst Rgb = RgbColor<LinearSrgbSpace, D65, T>\r\nconst Srgb = RgbColor<SrgbSpace, D65, T>\r\nconst AdobeRgb = RgbColor<AdobeSpace, D65, T>\r\n```\r\n\r\nconversions will be\r\n\r\n```\r\nimpl<RgbVariant, WP,T: Float> From<RgbColor<RgbVariant, WP,T>> for Xyz<T> {\r\n    fn from(rgb: Rgb<T>) -> Xyz<T> {\r\n      let conv_matrix = RgbVariant::get_matrix();\r\n      let wp_xyz = WP::get_xyz();\r\n      \r\n\r\n        Xyz {\r\n           .... calculations\r\n        }\r\n    }\r\n}\r\n\r\nimpl<RgbVariant, WP,T: Float> From<Xyz<T>> for RgbColor<RgbVariant, WP,T> {\r\n    fn from(xyz: Rgb<T>) -> RgbColor<RgbVariant, WP,T> {\r\n      let conv_matrix = RgbVariant::get_matrix();\r\n      let wp_xyz = WP::get_xyz();\r\n      \r\n\r\n        Rgb {\r\n           .... calculations\r\n        }\r\n    }\r\n}\r\n\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Ogeon/palette/issues/comments/183559080","html_url":"https://github.com/Ogeon/palette/issues/31#issuecomment-183559080","issue_url":"https://api.github.com/repos/Ogeon/palette/issues/31","id":183559080,"user":{"login":"sidred","id":6623285,"avatar_url":"https://avatars.githubusercontent.com/u/6623285?v=3","gravatar_id":"","url":"https://api.github.com/users/sidred","html_url":"https://github.com/sidred","followers_url":"https://api.github.com/users/sidred/followers","following_url":"https://api.github.com/users/sidred/following{/other_user}","gists_url":"https://api.github.com/users/sidred/gists{/gist_id}","starred_url":"https://api.github.com/users/sidred/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sidred/subscriptions","organizations_url":"https://api.github.com/users/sidred/orgs","repos_url":"https://api.github.com/users/sidred/repos","events_url":"https://api.github.com/users/sidred/events{/privacy}","received_events_url":"https://api.github.com/users/sidred/received_events","type":"User","site_admin":false},"created_at":"2016-02-13T01:48:22Z","updated_at":"2016-02-13T01:48:22Z","body":"After looking at the test data, maybe a good idea to encode the gamma/linear trait in the Rgb. Looking at the options:\r\n\r\n#### Assume linear\r\n- Current behaviour\r\n- User needs to manually correct for gamma and this depends on the rgb space.\r\n- Easy to miss the gamma correction step.\r\n- Not clear when gamma correction is needed.\r\n\r\n#### Assume Gamma\r\n- Most values shown are gamma corrected.\r\n- Every calculation like mix, add etc must convert to linear and from linear.\r\n- Not practical.\r\n\r\n#### Add GammaEncoding trait\r\n- Srgba becomes RgbColor\\<Linear, Srgb, D65, T \\> or RgbColor\\<Gamma, Srgb, D65, T\\>\r\n- What should be the default?\r\n- How should it be made clear to the users that rgb's loaded from images or color list from somewhere are gamma encoded and should be loaded as such.\r\n\r\n\r\n"}}