Skip to content
This repository was archived by the owner on Jan 4, 2021. It is now read-only.

Commit d263c91

Browse files
author
Francois-Xavier Gentilhomme
committed
Revert "[DEV] Fix var"
This reverts commit ee781c2. Revert "[DEV] InkRanges workaround in shape rendering" This reverts commit 2117fd4.
1 parent 1f00e3f commit d263c91

File tree

5 files changed

+36
-70
lines changed

5 files changed

+36
-70
lines changed

dist/myscript.js

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5274,14 +5274,9 @@ MyScript = {
52745274
*/
52755275
function ShapeDocument(obj) {
52765276
this.segments = [];
5277-
this.inkRanges = [];
52785277
if (obj) {
52795278
for (var i in obj.segments) {
52805279
this.segments.push(new scope.ShapeSegment(obj.segments[i]));
5281-
for(var j in this.segments[i].getInkRanges()){
5282-
this.inkRanges.push(this.segments[i].getInkRanges()[j]);
5283-
}
5284-
52855280
}
52865281
}
52875282
}
@@ -5303,7 +5298,11 @@ MyScript = {
53035298
* @returns {ShapeInkRange[]}
53045299
*/
53055300
ShapeDocument.prototype.getInkRanges = function () {
5306-
return this.inkRanges;
5301+
var inkRanges = [];
5302+
for (var i in this.segments) {
5303+
inkRanges = inkRanges.concat(this.segments[i].getInkRanges());
5304+
}
5305+
return inkRanges;
53075306
};
53085307

53095308
/**
@@ -12257,7 +12256,6 @@ MyScript = {
1225712256
*/
1225812257
function ShapeRenderer(context) {
1225912258
scope.AbstractRenderer.call(this, context);
12260-
this.inkRanges = [];
1226112259
}
1226212260

1226312261
/**
@@ -12281,7 +12279,16 @@ MyScript = {
1228112279
this.clear();
1228212280
if (document && (document instanceof scope.ShapeDocument)) {
1228312281
this.drawShapes(components, document.getSegments());
12284-
this.drawShapesNotYetRecognized(components, document.getInkRanges());
12282+
var lastComponents = [];
12283+
var processedComponents = _extractComponents(components, document.getInkRanges());
12284+
12285+
for (var i in components) {
12286+
var component = components[i];
12287+
if (processedComponents.indexOf(component) !== -1) {
12288+
lastComponents.push(component);
12289+
}
12290+
}
12291+
this.drawComponents(lastComponents);
1228512292
} else {
1228612293
this.drawComponents(components);
1228712294
}
@@ -12319,30 +12326,6 @@ MyScript = {
1231912326
}
1232012327
};
1232112328

12322-
ShapeRenderer.prototype.drawShapesNotYetRecognized = function (components, inkRanges){
12323-
for (var k in inkRanges) {
12324-
this.inkRanges.push(inkRanges[k]);
12325-
}
12326-
function contains(a, obj) {
12327-
var i = a.length;
12328-
while (i--) {
12329-
if (JSON.stringify(a[i]) === JSON.stringify(obj)) {
12330-
return true;
12331-
}
12332-
}
12333-
return false;
12334-
}
12335-
12336-
var lastComponents = [];
12337-
for (var i in components) {
12338-
var component = components[i];
12339-
if (!contains(_extractComponents(components, this.inkRanges), component)) {
12340-
lastComponents.push(component);
12341-
}
12342-
}
12343-
this.drawComponents(lastComponents);
12344-
};
12345-
1234612329
/**
1234712330
* Draw shape segment
1234812331
*

dist/myscript.min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/myscript.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/output/shape/shapeDocument.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,9 @@
1010
*/
1111
function ShapeDocument(obj) {
1212
this.segments = [];
13-
this.inkRanges = [];
1413
if (obj) {
1514
for (var i in obj.segments) {
1615
this.segments.push(new scope.ShapeSegment(obj.segments[i]));
17-
for(var j in this.segments[i].getInkRanges()){
18-
this.inkRanges.push(this.segments[i].getInkRanges()[j]);
19-
}
20-
2116
}
2217
}
2318
}
@@ -39,7 +34,11 @@
3934
* @returns {ShapeInkRange[]}
4035
*/
4136
ShapeDocument.prototype.getInkRanges = function () {
42-
return this.inkRanges;
37+
var inkRanges = [];
38+
for (var i in this.segments) {
39+
inkRanges = inkRanges.concat(this.segments[i].getInkRanges());
40+
}
41+
return inkRanges;
4342
};
4443

4544
/**

src/rendering/shapeRenderer.js

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
*/
1212
function ShapeRenderer(context) {
1313
scope.AbstractRenderer.call(this, context);
14-
this.inkRanges = [];
1514
}
1615

1716
/**
@@ -35,7 +34,16 @@
3534
this.clear();
3635
if (document && (document instanceof scope.ShapeDocument)) {
3736
this.drawShapes(components, document.getSegments());
38-
this.drawShapesNotYetRecognized(components, document.getInkRanges());
37+
var lastComponents = [];
38+
var processedComponents = _extractComponents(components, document.getInkRanges());
39+
40+
for (var i in components) {
41+
var component = components[i];
42+
if (processedComponents.indexOf(component) !== -1) {
43+
lastComponents.push(component);
44+
}
45+
}
46+
this.drawComponents(lastComponents);
3947
} else {
4048
this.drawComponents(components);
4149
}
@@ -73,30 +81,6 @@
7381
}
7482
};
7583

76-
ShapeRenderer.prototype.drawShapesNotYetRecognized = function (components, inkRanges){
77-
for (var k in inkRanges) {
78-
this.inkRanges.push(inkRanges[k]);
79-
}
80-
function contains(a, obj) {
81-
var i = a.length;
82-
while (i--) {
83-
if (JSON.stringify(a[i]) === JSON.stringify(obj)) {
84-
return true;
85-
}
86-
}
87-
return false;
88-
}
89-
90-
var lastComponents = [];
91-
for (var i in components) {
92-
var component = components[i];
93-
if (!contains(_extractComponents(components, this.inkRanges), component)) {
94-
lastComponents.push(component);
95-
}
96-
}
97-
this.drawComponents(lastComponents);
98-
};
99-
10084
/**
10185
* Draw shape segment
10286
*

0 commit comments

Comments
 (0)