{"action":"created","comment":{"url":"https://api.github.com/repos/plasma-umass/ElementaryJS/pulls/comments/212752005","pull_request_review_id":149456463,"id":212752005,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMjc1MjAwNQ==","diff_hunk":"@@ -1,5 +1,79 @@\n import { getRunner } from './runtime';\n \n+function hexColorChannel(n: number): string {\n+  let v = (Math.floor(n * 255)).toString(16);\n+  if (v.length < 2) v = '0' + v;\n+  return v;\n+}\n+\n+function rgbToHex(rgb: number[]): string {\n+  let hex = '#';\n+  for (let i = 0; i < 3; ++i) {\n+    hex += hexColorChannel(rgb[i]);\n+  }\n+  return hex;\n+}\n+\n+export class DrawingCanvas {\n+  width: number = 1;\n+  height: number = 1;\n+  ctx: CanvasRenderingContext2D | undefined = undefined;\n+  constructor(w: number, h: number) {\n+    if (arguments.length !== 2) {\n+      throw new TypeError(`Failed to construct Node 'DrawingCanvas': 2 arguments required but ${arguments.length} given`);\n+    }\n+    this.width = w;\n+    this.height = h;\n+    if (typeof document === 'undefined') {\n+      return; //  for node\n+    }\n+    const canvases = document.getElementById('canvases')!;","path":"ts/lib220.ts","position":30,"original_position":30,"commit_id":"0bed56dccbbec20aeedc15a7dbc44493156cff94","original_commit_id":"0bed56dccbbec20aeedc15a7dbc44493156cff94","user":{"login":"joydeep-b","id":3406269,"node_id":"MDQ6VXNlcjM0MDYyNjk=","avatar_url":"https://avatars2.githubusercontent.com/u/3406269?v=4","gravatar_id":"","url":"https://api.github.com/users/joydeep-b","html_url":"https://github.com/joydeep-b","followers_url":"https://api.github.com/users/joydeep-b/followers","following_url":"https://api.github.com/users/joydeep-b/following{/other_user}","gists_url":"https://api.github.com/users/joydeep-b/gists{/gist_id}","starred_url":"https://api.github.com/users/joydeep-b/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joydeep-b/subscriptions","organizations_url":"https://api.github.com/users/joydeep-b/orgs","repos_url":"https://api.github.com/users/joydeep-b/repos","events_url":"https://api.github.com/users/joydeep-b/events{/privacy}","received_events_url":"https://api.github.com/users/joydeep-b/received_events","type":"User","site_admin":false},"body":"The drawing actually happens in a saved context `ctx`, so creation of new canvases is not a problem - it still draws on the correct canvas (the one that was created in the constructor).\r\n\r\nWhat effect were you thinking of? The one edge case that we have is that we delete older canvases. Interestingly, the browser happily accepts drawing commands to a context which no longer exists, without any errors.","created_at":"2018-08-24T20:51:48Z","updated_at":"2018-08-24T20:51:48Z","html_url":"https://github.com/plasma-umass/ElementaryJS/pull/43#discussion_r212752005","pull_request_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/pulls/43","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/plasma-umass/ElementaryJS/pulls/comments/212752005"},"html":{"href":"https://github.com/plasma-umass/ElementaryJS/pull/43#discussion_r212752005"},"pull_request":{"href":"https://api.github.com/repos/plasma-umass/ElementaryJS/pulls/43"}},"in_reply_to_id":212743221},"pull_request":{"url":"https://api.github.com/repos/plasma-umass/ElementaryJS/pulls/43","id":210626360,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEwNjI2MzYw","html_url":"https://github.com/plasma-umass/ElementaryJS/pull/43","diff_url":"https://github.com/plasma-umass/ElementaryJS/pull/43.diff","patch_url":"https://github.com/plasma-umass/ElementaryJS/pull/43.patch","issue_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/issues/43","number":43,"state":"open","locked":false,"title":"Added native canvas drawing","user":{"login":"joydeep-b","id":3406269,"node_id":"MDQ6VXNlcjM0MDYyNjk=","avatar_url":"https://avatars2.githubusercontent.com/u/3406269?v=4","gravatar_id":"","url":"https://api.github.com/users/joydeep-b","html_url":"https://github.com/joydeep-b","followers_url":"https://api.github.com/users/joydeep-b/followers","following_url":"https://api.github.com/users/joydeep-b/following{/other_user}","gists_url":"https://api.github.com/users/joydeep-b/gists{/gist_id}","starred_url":"https://api.github.com/users/joydeep-b/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joydeep-b/subscriptions","organizations_url":"https://api.github.com/users/joydeep-b/orgs","repos_url":"https://api.github.com/users/joydeep-b/repos","events_url":"https://api.github.com/users/joydeep-b/events{/privacy}","received_events_url":"https://api.github.com/users/joydeep-b/received_events","type":"User","site_admin":false},"body":"Example usage:\r\n```js\r\nc = lib220.newCanvas(600, 600);\r\nc.drawArc(300, 300, 200, 0, 2 * Math.PI, [0.8, 0.4, 0]);\r\n\r\nfor (let i = 0; i < 100; ++i) {\r\n  const a = i / 100 * Math.PI;\r\n  const x = 200 * Math.cos(a);\r\n  const y = 200 * Math.sin(a);\r\n  c.drawLine(300 + x, 300 + y, 300 - x,\r\n    300 - y, [1, 0.5, 0]);\r\n}\r\n```","created_at":"2018-08-24T02:54:08Z","updated_at":"2018-08-24T20:51:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cabb5d6ff158fd712b0a4f8bc097522d700de987","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/pulls/43/commits","review_comments_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/pulls/43/comments","review_comment_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/pulls/comments{/number}","comments_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/issues/43/comments","statuses_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/statuses/0bed56dccbbec20aeedc15a7dbc44493156cff94","head":{"label":"plasma-umass:canvas-drawing","ref":"canvas-drawing","sha":"0bed56dccbbec20aeedc15a7dbc44493156cff94","user":{"login":"plasma-umass","id":1880823,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4ODA4MjM=","avatar_url":"https://avatars3.githubusercontent.com/u/1880823?v=4","gravatar_id":"","url":"https://api.github.com/users/plasma-umass","html_url":"https://github.com/plasma-umass","followers_url":"https://api.github.com/users/plasma-umass/followers","following_url":"https://api.github.com/users/plasma-umass/following{/other_user}","gists_url":"https://api.github.com/users/plasma-umass/gists{/gist_id}","starred_url":"https://api.github.com/users/plasma-umass/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plasma-umass/subscriptions","organizations_url":"https://api.github.com/users/plasma-umass/orgs","repos_url":"https://api.github.com/users/plasma-umass/repos","events_url":"https://api.github.com/users/plasma-umass/events{/privacy}","received_events_url":"https://api.github.com/users/plasma-umass/received_events","type":"Organization","site_admin":false},"repo":{"id":141826086,"node_id":"MDEwOlJlcG9zaXRvcnkxNDE4MjYwODY=","name":"ElementaryJS","full_name":"plasma-umass/ElementaryJS","owner":{"login":"plasma-umass","id":1880823,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4ODA4MjM=","avatar_url":"https://avatars3.githubusercontent.com/u/1880823?v=4","gravatar_id":"","url":"https://api.github.com/users/plasma-umass","html_url":"https://github.com/plasma-umass","followers_url":"https://api.github.com/users/plasma-umass/followers","following_url":"https://api.github.com/users/plasma-umass/following{/other_user}","gists_url":"https://api.github.com/users/plasma-umass/gists{/gist_id}","starred_url":"https://api.github.com/users/plasma-umass/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plasma-umass/subscriptions","organizations_url":"https://api.github.com/users/plasma-umass/orgs","repos_url":"https://api.github.com/users/plasma-umass/repos","events_url":"https://api.github.com/users/plasma-umass/events{/privacy}","received_events_url":"https://api.github.com/users/plasma-umass/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/plasma-umass/ElementaryJS","description":"JavaScript without the sharp edges","fork":false,"url":"https://api.github.com/repos/plasma-umass/ElementaryJS","forks_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/forks","keys_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/teams","hooks_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/hooks","issue_events_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/issues/events{/number}","events_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/events","assignees_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/assignees{/user}","branches_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/branches{/branch}","tags_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/tags","blobs_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/git/refs{/sha}","trees_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/statuses/{sha}","languages_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/languages","stargazers_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/stargazers","contributors_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/contributors","subscribers_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/subscribers","subscription_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/subscription","commits_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/commits{/sha}","git_commits_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/git/commits{/sha}","comments_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/comments{/number}","issue_comment_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/issues/comments{/number}","contents_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/contents/{+path}","compare_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/merges","archive_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/downloads","issues_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/issues{/number}","pulls_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/pulls{/number}","milestones_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/milestones{/number}","notifications_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/labels{/name}","releases_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/releases{/id}","deployments_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/deployments","created_at":"2018-07-21T15:49:19Z","updated_at":"2018-08-24T14:41:32Z","pushed_at":"2018-08-24T20:11:20Z","git_url":"git://github.com/plasma-umass/ElementaryJS.git","ssh_url":"git@github.com:plasma-umass/ElementaryJS.git","clone_url":"https://github.com/plasma-umass/ElementaryJS.git","svn_url":"https://github.com/plasma-umass/ElementaryJS","homepage":null,"size":214,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"plasma-umass:master","ref":"master","sha":"e0f18a116838d3ae47fc36fbb48c70e50dc442c4","user":{"login":"plasma-umass","id":1880823,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4ODA4MjM=","avatar_url":"https://avatars3.githubusercontent.com/u/1880823?v=4","gravatar_id":"","url":"https://api.github.com/users/plasma-umass","html_url":"https://github.com/plasma-umass","followers_url":"https://api.github.com/users/plasma-umass/followers","following_url":"https://api.github.com/users/plasma-umass/following{/other_user}","gists_url":"https://api.github.com/users/plasma-umass/gists{/gist_id}","starred_url":"https://api.github.com/users/plasma-umass/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plasma-umass/subscriptions","organizations_url":"https://api.github.com/users/plasma-umass/orgs","repos_url":"https://api.github.com/users/plasma-umass/repos","events_url":"https://api.github.com/users/plasma-umass/events{/privacy}","received_events_url":"https://api.github.com/users/plasma-umass/received_events","type":"Organization","site_admin":false},"repo":{"id":141826086,"node_id":"MDEwOlJlcG9zaXRvcnkxNDE4MjYwODY=","name":"ElementaryJS","full_name":"plasma-umass/ElementaryJS","owner":{"login":"plasma-umass","id":1880823,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4ODA4MjM=","avatar_url":"https://avatars3.githubusercontent.com/u/1880823?v=4","gravatar_id":"","url":"https://api.github.com/users/plasma-umass","html_url":"https://github.com/plasma-umass","followers_url":"https://api.github.com/users/plasma-umass/followers","following_url":"https://api.github.com/users/plasma-umass/following{/other_user}","gists_url":"https://api.github.com/users/plasma-umass/gists{/gist_id}","starred_url":"https://api.github.com/users/plasma-umass/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plasma-umass/subscriptions","organizations_url":"https://api.github.com/users/plasma-umass/orgs","repos_url":"https://api.github.com/users/plasma-umass/repos","events_url":"https://api.github.com/users/plasma-umass/events{/privacy}","received_events_url":"https://api.github.com/users/plasma-umass/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/plasma-umass/ElementaryJS","description":"JavaScript without the sharp edges","fork":false,"url":"https://api.github.com/repos/plasma-umass/ElementaryJS","forks_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/forks","keys_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/teams","hooks_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/hooks","issue_events_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/issues/events{/number}","events_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/events","assignees_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/assignees{/user}","branches_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/branches{/branch}","tags_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/tags","blobs_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/git/refs{/sha}","trees_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/statuses/{sha}","languages_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/languages","stargazers_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/stargazers","contributors_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/contributors","subscribers_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/subscribers","subscription_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/subscription","commits_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/commits{/sha}","git_commits_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/git/commits{/sha}","comments_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/comments{/number}","issue_comment_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/issues/comments{/number}","contents_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/contents/{+path}","compare_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/merges","archive_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/downloads","issues_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/issues{/number}","pulls_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/pulls{/number}","milestones_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/milestones{/number}","notifications_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/labels{/name}","releases_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/releases{/id}","deployments_url":"https://api.github.com/repos/plasma-umass/ElementaryJS/deployments","created_at":"2018-07-21T15:49:19Z","updated_at":"2018-08-24T14:41:32Z","pushed_at":"2018-08-24T20:11:20Z","git_url":"git://github.com/plasma-umass/ElementaryJS.git","ssh_url":"git@github.com:plasma-umass/ElementaryJS.git","clone_url":"https://github.com/plasma-umass/ElementaryJS.git","svn_url":"https://github.com/plasma-umass/ElementaryJS","homepage":null,"size":214,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/plasma-umass/ElementaryJS/pulls/43"},"html":{"href":"https://github.com/plasma-umass/ElementaryJS/pull/43"},"issue":{"href":"https://api.github.com/repos/plasma-umass/ElementaryJS/issues/43"},"comments":{"href":"https://api.github.com/repos/plasma-umass/ElementaryJS/issues/43/comments"},"review_comments":{"href":"https://api.github.com/repos/plasma-umass/ElementaryJS/pulls/43/comments"},"review_comment":{"href":"https://api.github.com/repos/plasma-umass/ElementaryJS/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/plasma-umass/ElementaryJS/pulls/43/commits"},"statuses":{"href":"https://api.github.com/repos/plasma-umass/ElementaryJS/statuses/0bed56dccbbec20aeedc15a7dbc44493156cff94"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"joydeep-b"}}