{"action":"created","comment":{"url":"https://api.github.com/repos/Pomax/bezierjs/pulls/comments/34963688","id":34963688,"diff_hunk":"@@ -1,29 +1,72 @@\n+var assert = require(\"assert\");\n var Bezier = require(\"./lib\");\n \n-function check(b) {\n-  console.log(\"---\");\n-  console.log(b.toString());\n-  console.log(b.length());\n-  console.log(b.dpoints);\n-  console.log(b.derivative(0), b.derivative(0.5), b.derivative(1));\n-  console.log(b.normal(0), b.normal(0.5), b.normal(1));\n+// plain and SVG quadratic check\n+[\n+  new Bezier(0,0, .5,1, 1,0),\n+  Bezier.fromSVG(\"M 0 0 Q 0.5 1 1 0\")\n+]\n+  .forEach(function(b) {\n+    assert.equal(b.toString(), \"[0/0, 0.5/1, 1/0]\");\n+    assert.equal(b.length(), 1.4789428575453212);\n+    assert.deepEqual(b.dpoints, [\n+      [{x:1, y:2}, {x:1, y:-2}],\n+      [{x:0, y:-4}]\n+    ]);\n \n-  var res = b.split(0.321);\n-  var points = res.span;\n-//  console.log(utils.pointsToString(points));\n-  var p321 = b.get(0.321);\n-//  console.log(\"check on final point: should be \", utils.pointToString(p321));\n+    assert.deepEqual(b.derivative(0), {x:1, y:2});\n+    assert.deepEqual(b.derivative(0.5), {x:1, y:0});\n+    assert.deepEqual(b.derivative(1), {x:1, y:-2});\n \n-  var roots = b.inflections();\n-  console.log(roots);\n+    assert.deepEqual(b.normal(0), {x:-0.8944271909999159, y:0.4472135954999579});\n+    assert.deepEqual(b.normal(0.5), {x:-0, y:1});\n+    assert.deepEqual(b.normal(1), {x:0.8944271909999159, y:0.4472135954999579});\n \n-  console.log(b.bbox());\n-}\n+    assert.deepEqual(b.inflections(), {x:[], y:[0.5], values:[0.5]});\n+    assert.deepEqual(b.bbox(), {\n+      x:{min:0, mid:0.5, max:1, size:1},\n+      y:{min:0, mid:0.25, max:0.5, size:0.5}\n+    });\n+  });\n \n-// plain and SVG quadratic check\n-check(new Bezier(0,0 , 0.5,1 , 1,0));\n-check(Bezier.fromSVG(\"M 0 0 Q 0.5 1 1 0\"));\n+// SVG relative quadratic check\n+assert.equal(\n+  Bezier.fromSVG(\"5 5c.5 1 1 0\").toString(),\n+  \"[5/5, 5.5/6, 6/5]\"\n+);\n \n // plain and SVG cubic check\n-check(new Bezier(0,0 , 0,1   , 1,1 , 1,0));\n-check(Bezier.fromSVG(\"m 0 0 C 0 1 1 0 0 -1\"));\n+[\n+  new Bezier(0,0, 0,1, 1,1, 1,0),\n+  Bezier.fromSVG(\"m 0 0 C 0 1 1 1 1 0\")\n+]\n+  .forEach(function(b) {\n+    assert.equal(b.toString(), \"[0/0, 0/1, 1/1, 1/0]\");\n+    assert.equal(b.length(), 2.0000000000000004);","path":"test.js","position":66,"original_position":66,"commit_id":"cf3a95a98e1d974c2c515c7d29c761621ed5ff40","original_commit_id":"cf3a95a98e1d974c2c515c7d29c761621ed5ff40","user":{"login":"Pomax","id":177243,"avatar_url":"https://avatars.githubusercontent.com/u/177243?v=3","gravatar_id":"","url":"https://api.github.com/users/Pomax","html_url":"https://github.com/Pomax","followers_url":"https://api.github.com/users/Pomax/followers","following_url":"https://api.github.com/users/Pomax/following{/other_user}","gists_url":"https://api.github.com/users/Pomax/gists{/gist_id}","starred_url":"https://api.github.com/users/Pomax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pomax/subscriptions","organizations_url":"https://api.github.com/users/Pomax/orgs","repos_url":"https://api.github.com/users/Pomax/repos","events_url":"https://api.github.com/users/Pomax/events{/privacy}","received_events_url":"https://api.github.com/users/Pomax/received_events","type":"User","site_admin":false},"body":"That feels a little too brittle, it probably makes more sense to test `b.length() - 2` being smaller than a small epsilon value","created_at":"2015-07-19T23:30:30Z","updated_at":"2015-07-19T23:30:30Z","html_url":"https://github.com/Pomax/bezierjs/pull/13#discussion_r34963688","pull_request_url":"https://api.github.com/repos/Pomax/bezierjs/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/Pomax/bezierjs/pulls/comments/34963688"},"html":{"href":"https://github.com/Pomax/bezierjs/pull/13#discussion_r34963688"},"pull_request":{"href":"https://api.github.com/repos/Pomax/bezierjs/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/Pomax/bezierjs/pulls/13","id":40311284,"html_url":"https://github.com/Pomax/bezierjs/pull/13","diff_url":"https://github.com/Pomax/bezierjs/pull/13.diff","patch_url":"https://github.com/Pomax/bezierjs/pull/13.patch","issue_url":"https://api.github.com/repos/Pomax/bezierjs/issues/13","number":13,"state":"open","locked":false,"title":"Relative SVG path parser works correctly now","user":{"login":"betula","id":421161,"avatar_url":"https://avatars.githubusercontent.com/u/421161?v=3","gravatar_id":"","url":"https://api.github.com/users/betula","html_url":"https://github.com/betula","followers_url":"https://api.github.com/users/betula/followers","following_url":"https://api.github.com/users/betula/following{/other_user}","gists_url":"https://api.github.com/users/betula/gists{/gist_id}","starred_url":"https://api.github.com/users/betula/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/betula/subscriptions","organizations_url":"https://api.github.com/users/betula/orgs","repos_url":"https://api.github.com/users/betula/repos","events_url":"https://api.github.com/users/betula/events{/privacy}","received_events_url":"https://api.github.com/users/betula/received_events","type":"User","site_admin":false},"body":"First letter \"m\" or \"M\" affects only if we have compound svg path, and new coordinate for first point calculating relative of last point previous path.\r\nFor relative or absolute curve coordinates we need to use \"C\" (absolute) \"c\" (relative) or \"Q\" and \"q\" for quadratic bezier curve.\r\nFor right calculation of relative curve points we need add coordinates of start point to all of next curve points.\r\nExample: http://codepen.io/betula/pen/YXvaWa?editors=100\r\nFormat normal SVG path data [M0 0L-1,-.5m.2e1+1h-1v-.5](http://codepen.io/betula/pen/ZGjmdB)\r\nAnd parser from commit convert it to values: [0, 0, -1, -0.5, 2, 1, -1, -0.5]","created_at":"2015-07-19T16:53:31Z","updated_at":"2015-07-19T23:30:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"671afe80d0bc903837de980e754a9fd7fba9dcbc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Pomax/bezierjs/pulls/13/commits","review_comments_url":"https://api.github.com/repos/Pomax/bezierjs/pulls/13/comments","review_comment_url":"https://api.github.com/repos/Pomax/bezierjs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Pomax/bezierjs/issues/13/comments","statuses_url":"https://api.github.com/repos/Pomax/bezierjs/statuses/cf3a95a98e1d974c2c515c7d29c761621ed5ff40","head":{"label":"betula:gh-pages","ref":"gh-pages","sha":"cf3a95a98e1d974c2c515c7d29c761621ed5ff40","user":{"login":"betula","id":421161,"avatar_url":"https://avatars.githubusercontent.com/u/421161?v=3","gravatar_id":"","url":"https://api.github.com/users/betula","html_url":"https://github.com/betula","followers_url":"https://api.github.com/users/betula/followers","following_url":"https://api.github.com/users/betula/following{/other_user}","gists_url":"https://api.github.com/users/betula/gists{/gist_id}","starred_url":"https://api.github.com/users/betula/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/betula/subscriptions","organizations_url":"https://api.github.com/users/betula/orgs","repos_url":"https://api.github.com/users/betula/repos","events_url":"https://api.github.com/users/betula/events{/privacy}","received_events_url":"https://api.github.com/users/betula/received_events","type":"User","site_admin":false},"repo":{"id":39106789,"name":"bezierjs","full_name":"betula/bezierjs","owner":{"login":"betula","id":421161,"avatar_url":"https://avatars.githubusercontent.com/u/421161?v=3","gravatar_id":"","url":"https://api.github.com/users/betula","html_url":"https://github.com/betula","followers_url":"https://api.github.com/users/betula/followers","following_url":"https://api.github.com/users/betula/following{/other_user}","gists_url":"https://api.github.com/users/betula/gists{/gist_id}","starred_url":"https://api.github.com/users/betula/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/betula/subscriptions","organizations_url":"https://api.github.com/users/betula/orgs","repos_url":"https://api.github.com/users/betula/repos","events_url":"https://api.github.com/users/betula/events{/privacy}","received_events_url":"https://api.github.com/users/betula/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/betula/bezierjs","description":"A nodejs and client-side library for (cubic) Bezier curve work","fork":true,"url":"https://api.github.com/repos/betula/bezierjs","forks_url":"https://api.github.com/repos/betula/bezierjs/forks","keys_url":"https://api.github.com/repos/betula/bezierjs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/betula/bezierjs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/betula/bezierjs/teams","hooks_url":"https://api.github.com/repos/betula/bezierjs/hooks","issue_events_url":"https://api.github.com/repos/betula/bezierjs/issues/events{/number}","events_url":"https://api.github.com/repos/betula/bezierjs/events","assignees_url":"https://api.github.com/repos/betula/bezierjs/assignees{/user}","branches_url":"https://api.github.com/repos/betula/bezierjs/branches{/branch}","tags_url":"https://api.github.com/repos/betula/bezierjs/tags","blobs_url":"https://api.github.com/repos/betula/bezierjs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/betula/bezierjs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/betula/bezierjs/git/refs{/sha}","trees_url":"https://api.github.com/repos/betula/bezierjs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/betula/bezierjs/statuses/{sha}","languages_url":"https://api.github.com/repos/betula/bezierjs/languages","stargazers_url":"https://api.github.com/repos/betula/bezierjs/stargazers","contributors_url":"https://api.github.com/repos/betula/bezierjs/contributors","subscribers_url":"https://api.github.com/repos/betula/bezierjs/subscribers","subscription_url":"https://api.github.com/repos/betula/bezierjs/subscription","commits_url":"https://api.github.com/repos/betula/bezierjs/commits{/sha}","git_commits_url":"https://api.github.com/repos/betula/bezierjs/git/commits{/sha}","comments_url":"https://api.github.com/repos/betula/bezierjs/comments{/number}","issue_comment_url":"https://api.github.com/repos/betula/bezierjs/issues/comments{/number}","contents_url":"https://api.github.com/repos/betula/bezierjs/contents/{+path}","compare_url":"https://api.github.com/repos/betula/bezierjs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/betula/bezierjs/merges","archive_url":"https://api.github.com/repos/betula/bezierjs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/betula/bezierjs/downloads","issues_url":"https://api.github.com/repos/betula/bezierjs/issues{/number}","pulls_url":"https://api.github.com/repos/betula/bezierjs/pulls{/number}","milestones_url":"https://api.github.com/repos/betula/bezierjs/milestones{/number}","notifications_url":"https://api.github.com/repos/betula/bezierjs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/betula/bezierjs/labels{/name}","releases_url":"https://api.github.com/repos/betula/bezierjs/releases{/id}","created_at":"2015-07-15T00:06:46Z","updated_at":"2015-07-15T00:06:46Z","pushed_at":"2015-07-19T20:30:29Z","git_url":"git://github.com/betula/bezierjs.git","ssh_url":"git@github.com:betula/bezierjs.git","clone_url":"https://github.com/betula/bezierjs.git","svn_url":"https://github.com/betula/bezierjs","homepage":null,"size":233,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"gh-pages"}},"base":{"label":"Pomax:gh-pages","ref":"gh-pages","sha":"cd36a869d489d66736d4f845fd37d989b410aad5","user":{"login":"Pomax","id":177243,"avatar_url":"https://avatars.githubusercontent.com/u/177243?v=3","gravatar_id":"","url":"https://api.github.com/users/Pomax","html_url":"https://github.com/Pomax","followers_url":"https://api.github.com/users/Pomax/followers","following_url":"https://api.github.com/users/Pomax/following{/other_user}","gists_url":"https://api.github.com/users/Pomax/gists{/gist_id}","starred_url":"https://api.github.com/users/Pomax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pomax/subscriptions","organizations_url":"https://api.github.com/users/Pomax/orgs","repos_url":"https://api.github.com/users/Pomax/repos","events_url":"https://api.github.com/users/Pomax/events{/privacy}","received_events_url":"https://api.github.com/users/Pomax/received_events","type":"User","site_admin":false},"repo":{"id":24802869,"name":"bezierjs","full_name":"Pomax/bezierjs","owner":{"login":"Pomax","id":177243,"avatar_url":"https://avatars.githubusercontent.com/u/177243?v=3","gravatar_id":"","url":"https://api.github.com/users/Pomax","html_url":"https://github.com/Pomax","followers_url":"https://api.github.com/users/Pomax/followers","following_url":"https://api.github.com/users/Pomax/following{/other_user}","gists_url":"https://api.github.com/users/Pomax/gists{/gist_id}","starred_url":"https://api.github.com/users/Pomax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pomax/subscriptions","organizations_url":"https://api.github.com/users/Pomax/orgs","repos_url":"https://api.github.com/users/Pomax/repos","events_url":"https://api.github.com/users/Pomax/events{/privacy}","received_events_url":"https://api.github.com/users/Pomax/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Pomax/bezierjs","description":"A nodejs and client-side library for (cubic) Bezier curve work","fork":false,"url":"https://api.github.com/repos/Pomax/bezierjs","forks_url":"https://api.github.com/repos/Pomax/bezierjs/forks","keys_url":"https://api.github.com/repos/Pomax/bezierjs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Pomax/bezierjs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Pomax/bezierjs/teams","hooks_url":"https://api.github.com/repos/Pomax/bezierjs/hooks","issue_events_url":"https://api.github.com/repos/Pomax/bezierjs/issues/events{/number}","events_url":"https://api.github.com/repos/Pomax/bezierjs/events","assignees_url":"https://api.github.com/repos/Pomax/bezierjs/assignees{/user}","branches_url":"https://api.github.com/repos/Pomax/bezierjs/branches{/branch}","tags_url":"https://api.github.com/repos/Pomax/bezierjs/tags","blobs_url":"https://api.github.com/repos/Pomax/bezierjs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Pomax/bezierjs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Pomax/bezierjs/git/refs{/sha}","trees_url":"https://api.github.com/repos/Pomax/bezierjs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Pomax/bezierjs/statuses/{sha}","languages_url":"https://api.github.com/repos/Pomax/bezierjs/languages","stargazers_url":"https://api.github.com/repos/Pomax/bezierjs/stargazers","contributors_url":"https://api.github.com/repos/Pomax/bezierjs/contributors","subscribers_url":"https://api.github.com/repos/Pomax/bezierjs/subscribers","subscription_url":"https://api.github.com/repos/Pomax/bezierjs/subscription","commits_url":"https://api.github.com/repos/Pomax/bezierjs/commits{/sha}","git_commits_url":"https://api.github.com/repos/Pomax/bezierjs/git/commits{/sha}","comments_url":"https://api.github.com/repos/Pomax/bezierjs/comments{/number}","issue_comment_url":"https://api.github.com/repos/Pomax/bezierjs/issues/comments{/number}","contents_url":"https://api.github.com/repos/Pomax/bezierjs/contents/{+path}","compare_url":"https://api.github.com/repos/Pomax/bezierjs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Pomax/bezierjs/merges","archive_url":"https://api.github.com/repos/Pomax/bezierjs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Pomax/bezierjs/downloads","issues_url":"https://api.github.com/repos/Pomax/bezierjs/issues{/number}","pulls_url":"https://api.github.com/repos/Pomax/bezierjs/pulls{/number}","milestones_url":"https://api.github.com/repos/Pomax/bezierjs/milestones{/number}","notifications_url":"https://api.github.com/repos/Pomax/bezierjs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Pomax/bezierjs/labels{/name}","releases_url":"https://api.github.com/repos/Pomax/bezierjs/releases{/id}","created_at":"2014-10-04T22:07:01Z","updated_at":"2015-07-18T01:54:05Z","pushed_at":"2015-07-19T20:30:29Z","git_url":"git://github.com/Pomax/bezierjs.git","ssh_url":"git@github.com:Pomax/bezierjs.git","clone_url":"https://github.com/Pomax/bezierjs.git","svn_url":"https://github.com/Pomax/bezierjs","homepage":null,"size":509,"stargazers_count":46,"watchers_count":46,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":7,"mirror_url":null,"open_issues_count":7,"forks":7,"open_issues":7,"watchers":46,"default_branch":"gh-pages"}},"_links":{"self":{"href":"https://api.github.com/repos/Pomax/bezierjs/pulls/13"},"html":{"href":"https://github.com/Pomax/bezierjs/pull/13"},"issue":{"href":"https://api.github.com/repos/Pomax/bezierjs/issues/13"},"comments":{"href":"https://api.github.com/repos/Pomax/bezierjs/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/Pomax/bezierjs/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/Pomax/bezierjs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Pomax/bezierjs/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/Pomax/bezierjs/statuses/cf3a95a98e1d974c2c515c7d29c761621ed5ff40"}}}}