{"action":"opened","number":230,"pull_request":{"url":"https://api.github.com/repos/tangrams/tangram/pulls/230","id":55639527,"html_url":"https://github.com/tangrams/tangram/pull/230","diff_url":"https://github.com/tangrams/tangram/pull/230.diff","patch_url":"https://github.com/tangrams/tangram/pull/230.patch","issue_url":"https://api.github.com/repos/tangrams/tangram/issues/230","number":230,"state":"open","locked":false,"title":"Add screenshot support","user":{"login":"bcamper","id":16733,"avatar_url":"https://avatars.githubusercontent.com/u/16733?v=3","gravatar_id":"","url":"https://api.github.com/users/bcamper","html_url":"https://github.com/bcamper","followers_url":"https://api.github.com/users/bcamper/followers","following_url":"https://api.github.com/users/bcamper/following{/other_user}","gists_url":"https://api.github.com/users/bcamper/gists{/gist_id}","starred_url":"https://api.github.com/users/bcamper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcamper/subscriptions","organizations_url":"https://api.github.com/users/bcamper/orgs","repos_url":"https://api.github.com/users/bcamper/repos","events_url":"https://api.github.com/users/bcamper/events{/privacy}","received_events_url":"https://api.github.com/users/bcamper/received_events","type":"User","site_admin":false},"body":"Incorporates screenshot-related support from the demo into Tangram itself. This will be useful for automated render testing, for apps like Tangram Play that may want to capture the view periodically, and for other users who would like to incorporate screenshot support.\r\n\r\nAPI changes:\r\n\r\n- A new scene method, `Scene.screenshot()`, which queues a screenshot request, and returns a Promise that fulfills when the screenshot is available. (The screenshot must be \"queued\" because it cannot be captured immediately: we must ensure that the GL buffer is finished drawing, and then must capture the buffer contents just after rendering, before it is cleared by other operations.)\r\n   - The promise resolves with an object containing two properties:\r\n      - `buffer`: a `Uint8Array` of raw Canvas pixel data.\r\n      - `blob`: a `Blob` of type `image/png`, suitable for saving to a file. Note that actually saving the blob to disk is left to the user or 3rd party library such as [FileSaver.js](https://github.com/eligrey/FileSaver.js/), as this goes a step beyond what can be considered generic Tangram functionality.\r\n   - Example usage of requesting and saving a screenshot:\r\n```\r\nscene.screenshot().then(function(screenshot) {\r\n    // uses FileSaver.js: https://github.com/eligrey/FileSaver.js/\r\n    saveAs(screenshot.blob, 'tangram-' + (+new Date()) + '.png');\r\n});\r\n```\r\n- A new scene event called `view_complete`, which fires when the view is in a \"resting state\", meaning new geometry is rendered, and no further tiles are loading/building. For example, when a scene is loaded, a `view_complete` event will fire when all tiles have loaded and the map renders. If the view is then zoomed in a level, another `view_complete` event will fire when the next zoom finishes rendering. `view_complete` can be subscribed to like other scene events:\r\n```\r\nscene.subscribe({\r\n    view_complete: function () {\r\n        console.log('scene view complete, rendered ' + \r\n            scene.render_count + ' primitives at: ' + \r\n            [scene.center.lng, scene.center.lat, scene.zoom].join('/'));\r\n    }\r\n});\r\n```\r\n- `Scene.screenshot()` can be paired with `view_complete` to automate screenshots, e.g. take a screenshot on initial scene view, take a screenshot for each new view, or a list of views for automated test generation, etc.","created_at":"2016-01-11T15:56:39Z","updated_at":"2016-01-11T15:56:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tangrams/tangram/pulls/230/commits","review_comments_url":"https://api.github.com/repos/tangrams/tangram/pulls/230/comments","review_comment_url":"https://api.github.com/repos/tangrams/tangram/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tangrams/tangram/issues/230/comments","statuses_url":"https://api.github.com/repos/tangrams/tangram/statuses/b89b22086c7cabeeb5ac4cb3f7fe765850a7554e","head":{"label":"tangrams:screenshot","ref":"screenshot","sha":"b89b22086c7cabeeb5ac4cb3f7fe765850a7554e","user":{"login":"tangrams","id":8495302,"avatar_url":"https://avatars.githubusercontent.com/u/8495302?v=3","gravatar_id":"","url":"https://api.github.com/users/tangrams","html_url":"https://github.com/tangrams","followers_url":"https://api.github.com/users/tangrams/followers","following_url":"https://api.github.com/users/tangrams/following{/other_user}","gists_url":"https://api.github.com/users/tangrams/gists{/gist_id}","starred_url":"https://api.github.com/users/tangrams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tangrams/subscriptions","organizations_url":"https://api.github.com/users/tangrams/orgs","repos_url":"https://api.github.com/users/tangrams/repos","events_url":"https://api.github.com/users/tangrams/events{/privacy}","received_events_url":"https://api.github.com/users/tangrams/received_events","type":"Organization","site_admin":false},"repo":{"id":13203894,"name":"tangram","full_name":"tangrams/tangram","owner":{"login":"tangrams","id":8495302,"avatar_url":"https://avatars.githubusercontent.com/u/8495302?v=3","gravatar_id":"","url":"https://api.github.com/users/tangrams","html_url":"https://github.com/tangrams","followers_url":"https://api.github.com/users/tangrams/followers","following_url":"https://api.github.com/users/tangrams/following{/other_user}","gists_url":"https://api.github.com/users/tangrams/gists{/gist_id}","starred_url":"https://api.github.com/users/tangrams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tangrams/subscriptions","organizations_url":"https://api.github.com/users/tangrams/orgs","repos_url":"https://api.github.com/users/tangrams/repos","events_url":"https://api.github.com/users/tangrams/events{/privacy}","received_events_url":"https://api.github.com/users/tangrams/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tangrams/tangram","description":"Real-Time WebGL Maps","fork":false,"url":"https://api.github.com/repos/tangrams/tangram","forks_url":"https://api.github.com/repos/tangrams/tangram/forks","keys_url":"https://api.github.com/repos/tangrams/tangram/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tangrams/tangram/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tangrams/tangram/teams","hooks_url":"https://api.github.com/repos/tangrams/tangram/hooks","issue_events_url":"https://api.github.com/repos/tangrams/tangram/issues/events{/number}","events_url":"https://api.github.com/repos/tangrams/tangram/events","assignees_url":"https://api.github.com/repos/tangrams/tangram/assignees{/user}","branches_url":"https://api.github.com/repos/tangrams/tangram/branches{/branch}","tags_url":"https://api.github.com/repos/tangrams/tangram/tags","blobs_url":"https://api.github.com/repos/tangrams/tangram/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tangrams/tangram/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tangrams/tangram/git/refs{/sha}","trees_url":"https://api.github.com/repos/tangrams/tangram/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tangrams/tangram/statuses/{sha}","languages_url":"https://api.github.com/repos/tangrams/tangram/languages","stargazers_url":"https://api.github.com/repos/tangrams/tangram/stargazers","contributors_url":"https://api.github.com/repos/tangrams/tangram/contributors","subscribers_url":"https://api.github.com/repos/tangrams/tangram/subscribers","subscription_url":"https://api.github.com/repos/tangrams/tangram/subscription","commits_url":"https://api.github.com/repos/tangrams/tangram/commits{/sha}","git_commits_url":"https://api.github.com/repos/tangrams/tangram/git/commits{/sha}","comments_url":"https://api.github.com/repos/tangrams/tangram/comments{/number}","issue_comment_url":"https://api.github.com/repos/tangrams/tangram/issues/comments{/number}","contents_url":"https://api.github.com/repos/tangrams/tangram/contents/{+path}","compare_url":"https://api.github.com/repos/tangrams/tangram/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tangrams/tangram/merges","archive_url":"https://api.github.com/repos/tangrams/tangram/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tangrams/tangram/downloads","issues_url":"https://api.github.com/repos/tangrams/tangram/issues{/number}","pulls_url":"https://api.github.com/repos/tangrams/tangram/pulls{/number}","milestones_url":"https://api.github.com/repos/tangrams/tangram/milestones{/number}","notifications_url":"https://api.github.com/repos/tangrams/tangram/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tangrams/tangram/labels{/name}","releases_url":"https://api.github.com/repos/tangrams/tangram/releases{/id}","created_at":"2013-09-30T01:59:45Z","updated_at":"2016-01-08T17:08:35Z","pushed_at":"2016-01-11T15:29:05Z","git_url":"git://github.com/tangrams/tangram.git","ssh_url":"git@github.com:tangrams/tangram.git","clone_url":"https://github.com/tangrams/tangram.git","svn_url":"https://github.com/tangrams/tangram","homepage":"http://tangrams.github.io/tangram","size":112921,"stargazers_count":584,"watchers_count":584,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":79,"mirror_url":null,"open_issues_count":9,"forks":79,"open_issues":9,"watchers":584,"default_branch":"master"}},"base":{"label":"tangrams:master","ref":"master","sha":"2c33c18cfccddfbcd75187516e2eab0199b9c974","user":{"login":"tangrams","id":8495302,"avatar_url":"https://avatars.githubusercontent.com/u/8495302?v=3","gravatar_id":"","url":"https://api.github.com/users/tangrams","html_url":"https://github.com/tangrams","followers_url":"https://api.github.com/users/tangrams/followers","following_url":"https://api.github.com/users/tangrams/following{/other_user}","gists_url":"https://api.github.com/users/tangrams/gists{/gist_id}","starred_url":"https://api.github.com/users/tangrams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tangrams/subscriptions","organizations_url":"https://api.github.com/users/tangrams/orgs","repos_url":"https://api.github.com/users/tangrams/repos","events_url":"https://api.github.com/users/tangrams/events{/privacy}","received_events_url":"https://api.github.com/users/tangrams/received_events","type":"Organization","site_admin":false},"repo":{"id":13203894,"name":"tangram","full_name":"tangrams/tangram","owner":{"login":"tangrams","id":8495302,"avatar_url":"https://avatars.githubusercontent.com/u/8495302?v=3","gravatar_id":"","url":"https://api.github.com/users/tangrams","html_url":"https://github.com/tangrams","followers_url":"https://api.github.com/users/tangrams/followers","following_url":"https://api.github.com/users/tangrams/following{/other_user}","gists_url":"https://api.github.com/users/tangrams/gists{/gist_id}","starred_url":"https://api.github.com/users/tangrams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tangrams/subscriptions","organizations_url":"https://api.github.com/users/tangrams/orgs","repos_url":"https://api.github.com/users/tangrams/repos","events_url":"https://api.github.com/users/tangrams/events{/privacy}","received_events_url":"https://api.github.com/users/tangrams/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tangrams/tangram","description":"Real-Time WebGL Maps","fork":false,"url":"https://api.github.com/repos/tangrams/tangram","forks_url":"https://api.github.com/repos/tangrams/tangram/forks","keys_url":"https://api.github.com/repos/tangrams/tangram/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tangrams/tangram/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tangrams/tangram/teams","hooks_url":"https://api.github.com/repos/tangrams/tangram/hooks","issue_events_url":"https://api.github.com/repos/tangrams/tangram/issues/events{/number}","events_url":"https://api.github.com/repos/tangrams/tangram/events","assignees_url":"https://api.github.com/repos/tangrams/tangram/assignees{/user}","branches_url":"https://api.github.com/repos/tangrams/tangram/branches{/branch}","tags_url":"https://api.github.com/repos/tangrams/tangram/tags","blobs_url":"https://api.github.com/repos/tangrams/tangram/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tangrams/tangram/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tangrams/tangram/git/refs{/sha}","trees_url":"https://api.github.com/repos/tangrams/tangram/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tangrams/tangram/statuses/{sha}","languages_url":"https://api.github.com/repos/tangrams/tangram/languages","stargazers_url":"https://api.github.com/repos/tangrams/tangram/stargazers","contributors_url":"https://api.github.com/repos/tangrams/tangram/contributors","subscribers_url":"https://api.github.com/repos/tangrams/tangram/subscribers","subscription_url":"https://api.github.com/repos/tangrams/tangram/subscription","commits_url":"https://api.github.com/repos/tangrams/tangram/commits{/sha}","git_commits_url":"https://api.github.com/repos/tangrams/tangram/git/commits{/sha}","comments_url":"https://api.github.com/repos/tangrams/tangram/comments{/number}","issue_comment_url":"https://api.github.com/repos/tangrams/tangram/issues/comments{/number}","contents_url":"https://api.github.com/repos/tangrams/tangram/contents/{+path}","compare_url":"https://api.github.com/repos/tangrams/tangram/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tangrams/tangram/merges","archive_url":"https://api.github.com/repos/tangrams/tangram/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tangrams/tangram/downloads","issues_url":"https://api.github.com/repos/tangrams/tangram/issues{/number}","pulls_url":"https://api.github.com/repos/tangrams/tangram/pulls{/number}","milestones_url":"https://api.github.com/repos/tangrams/tangram/milestones{/number}","notifications_url":"https://api.github.com/repos/tangrams/tangram/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tangrams/tangram/labels{/name}","releases_url":"https://api.github.com/repos/tangrams/tangram/releases{/id}","created_at":"2013-09-30T01:59:45Z","updated_at":"2016-01-08T17:08:35Z","pushed_at":"2016-01-11T15:29:05Z","git_url":"git://github.com/tangrams/tangram.git","ssh_url":"git@github.com:tangrams/tangram.git","clone_url":"https://github.com/tangrams/tangram.git","svn_url":"https://github.com/tangrams/tangram","homepage":"http://tangrams.github.io/tangram","size":112921,"stargazers_count":584,"watchers_count":584,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":79,"mirror_url":null,"open_issues_count":9,"forks":79,"open_issues":9,"watchers":584,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tangrams/tangram/pulls/230"},"html":{"href":"https://github.com/tangrams/tangram/pull/230"},"issue":{"href":"https://api.github.com/repos/tangrams/tangram/issues/230"},"comments":{"href":"https://api.github.com/repos/tangrams/tangram/issues/230/comments"},"review_comments":{"href":"https://api.github.com/repos/tangrams/tangram/pulls/230/comments"},"review_comment":{"href":"https://api.github.com/repos/tangrams/tangram/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tangrams/tangram/pulls/230/commits"},"statuses":{"href":"https://api.github.com/repos/tangrams/tangram/statuses/b89b22086c7cabeeb5ac4cb3f7fe765850a7554e"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":3,"additions":69,"deletions":22,"changed_files":3}}