{"action":"created","issue":{"url":"https://api.github.com/repos/thelounge/lounge/issues/357","repository_url":"https://api.github.com/repos/thelounge/lounge","labels_url":"https://api.github.com/repos/thelounge/lounge/issues/357/labels{/name}","comments_url":"https://api.github.com/repos/thelounge/lounge/issues/357/comments","events_url":"https://api.github.com/repos/thelounge/lounge/issues/357/events","html_url":"https://github.com/thelounge/lounge/pull/357","id":157374874,"number":357,"title":"New nick colors (again)","user":{"login":"maxpoulin64","id":5481612,"avatar_url":"https://avatars.githubusercontent.com/u/5481612?v=3","gravatar_id":"","url":"https://api.github.com/users/maxpoulin64","html_url":"https://github.com/maxpoulin64","followers_url":"https://api.github.com/users/maxpoulin64/followers","following_url":"https://api.github.com/users/maxpoulin64/following{/other_user}","gists_url":"https://api.github.com/users/maxpoulin64/gists{/gist_id}","starred_url":"https://api.github.com/users/maxpoulin64/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxpoulin64/subscriptions","organizations_url":"https://api.github.com/users/maxpoulin64/orgs","repos_url":"https://api.github.com/users/maxpoulin64/repos","events_url":"https://api.github.com/users/maxpoulin64/events{/privacy}","received_events_url":"https://api.github.com/users/maxpoulin64/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/thelounge/lounge/labels/do%20not%20merge","name":"do not merge","color":"ff0000"},{"url":"https://api.github.com/repos/thelounge/lounge/labels/enhancement","name":"enhancement","color":"2196F3"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-05-29T08:07:31Z","updated_at":"2016-05-30T22:37:08Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/thelounge/lounge/pulls/357","html_url":"https://github.com/thelounge/lounge/pull/357","diff_url":"https://github.com/thelounge/lounge/pull/357.diff","patch_url":"https://github.com/thelounge/lounge/pull/357.patch"},"body":"This one was generated by a script designed to spread all colors evenly and adjust the brightness dynamically when the contrast ratio is too low. The end result is that we have all the colors adapted for each theme.\r\n\r\nSample:\r\n![compare](https://cloud.githubusercontent.com/assets/5481612/15631982/30246bdc-2551-11e6-9030-6fefd2f591ff.png)\r\n\r\nShould fix #335, which is what pushed me to do this (when rendering the list of colors, there were very close duplicates and overall the colors were kinda meh).\r\n\r\n32 colors is a lot, it's very hard to not have duplicates or too close colors without going for the whole spectrum.\r\n\r\nGenerator script for reference or tweaking:\r\n```javascript\r\nvar Color = require(\"color\");\r\n\r\nvar background = Color(\"#3f3f3f\");\r\nvar backgroundL = background.luminosity();\r\n\r\nfunction printcolor(n, color) {\r\n\tconsole.log(\"#chat.colored-nicks .user.color-\"+ ((n < 10) ? n + \" \" : n)\r\n\t\t+ \" { color: \" + color.hexString() + \"; }\");\r\n}\r\n\r\nfunction genrainbow(start, end, gencolor, adjust) {\r\n\tfor(var i = start; i <= end; i++) {\r\n\t\tvar fact = (i-start)/(end-start);\r\n\t\tprintcolor(i, adjust(gencolor(fact), i));\r\n\t}\r\n}\r\n\r\ngenrainbow(\r\n\t1, 32,\r\n\t(fact) => Color().hsl(fact*310, 100, 50),\r\n\t(color, n) => {\r\n\t\tvar contrast = color.contrast(background);\r\n\t\tvar luminosity = color.luminosity();\r\n\r\n\t\tif(contrast < 2.5) {\r\n\t\t\tif(backgroundL > luminosity) {\r\n\t\t\t\tcolor.darken(contrast/5);\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tcolor.lighten(contrast/3);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn color;\r\n\t}\r\n);\r\n```"},"comment":{"url":"https://api.github.com/repos/thelounge/lounge/issues/comments/222562139","html_url":"https://github.com/thelounge/lounge/pull/357#issuecomment-222562139","issue_url":"https://api.github.com/repos/thelounge/lounge/issues/357","id":222562139,"user":{"login":"astorije","id":113730,"avatar_url":"https://avatars.githubusercontent.com/u/113730?v=3","gravatar_id":"","url":"https://api.github.com/users/astorije","html_url":"https://github.com/astorije","followers_url":"https://api.github.com/users/astorije/followers","following_url":"https://api.github.com/users/astorije/following{/other_user}","gists_url":"https://api.github.com/users/astorije/gists{/gist_id}","starred_url":"https://api.github.com/users/astorije/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astorije/subscriptions","organizations_url":"https://api.github.com/users/astorije/orgs","repos_url":"https://api.github.com/users/astorije/repos","events_url":"https://api.github.com/users/astorije/events{/privacy}","received_events_url":"https://api.github.com/users/astorije/received_events","type":"User","site_admin":false},"created_at":"2016-05-30T22:37:08Z","updated_at":"2016-05-30T22:37:08Z","body":"> You can solve this by using something like murmurhash (it's quite simple and fast).\r\n\r\nWe could, but when I see [this JS implementation of murmurhash](https://github.com/garycourt/murmurhash-js/blob/0197ce38bedac0e05f40b9d7152095d06db8292c/murmurhash2_gc.js#L14-L50) compared to [what we have on `master`](https://github.com/thelounge/lounge/blob/7157076aad1837db408b58c6b452bf20a8493b1a/client/js/libs/handlebars/colorClass.js#L5-L12) or [your earlier implementation of `hashCode`](https://github.com/thelounge/lounge/pull/322/files#diff-1d12033fe31e161ba1cd53ac22b39929R18), I don't think we need to go that far.\r\n\r\nTo be honest, I don't think successive hashing like we have will be a problem to channels of, say, ~100-200 users anyway. It's very unlikely that most nicks will be directly successive (like `lorema` and `loremab` will have very different hashes) but it could on channels with thousands of nicks.\r\nI don't care too much but randomizing could be needed in the latter case, so just to keep in mind if needed. Of course, no big deal in not randomizing I think."}}
{"actor":{"display_login":"astorije"}}