Skip to content

Commit 92fcf78

Browse files
committed
fix zigzag sorting
1 parent e1ef4ec commit 92fcf78

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/braillegeometry/BrailleToGeometry.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ class BrailleToGeometry
9191
let geom = [];
9292

9393
const sort_predicate_y = (a,b) => {
94-
if (a.y === b.y) return (a.x - b.x);
94+
if (a.y === b.y)
95+
return ((a.x - b.x) * dir);
9596
return (a.y - b.y);
9697
}
9798
if (inputgeom == null)
@@ -105,6 +106,7 @@ class BrailleToGeometry
105106
e = 0;
106107
while (e < geom.length)
107108
{
109+
// get the last dot with same y position
108110
while ((geom[s].y === geom[e].y) )
109111
{
110112
e++;
@@ -115,6 +117,8 @@ class BrailleToGeometry
115117
}
116118

117119
//if (e - s >= 0)
120+
// all dots on same position are a single line
121+
// sort this lines in zigzag order (one from right to left, the next from left to right ...)
118122
{
119123
for (i = s; i < e; i++)
120124
{

0 commit comments

Comments
 (0)