{"action":"created","issue":{"url":"https://api.github.com/repos/processing/p5.js/issues/696","labels_url":"https://api.github.com/repos/processing/p5.js/issues/696/labels{/name}","comments_url":"https://api.github.com/repos/processing/p5.js/issues/696/comments","events_url":"https://api.github.com/repos/processing/p5.js/issues/696/events","html_url":"https://github.com/processing/p5.js/issues/696","id":82823842,"number":696,"title":"ColorMode() as global state","user":{"login":"workergnome","id":34536,"avatar_url":"https://avatars.githubusercontent.com/u/34536?v=3","gravatar_id":"","url":"https://api.github.com/users/workergnome","html_url":"https://github.com/workergnome","followers_url":"https://api.github.com/users/workergnome/followers","following_url":"https://api.github.com/users/workergnome/following{/other_user}","gists_url":"https://api.github.com/users/workergnome/gists{/gist_id}","starred_url":"https://api.github.com/users/workergnome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/workergnome/subscriptions","organizations_url":"https://api.github.com/users/workergnome/orgs","repos_url":"https://api.github.com/users/workergnome/repos","events_url":"https://api.github.com/users/workergnome/events{/privacy}","received_events_url":"https://api.github.com/users/workergnome/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/processing/p5.js/labels/discussion","name":"discussion","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-30T14:22:01Z","updated_at":"2015-05-30T15:06:06Z","closed_at":null,"body":"As we've been digging through the `colorMode` codebase as part of our conversations about HSB/HSL/RGB et al, we've run into a conceptual problem.\r\n\r\nA lot of this has to do with unintuitive behavior in colorMode.  Intuitively, I assume that the colorMode set is the mode that colors are used in.  For example:\r\n\r\n```javascript\r\n\r\n  colorMode(RGB, 255);\r\n  var c = color(127,255,0);\r\n\r\n  colorMode(RGB,1);\r\n  var myColor = c.getRed();\r\n  print(myColor);\t\r\n\r\n```\r\n\r\nI would assume, because I have set the global `colorMode`, that myColor would be equal to ~0.5.  Of course, it's not; it's equal to 127 just as I set it.  This is because what `colorMode` does is set *the way that colors are created*, not *what mode colors are in*.\r\n\r\nMy intuition says that setting HSB/RGB this way made sense, because it's easier than `color(100,200,100,RGB)` or rgbColor(100,200,300)`, but once we add the ability to scale colors values as a global state, it causes complications.\r\n\r\nFor things like `fill()` or `stroke()`, global states make sense, because the things that use them are just side effects, not objects with persistent state.  `colorMode()` is different—it involves persistence, and that means that we need to think harder about what it actually means.\r\n\r\nHaving an object whose functionality depends on globally set states also seems dirty to me.\r\n\r\n### Potential Options:\r\n\r\n1. We could calculate the `red()`, `green()`, `blue()`, `brightness()`, `saturation()`, `hue()`, et al using the global color mode.  There would be a performance hit here, but maybe not a large one, and it would make the software more intuitive.\r\n2. We could modify the documentation to better explain what `colorMode()` does.\r\n3. We could reconsider colorMode() as a global flag\r\n5. We could create explicit constructors for various modes and scalings. \r\n4. Someone could explain to me what I have missed, we could close this issue, and I could go back to sleeping nights."},"comment":{"url":"https://api.github.com/repos/processing/p5.js/issues/comments/107050166","html_url":"https://github.com/processing/p5.js/issues/696#issuecomment-107050166","issue_url":"https://api.github.com/repos/processing/p5.js/issues/696","id":107050166,"user":{"login":"sarahgp","id":1477362,"avatar_url":"https://avatars.githubusercontent.com/u/1477362?v=3","gravatar_id":"","url":"https://api.github.com/users/sarahgp","html_url":"https://github.com/sarahgp","followers_url":"https://api.github.com/users/sarahgp/followers","following_url":"https://api.github.com/users/sarahgp/following{/other_user}","gists_url":"https://api.github.com/users/sarahgp/gists{/gist_id}","starred_url":"https://api.github.com/users/sarahgp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sarahgp/subscriptions","organizations_url":"https://api.github.com/users/sarahgp/orgs","repos_url":"https://api.github.com/users/sarahgp/repos","events_url":"https://api.github.com/users/sarahgp/events{/privacy}","received_events_url":"https://api.github.com/users/sarahgp/received_events","type":"User","site_admin":false},"created_at":"2015-05-30T15:06:06Z","updated_at":"2015-05-30T15:06:06Z","body":"Also related to this is the fact that `color.toString()` is currently returning an unconverted rgba string. Once we figure out our direction, we can update this method to reflect it."}}