diff --git a/examples/Animated/Extruded.html b/examples/Animated/Extruded.html index 31527714..f37af4d5 100644 --- a/examples/Animated/Extruded.html +++ b/examples/Animated/Extruded.html @@ -14,7 +14,7 @@ } lineGroup.strokeColor = 'red'; - var path1 = project.importJson('["Path",{"pathData":"M63.39307,265.71387c10.8667,6.96631 26.4707,12.26025 43.18896,12.26025c24.79932,0 39.28857,-13.09619 39.28857,-32.04346c0,-17.27588 -10.03125,-27.58545 -35.38721,-37.05908c-30.65088,-11.146 -49.59814,-27.30713 -49.59814,-53.49902c0,-29.25732 24.2417,-50.9917 60.74365,-50.9917c18.94727,0 33.1582,4.4585 41.23877,9.19531L156.18018,133.35986c-5.85156,-3.62256 -18.39014,-8.9165 -35.38721,-8.9165c-25.63525,0 -35.3877,15.3252 -35.3877,28.14258c0,17.5542 11.42432,26.19238 37.33789,36.22314c31.76514,12.26025 47.64795,27.58545 47.64795,55.1709c0,28.979 -21.17676,54.33496 -65.48096,54.33496c-18.11133,0 -37.89502,-5.57275 -47.92578,-12.26025z"}]'); + var path1 = project.importJSON('["Path",{"pathData":"M63.39307,265.71387c10.8667,6.96631 26.4707,12.26025 43.18896,12.26025c24.79932,0 39.28857,-13.09619 39.28857,-32.04346c0,-17.27588 -10.03125,-27.58545 -35.38721,-37.05908c-30.65088,-11.146 -49.59814,-27.30713 -49.59814,-53.49902c0,-29.25732 24.2417,-50.9917 60.74365,-50.9917c18.94727,0 33.1582,4.4585 41.23877,9.19531L156.18018,133.35986c-5.85156,-3.62256 -18.39014,-8.9165 -35.38721,-8.9165c-25.63525,0 -35.3877,15.3252 -35.3877,28.14258c0,17.5542 11.42432,26.19238 37.33789,36.22314c31.76514,12.26025 47.64795,27.58545 47.64795,55.1709c0,28.979 -21.17676,54.33496 -65.48096,54.33496c-18.11133,0 -37.89502,-5.57275 -47.92578,-12.26025z"}]'); path1.position = view.center; var path2 = path1.clone(); diff --git a/examples/JSON/Circle Testing.html b/examples/JSON/Circle Testing.html index dbb60beb..1d4437d6 100644 --- a/examples/JSON/Circle Testing.html +++ b/examples/JSON/Circle Testing.html @@ -20,11 +20,11 @@ var path = new Path.Circle(new Point(50, 50), 25); path.fillColor = 'red'; - window._json = project.exportJson(); + window._json = project.exportJSON(); console.log(window._json); diff --git a/examples/JSON/Compound Path.html b/examples/JSON/Compound Path.html index b126ad2b..3aead575 100644 --- a/examples/JSON/Compound Path.html +++ b/examples/JSON/Compound Path.html @@ -11,11 +11,11 @@ var path2 = new Path.Rectangle([50, 50], [200, 200]); var path3 = new Path.Rectangle([0, 0], [400, 400]); new CompoundPath(path1, path2, path3); - window._json = project.exportJson(); + window._json = project.exportJSON(); console.log(window._json); diff --git a/examples/JSON/Empty Path Testing.html b/examples/JSON/Empty Path Testing.html index dc6924ec..0f0b099c 100644 --- a/examples/JSON/Empty Path Testing.html +++ b/examples/JSON/Empty Path Testing.html @@ -17,11 +17,11 @@ var path3 = new Path(); - window._json = project.exportJson(); + window._json = project.exportJSON(); console.log(window._json); diff --git a/examples/JSON/Gradients.html b/examples/JSON/Gradients.html index f02ecc25..ff74000f 100644 --- a/examples/JSON/Gradients.html +++ b/examples/JSON/Gradients.html @@ -15,11 +15,11 @@ destination: path.bounds.rightCenter } path.strokeColor = 'black'; - window._json = project.exportJson(); + window._json = project.exportJSON(); console.log(window._json); diff --git a/examples/JSON/Group Transform.html b/examples/JSON/Group Transform.html index 4dfee507..2b4e00da 100644 --- a/examples/JSON/Group Transform.html +++ b/examples/JSON/Group Transform.html @@ -14,11 +14,11 @@ group.translate([100, 100]); group.scale(0.5); group.rotate(10); - window._json = project.exportJson(); + window._json = project.exportJSON(); console.log(window._json); diff --git a/examples/JSON/Line Testing.html b/examples/JSON/Line Testing.html index 9beb0971..067a8b48 100644 --- a/examples/JSON/Line Testing.html +++ b/examples/JSON/Line Testing.html @@ -30,11 +30,11 @@ line3.strokeColor = "yellow"; line3.strokeWidth = "5"; - window._json = project.exportJson(); + window._json = project.exportJSON(); console.log(window._json); diff --git a/examples/JSON/Random Path Testing.html b/examples/JSON/Random Path Testing.html index 46e7875f..591e13f7 100644 --- a/examples/JSON/Random Path Testing.html +++ b/examples/JSON/Random Path Testing.html @@ -28,11 +28,11 @@ var path = new Path.Star(center, points, radius1, radius2); path.fillColor = 'black'; - window._json = project.exportJson(); + window._json = project.exportJSON(); console.log(window._json); diff --git a/examples/JSON/Raster.html b/examples/JSON/Raster.html index 6feb6b0d..cc8fb924 100644 --- a/examples/JSON/Raster.html +++ b/examples/JSON/Raster.html @@ -10,14 +10,14 @@ raster.onLoad = function() { raster.position = view.center; raster.rotate(45); - window.importJson(project.exportJson()); + window.importJSON(project.exportJSON()); } diff --git a/examples/JSON/Rect and Attribute Testing.html b/examples/JSON/Rect and Attribute Testing.html index e9ed89f1..e91fa4c1 100644 --- a/examples/JSON/Rect and Attribute Testing.html +++ b/examples/JSON/Rect and Attribute Testing.html @@ -42,11 +42,11 @@ path4.strokeColor= 'yellow'; path4.fillColor='purple'; - window._json = project.exportJson(); + window._json = project.exportJSON(); console.log(window._json); diff --git a/examples/JSON/Rotated Primitives.html b/examples/JSON/Rotated Primitives.html index 60ba4dbe..41c0e38d 100644 --- a/examples/JSON/Rotated Primitives.html +++ b/examples/JSON/Rotated Primitives.html @@ -30,11 +30,11 @@ rect.fillColor = 'yellow'; rect.rotate(-20); - window._json = project.exportJson(); + window._json = project.exportJSON(); console.log(window._json); diff --git a/examples/JSON/Symbols.html b/examples/JSON/Symbols.html index a82bbdba..4b570c29 100644 --- a/examples/JSON/Symbols.html +++ b/examples/JSON/Symbols.html @@ -16,11 +16,11 @@ p1.rotate(45); var p2 = symbol.place([300, 200]); p2.rotate(-30); - window._json = project.exportJson(); + window._json = project.exportJSON(); console.log(window._json); diff --git a/examples/JSON/Text Testing.html b/examples/JSON/Text Testing.html index 2868172f..ed70db26 100644 --- a/examples/JSON/Text Testing.html +++ b/examples/JSON/Text Testing.html @@ -24,11 +24,11 @@ text.shear(.85, .15); text.scale(.85, 2); - window._json = project.exportJson(); + window._json = project.exportJSON(); console.log(window._json); diff --git a/examples/JSON/Transform Test 1.html b/examples/JSON/Transform Test 1.html index 7ebda1d9..3f94fae6 100644 --- a/examples/JSON/Transform Test 1.html +++ b/examples/JSON/Transform Test 1.html @@ -18,11 +18,11 @@ clonedPath.rotate(angle * i, circlePath.bounds.topLeft); }; - window._json = project.exportJson(); + window._json = project.exportJSON(); console.log(window._json); diff --git a/examples/JSON/Transform Test 2.html b/examples/JSON/Transform Test 2.html index e6eb0757..82466b09 100644 --- a/examples/JSON/Transform Test 2.html +++ b/examples/JSON/Transform Test 2.html @@ -16,11 +16,11 @@ copy.rotate(-45); copy.scale(0.5); - window._json = project.exportJson(); + window._json = project.exportJSON(); console.log(window._json); diff --git a/examples/Paperjs.org/Tadpoles.html b/examples/Paperjs.org/Tadpoles.html index 200d2347..129e5b4c 100644 --- a/examples/Paperjs.org/Tadpoles.html +++ b/examples/Paperjs.org/Tadpoles.html @@ -236,7 +236,7 @@ } }); - var heartPath = Project.importJson('["Path",{"pathData":"M514.69629,624.70313c-7.10205,-27.02441 -17.2373,-52.39453 -30.40576,-76.10059c-13.17383,-23.70703 -38.65137,-60.52246 -76.44434,-110.45801c-27.71631,-36.64355 -44.78174,-59.89355 -51.19189,-69.74414c-10.5376,-16.02979 -18.15527,-30.74951 -22.84717,-44.14893c-4.69727,-13.39893 -7.04297,-26.97021 -7.04297,-40.71289c0,-25.42432 8.47119,-46.72559 25.42383,-63.90381c16.94775,-17.17871 37.90527,-25.76758 62.87354,-25.76758c25.19287,0 47.06885,8.93262 65.62158,26.79834c13.96826,13.28662 25.30615,33.10059 34.01318,59.4375c7.55859,-25.88037 18.20898,-45.57666 31.95215,-59.09424c19.00879,-18.32178 40.99707,-27.48535 65.96484,-27.48535c24.7373,0 45.69531,8.53564 62.87305,25.5957c17.17871,17.06592 25.76855,37.39551 25.76855,60.98389c0,20.61377 -5.04102,42.08691 -15.11719,64.41895c-10.08203,22.33203 -29.54687,51.59521 -58.40723,87.78271c-37.56738,47.41211 -64.93457,86.35352 -82.11328,116.8125c-13.51758,24.0498 -23.82422,49.24902 -30.9209,75.58594z","strokeWidth":2,"strokeCap":"round"}]'); + var heartPath = Project.importJSON('["Path",{"pathData":"M514.69629,624.70313c-7.10205,-27.02441 -17.2373,-52.39453 -30.40576,-76.10059c-13.17383,-23.70703 -38.65137,-60.52246 -76.44434,-110.45801c-27.71631,-36.64355 -44.78174,-59.89355 -51.19189,-69.74414c-10.5376,-16.02979 -18.15527,-30.74951 -22.84717,-44.14893c-4.69727,-13.39893 -7.04297,-26.97021 -7.04297,-40.71289c0,-25.42432 8.47119,-46.72559 25.42383,-63.90381c16.94775,-17.17871 37.90527,-25.76758 62.87354,-25.76758c25.19287,0 47.06885,8.93262 65.62158,26.79834c13.96826,13.28662 25.30615,33.10059 34.01318,59.4375c7.55859,-25.88037 18.20898,-45.57666 31.95215,-59.09424c19.00879,-18.32178 40.99707,-27.48535 65.96484,-27.48535c24.7373,0 45.69531,8.53564 62.87305,25.5957c17.17871,17.06592 25.76855,37.39551 25.76855,60.98389c0,20.61377 -5.04102,42.08691 -15.11719,64.41895c-10.08203,22.33203 -29.54687,51.59521 -58.40723,87.78271c-37.56738,47.41211 -64.93457,86.35352 -82.11328,116.8125c-13.51758,24.0498 -23.82422,49.24902 -30.9209,75.58594z","strokeWidth":2,"strokeCap":"round"}]'); var pathLength = heartPath.length; var boids = []; diff --git a/examples/SVG Export/Tiger.html b/examples/SVG Export/Tiger.html index 655fbe5f..951356ed 100644 --- a/examples/SVG Export/Tiger.html +++ b/examples/SVG Export/Tiger.html @@ -8,7 +8,7 @@ diff --git a/examples/SVG Import/Tiger.html b/examples/SVG Import/Tiger.html index e90d5ca7..5577f8c0 100644 --- a/examples/SVG Import/Tiger.html +++ b/examples/SVG Import/Tiger.html @@ -9,7 +9,7 @@ var start = Date.now(); project.importSvg(document.getElementById('svg')); console.log(Date.now() - start); - // console.log(project.exportJson()); + // console.log(project.exportJSON()); diff --git a/src/core/Base.js b/src/core/Base.js index ad561380..aa0ec951 100644 --- a/src/core/Base.js +++ b/src/core/Base.js @@ -55,8 +55,8 @@ this.Base = Base.inject(/** @lends Base# */{ * * @param {Object} [options={ precision: 5 }] */ - exportJson: function(options) { - return Base.exportJson(this, options); + exportJSON: function(options) { + return Base.exportJSON(this, options); }, // To support JSON.stringify: @@ -379,11 +379,11 @@ this.Base = Base.inject(/** @lends Base# */{ return res; }, - exportJson: function(obj, options) { + exportJSON: function(obj, options) { return JSON.stringify(Base.serialize(obj, options)); }, - importJson: function(json) { + importJSON: function(json) { return Base.deserialize( typeof json === 'string' ? JSON.parse(json) : json); }, diff --git a/src/item/Item.js b/src/item/Item.js index ec698ff7..47bdc44f 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -2340,12 +2340,12 @@ var Item = this.Item = Base.extend(Callback, { this.setBounds(newBounds); }, - // DOCS: document exportJson (documented in @private Base) - // DOCS: document importJson + // DOCS: document exportJSON (documented in @private Base) + // DOCS: document importJSON // DOCS: Figure out a way to group these together with importSvg / exportSvg - importJson: function(json) { - return this.addChild(Base.importJson(json)); + importJSON: function(json) { + return this.addChild(Base.importJSON(json)); }, /** diff --git a/src/project/Project.js b/src/project/Project.js index 094cb7bc..56981171 100644 --- a/src/project/Project.js +++ b/src/project/Project.js @@ -266,12 +266,12 @@ var Project = this.Project = PaperScopeItem.extend(/** @lends Project# */{ return null; }, - // DOCS: document exportJson (documented in @private Base) - // DOCS: document importJson + // DOCS: document exportJSON (documented in @private Base) + // DOCS: document importJSON // DOCS: Figure out a way to group these together with importSvg / exportSvg - importJson: function(json) { - return Base.importJson(json); + importJSON: function(json) { + return Base.importJSON(json); }, /** diff --git a/test/tests/JSON.js b/test/tests/JSON.js index d810c5ff..4bce3c0e 100644 --- a/test/tests/JSON.js +++ b/test/tests/JSON.js @@ -12,12 +12,12 @@ module('JSON'); -function testExportImportJson(project) { +function testExportImportJSON(project) { // Use higher precision than in comparissons, for bounds - var json = project.exportJson({ precision: 8 }); + var json = project.exportJSON({ precision: 8 }); var project2 = new Project(); project2.clear(); - project2.importJson(json); + project2.importJSON(json); compareProjects(project2, project); } @@ -27,7 +27,7 @@ test('Circles', function() { var rectangle = new Rectangle(topLeft, size); var path = new Path.Ellipse(rectangle); path.fillColor = 'black'; - console.log('JSON', path.exportJson()); + console.log('JSON', path.exportJSON()); var topLeft = new Point(5, 400); var size = new Size(100, 50); @@ -38,7 +38,7 @@ test('Circles', function() { var path = new Path.Circle(new Point(50, 50), 25); path.fillColor = 'red'; - testExportImportJson(paper.project); + testExportImportJSON(paper.project); }); test('CompoundPath', function() { @@ -48,12 +48,12 @@ test('CompoundPath', function() { var path3 = new Path.Rectangle([0, 0], [400, 400]); new CompoundPath(path1, path2, path3); - testExportImportJson(paper.project); + testExportImportJSON(paper.project); }); test('Empty Path', function() { new Path(); - testExportImportJson(paper.project); + testExportImportJSON(paper.project); }); test('Gradients', function() { @@ -64,7 +64,7 @@ test('Gradients', function() { var gradientColor = new Color(gradient, from, to); path.fillColor = gradientColor; path.strokeColor = 'black'; - testExportImportJson(paper.project); + testExportImportJSON(paper.project); }); test('Group transform', function() { @@ -76,7 +76,7 @@ test('Group transform', function() { group.translate([100, 100]); group.scale(0.5); group.rotate(10); - testExportImportJson(paper.project); + testExportImportJSON(paper.project); }); test('Rectangle testing', function() { @@ -114,7 +114,7 @@ test('Rectangle testing', function() { var path4 = new Path.Rectangle(rectangle4, cornerSize4); path4.strokeColor= 'yellow'; path4.fillColor='purple'; - testExportImportJson(paper.project); + testExportImportJSON(paper.project); }); test('Symbols', function() { @@ -129,7 +129,7 @@ test('Symbols', function() { var p2 = symbol.place([300, 200]); p2.rotate(-30); - testExportImportJson(paper.project); + testExportImportJSON(paper.project); }); test('PointText testing', function() { @@ -145,7 +145,7 @@ test('PointText testing', function() { text.rotate(45); text.shear(0.85, 0.15); text.scale(0.85, 2); - testExportImportJson(paper.project); + testExportImportJSON(paper.project); }); test('transform test 1', function() { @@ -160,7 +160,7 @@ test('transform test 1', function() { var clonedPath = circlePath.clone(); clonedPath.rotate(angle * i, circlePath.bounds.topLeft); }; - testExportImportJson(paper.project); + testExportImportJSON(paper.project); }); test('transform test 2', function() { @@ -173,14 +173,14 @@ test('transform test 2', function() { copy.strokeColor = 'red'; copy.rotate(-45); copy.scale(0.5); - testExportImportJson(paper.project); + testExportImportJSON(paper.project); }); test('Item#name', function() { var path = new Path({ name: 'dave' }); - testExportImportJson(paper.project); + testExportImportJSON(paper.project); }); test('Item#data', function() { @@ -200,6 +200,6 @@ test('Item#data', function() { } } }; - testExportImportJson(paper.project); + testExportImportJSON(paper.project); });