Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
change regexp used to parse SVG paths to support numbers with exponents e.g. -6e-9.
  • Loading branch information
edurocher committed May 9, 2014
1 parent f748172 commit f4a8237
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gfx/_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ function(kernel, lang, Color, has, win, arr, dom, domConstruct, domGeom){
// a constant regular expression used to split a SVG/VML path into primitive components
// tags:
// private
pathSvgRegExp: /([A-Za-z])|(\d+(\.\d+)?)|(\.\d+)|(-\d+(\.\d+)?)|(-\.\d+)/g,
pathSvgRegExp: /([A-DF-Za-df-z])|([-+]?\d*[.]?\d+(?:[eE][-+]?\d+)?)/g,

equalSources: function(a, b){
// summary:
Expand Down
8 changes: 4 additions & 4 deletions gfx/tests/test_setPath.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
;
// absolute path with cubic bezier
surface
.createPath("M100 100 200 100 200 200C200 250 150 250 100 200S50 100 100 100z")
.createPath("M100 100 200 100 200 200C200 250 150 250 1E2 200S50 1E2 1E2 100z")
.setStroke({color: "black", style:'longdash', width:3})
.setFill("#f80")
.setTransform({dx: 100, dy: -50})
Expand All @@ -40,21 +40,21 @@
;
// relative path with quadratic beziers
surface
.createPath("m100 100 100 0 0 100q0 50-75-25t-25-75z")
.createPath("m100 1E2 1E2 0 0 100q0 50-75-25t-25-75z")
.setStroke({color: "black", style:'longdash', width:3})
.setFill("green")
.setTransform({dx: -50, dy: 150})
;
// absolute path with quadratic bezier
surface
.createPath("M100 100 200 100 200 200Q200 250 125 175T100 100z")
.createPath("M100 1E2 200 1E2 200 200Q200 250 125 175T100 100z")
.setStroke({color: "black", style:'longdash', width:3})
.setFill("blue")
.setTransform({dx: 100, dy: 150})
;
// relative path with horizontal and vertical lines, and quadratic beziers
surface
.createPath("m100 100h100v100q0 50-75-25t-25-75z")
.createPath("m100 100h100v1E2q0 50-75-25t-25-75z")
.setStroke({color: "black", style:'longdash', width:3})
.setFill("#f0f")
.setTransform({dx: 250, dy: 150})
Expand Down

1 comment on commit f4a8237

@edurocher
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to set author, thanks j105rob and Thomas L. Shinnick

Please sign in to comment.