{"action":"closed","number":114,"pull_request":{"url":"https://api.github.com/repos/koggdal/ocanvas/pulls/114","id":42548268,"html_url":"https://github.com/koggdal/ocanvas/pull/114","diff_url":"https://github.com/koggdal/ocanvas/pull/114.diff","patch_url":"https://github.com/koggdal/ocanvas/pull/114.patch","issue_url":"https://api.github.com/repos/koggdal/ocanvas/issues/114","number":114,"state":"closed","locked":false,"title":"Added clipping feature","user":{"login":"nestorrente","id":9889025,"avatar_url":"https://avatars.githubusercontent.com/u/9889025?v=3","gravatar_id":"","url":"https://api.github.com/users/nestorrente","html_url":"https://github.com/nestorrente","followers_url":"https://api.github.com/users/nestorrente/followers","following_url":"https://api.github.com/users/nestorrente/following{/other_user}","gists_url":"https://api.github.com/users/nestorrente/gists{/gist_id}","starred_url":"https://api.github.com/users/nestorrente/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nestorrente/subscriptions","organizations_url":"https://api.github.com/users/nestorrente/orgs","repos_url":"https://api.github.com/users/nestorrente/repos","events_url":"https://api.github.com/users/nestorrente/events{/privacy}","received_events_url":"https://api.github.com/users/nestorrente/received_events","type":"User","site_admin":false},"body":"Now an object can \"clip\" its childs into its shape.\r\n\r\nBefore this change, the drawObject function restored the canvas before draw object's children. In that way, clipping feature was not possible.\r\n\r\nInstead of restoring canvas and making again all parent's transformations, now the canvas is restored after children were drawn. This allows us to use the clip() function before draw the object's children.\r\n\r\nI realized that the fillRect() function doesn't work fine with clip() -it paints the object above its children. That's the reason why I wrote the function fillRectClipping. This function executes a rect() then a fill() instead of a fillRect(). Using rect()+fill(), the object is painted below its children as expected.\r\n\r\nNow the trick begins: when an object has a \"clipChildren\" property with a truthly value, the following happens:\r\n1. canvas.fillRect() function is replaced by fillRectClipping function (line 159).\r\n2. object's draw() function is invoked (line 160).\r\n3. canvas.fillRect() function is restored (line 161).\r\n4. canvas.clip() function is invoked (line 162).\r\n\r\nWhen \"clipChildren\" property is not defined or it has a falsy value, only \"obj.draw()\" is invoked.\r\n\r\nHere its an example of this clipping feature:\r\n\r\n![clipping_example](https://cloud.githubusercontent.com/assets/9889025/9296631/a57d6f24-4491-11e5-883f-db6b1da55608.png)\r\n","created_at":"2015-08-17T01:40:18Z","updated_at":"2015-08-21T15:00:21Z","closed_at":"2015-08-21T15:00:21Z","merged_at":null,"merge_commit_sha":"2cdb1216db4ca1ab979865cea1ade0a7fcca468f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/koggdal/ocanvas/pulls/114/commits","review_comments_url":"https://api.github.com/repos/koggdal/ocanvas/pulls/114/comments","review_comment_url":"https://api.github.com/repos/koggdal/ocanvas/pulls/comments{/number}","comments_url":"https://api.github.com/repos/koggdal/ocanvas/issues/114/comments","statuses_url":"https://api.github.com/repos/koggdal/ocanvas/statuses/6cd04425d2787d049d51b63e8722f0bacdf40f86","head":{"label":"nestorrente:develop-patch-clipping","ref":"develop-patch-clipping","sha":"6cd04425d2787d049d51b63e8722f0bacdf40f86","user":{"login":"nestorrente","id":9889025,"avatar_url":"https://avatars.githubusercontent.com/u/9889025?v=3","gravatar_id":"","url":"https://api.github.com/users/nestorrente","html_url":"https://github.com/nestorrente","followers_url":"https://api.github.com/users/nestorrente/followers","following_url":"https://api.github.com/users/nestorrente/following{/other_user}","gists_url":"https://api.github.com/users/nestorrente/gists{/gist_id}","starred_url":"https://api.github.com/users/nestorrente/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nestorrente/subscriptions","organizations_url":"https://api.github.com/users/nestorrente/orgs","repos_url":"https://api.github.com/users/nestorrente/repos","events_url":"https://api.github.com/users/nestorrente/events{/privacy}","received_events_url":"https://api.github.com/users/nestorrente/received_events","type":"User","site_admin":false},"repo":{"id":40669898,"name":"ocanvas","full_name":"nestorrente/ocanvas","owner":{"login":"nestorrente","id":9889025,"avatar_url":"https://avatars.githubusercontent.com/u/9889025?v=3","gravatar_id":"","url":"https://api.github.com/users/nestorrente","html_url":"https://github.com/nestorrente","followers_url":"https://api.github.com/users/nestorrente/followers","following_url":"https://api.github.com/users/nestorrente/following{/other_user}","gists_url":"https://api.github.com/users/nestorrente/gists{/gist_id}","starred_url":"https://api.github.com/users/nestorrente/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nestorrente/subscriptions","organizations_url":"https://api.github.com/users/nestorrente/orgs","repos_url":"https://api.github.com/users/nestorrente/repos","events_url":"https://api.github.com/users/nestorrente/events{/privacy}","received_events_url":"https://api.github.com/users/nestorrente/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nestorrente/ocanvas","description":"JavaScript library for object-based canvas drawing.","fork":true,"url":"https://api.github.com/repos/nestorrente/ocanvas","forks_url":"https://api.github.com/repos/nestorrente/ocanvas/forks","keys_url":"https://api.github.com/repos/nestorrente/ocanvas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nestorrente/ocanvas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nestorrente/ocanvas/teams","hooks_url":"https://api.github.com/repos/nestorrente/ocanvas/hooks","issue_events_url":"https://api.github.com/repos/nestorrente/ocanvas/issues/events{/number}","events_url":"https://api.github.com/repos/nestorrente/ocanvas/events","assignees_url":"https://api.github.com/repos/nestorrente/ocanvas/assignees{/user}","branches_url":"https://api.github.com/repos/nestorrente/ocanvas/branches{/branch}","tags_url":"https://api.github.com/repos/nestorrente/ocanvas/tags","blobs_url":"https://api.github.com/repos/nestorrente/ocanvas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nestorrente/ocanvas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nestorrente/ocanvas/git/refs{/sha}","trees_url":"https://api.github.com/repos/nestorrente/ocanvas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nestorrente/ocanvas/statuses/{sha}","languages_url":"https://api.github.com/repos/nestorrente/ocanvas/languages","stargazers_url":"https://api.github.com/repos/nestorrente/ocanvas/stargazers","contributors_url":"https://api.github.com/repos/nestorrente/ocanvas/contributors","subscribers_url":"https://api.github.com/repos/nestorrente/ocanvas/subscribers","subscription_url":"https://api.github.com/repos/nestorrente/ocanvas/subscription","commits_url":"https://api.github.com/repos/nestorrente/ocanvas/commits{/sha}","git_commits_url":"https://api.github.com/repos/nestorrente/ocanvas/git/commits{/sha}","comments_url":"https://api.github.com/repos/nestorrente/ocanvas/comments{/number}","issue_comment_url":"https://api.github.com/repos/nestorrente/ocanvas/issues/comments{/number}","contents_url":"https://api.github.com/repos/nestorrente/ocanvas/contents/{+path}","compare_url":"https://api.github.com/repos/nestorrente/ocanvas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nestorrente/ocanvas/merges","archive_url":"https://api.github.com/repos/nestorrente/ocanvas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nestorrente/ocanvas/downloads","issues_url":"https://api.github.com/repos/nestorrente/ocanvas/issues{/number}","pulls_url":"https://api.github.com/repos/nestorrente/ocanvas/pulls{/number}","milestones_url":"https://api.github.com/repos/nestorrente/ocanvas/milestones{/number}","notifications_url":"https://api.github.com/repos/nestorrente/ocanvas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nestorrente/ocanvas/labels{/name}","releases_url":"https://api.github.com/repos/nestorrente/ocanvas/releases{/id}","created_at":"2015-08-13T16:35:00Z","updated_at":"2015-08-13T16:35:00Z","pushed_at":"2015-08-21T15:00:21Z","git_url":"git://github.com/nestorrente/ocanvas.git","ssh_url":"git@github.com:nestorrente/ocanvas.git","clone_url":"https://github.com/nestorrente/ocanvas.git","svn_url":"https://github.com/nestorrente/ocanvas","homepage":"http://ocanvas.org/","size":1169,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"koggdal:develop","ref":"develop","sha":"377a4e85f66a4947b3d324380499329e15bdb392","user":{"login":"koggdal","id":382138,"avatar_url":"https://avatars.githubusercontent.com/u/382138?v=3","gravatar_id":"","url":"https://api.github.com/users/koggdal","html_url":"https://github.com/koggdal","followers_url":"https://api.github.com/users/koggdal/followers","following_url":"https://api.github.com/users/koggdal/following{/other_user}","gists_url":"https://api.github.com/users/koggdal/gists{/gist_id}","starred_url":"https://api.github.com/users/koggdal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koggdal/subscriptions","organizations_url":"https://api.github.com/users/koggdal/orgs","repos_url":"https://api.github.com/users/koggdal/repos","events_url":"https://api.github.com/users/koggdal/events{/privacy}","received_events_url":"https://api.github.com/users/koggdal/received_events","type":"User","site_admin":false},"repo":{"id":1500404,"name":"ocanvas","full_name":"koggdal/ocanvas","owner":{"login":"koggdal","id":382138,"avatar_url":"https://avatars.githubusercontent.com/u/382138?v=3","gravatar_id":"","url":"https://api.github.com/users/koggdal","html_url":"https://github.com/koggdal","followers_url":"https://api.github.com/users/koggdal/followers","following_url":"https://api.github.com/users/koggdal/following{/other_user}","gists_url":"https://api.github.com/users/koggdal/gists{/gist_id}","starred_url":"https://api.github.com/users/koggdal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koggdal/subscriptions","organizations_url":"https://api.github.com/users/koggdal/orgs","repos_url":"https://api.github.com/users/koggdal/repos","events_url":"https://api.github.com/users/koggdal/events{/privacy}","received_events_url":"https://api.github.com/users/koggdal/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/koggdal/ocanvas","description":"JavaScript library for object-based canvas drawing.","fork":false,"url":"https://api.github.com/repos/koggdal/ocanvas","forks_url":"https://api.github.com/repos/koggdal/ocanvas/forks","keys_url":"https://api.github.com/repos/koggdal/ocanvas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/koggdal/ocanvas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/koggdal/ocanvas/teams","hooks_url":"https://api.github.com/repos/koggdal/ocanvas/hooks","issue_events_url":"https://api.github.com/repos/koggdal/ocanvas/issues/events{/number}","events_url":"https://api.github.com/repos/koggdal/ocanvas/events","assignees_url":"https://api.github.com/repos/koggdal/ocanvas/assignees{/user}","branches_url":"https://api.github.com/repos/koggdal/ocanvas/branches{/branch}","tags_url":"https://api.github.com/repos/koggdal/ocanvas/tags","blobs_url":"https://api.github.com/repos/koggdal/ocanvas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/koggdal/ocanvas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/koggdal/ocanvas/git/refs{/sha}","trees_url":"https://api.github.com/repos/koggdal/ocanvas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/koggdal/ocanvas/statuses/{sha}","languages_url":"https://api.github.com/repos/koggdal/ocanvas/languages","stargazers_url":"https://api.github.com/repos/koggdal/ocanvas/stargazers","contributors_url":"https://api.github.com/repos/koggdal/ocanvas/contributors","subscribers_url":"https://api.github.com/repos/koggdal/ocanvas/subscribers","subscription_url":"https://api.github.com/repos/koggdal/ocanvas/subscription","commits_url":"https://api.github.com/repos/koggdal/ocanvas/commits{/sha}","git_commits_url":"https://api.github.com/repos/koggdal/ocanvas/git/commits{/sha}","comments_url":"https://api.github.com/repos/koggdal/ocanvas/comments{/number}","issue_comment_url":"https://api.github.com/repos/koggdal/ocanvas/issues/comments{/number}","contents_url":"https://api.github.com/repos/koggdal/ocanvas/contents/{+path}","compare_url":"https://api.github.com/repos/koggdal/ocanvas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/koggdal/ocanvas/merges","archive_url":"https://api.github.com/repos/koggdal/ocanvas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/koggdal/ocanvas/downloads","issues_url":"https://api.github.com/repos/koggdal/ocanvas/issues{/number}","pulls_url":"https://api.github.com/repos/koggdal/ocanvas/pulls{/number}","milestones_url":"https://api.github.com/repos/koggdal/ocanvas/milestones{/number}","notifications_url":"https://api.github.com/repos/koggdal/ocanvas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/koggdal/ocanvas/labels{/name}","releases_url":"https://api.github.com/repos/koggdal/ocanvas/releases{/id}","created_at":"2011-03-19T16:23:10Z","updated_at":"2015-08-21T04:36:12Z","pushed_at":"2015-08-21T15:00:22Z","git_url":"git://github.com/koggdal/ocanvas.git","ssh_url":"git@github.com:koggdal/ocanvas.git","clone_url":"https://github.com/koggdal/ocanvas.git","svn_url":"https://github.com/koggdal/ocanvas","homepage":"http://ocanvas.org/","size":1716,"stargazers_count":353,"watchers_count":353,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":45,"mirror_url":null,"open_issues_count":21,"forks":45,"open_issues":21,"watchers":353,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/koggdal/ocanvas/pulls/114"},"html":{"href":"https://github.com/koggdal/ocanvas/pull/114"},"issue":{"href":"https://api.github.com/repos/koggdal/ocanvas/issues/114"},"comments":{"href":"https://api.github.com/repos/koggdal/ocanvas/issues/114/comments"},"review_comments":{"href":"https://api.github.com/repos/koggdal/ocanvas/pulls/114/comments"},"review_comment":{"href":"https://api.github.com/repos/koggdal/ocanvas/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/koggdal/ocanvas/pulls/114/commits"},"statuses":{"href":"https://api.github.com/repos/koggdal/ocanvas/statuses/6cd04425d2787d049d51b63e8722f0bacdf40f86"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":6,"review_comments":0,"commits":0,"additions":0,"deletions":0,"changed_files":0}}