2012-10-26 21:03:50 +00:00
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<div style="height:0">
|
|
|
|
|
2013-02-22 21:50:07 +00:00
|
|
|
<div id="cubicOp25i">
|
|
|
|
debugShowActiveSpans id=1 (0,1 2,4 5,0 3,2) t=0.466666667 (2.84355545,1.9478519) tEnd=0.605057566 other=2 otherT=0.0521481481 otherIndex=1 windSum=-1 windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=2 (3,2 0,1) t=0.0521481481 (2.84355545,1.9478519) tEnd=0.377811276 other=1 otherT=0.466666667 otherIndex=2 windSum=1 windValue=1 oppValue=0
|
|
|
|
</div>
|
|
|
|
|
2013-02-17 01:41:25 +00:00
|
|
|
<div id="cubicOp19i">
|
|
|
|
debugShowActiveSpans id=3 (1,2 2,6 2,0 1,0) t=0 (1,2) tEnd=0.578464835 other=4 otherT=1 otherIndex=2 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=3 (1,2 2,6 2,0 1,0) t=0.578464835 (1.73152983,2) tEnd=0.692069746 other=2 otherT=0.711411698 otherIndex=1 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=3 (1,2 2,6 2,0 1,0) t=0.692069746 (1.63932765,1.25154662) tEnd=1 other=1 otherT=0.522705723 otherIndex=2 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=4 (1,0 1,2) t=0 (1,0) tEnd=0.637627564 other=3 otherT=1 otherIndex=4 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=4 (1,0 1,2) t=0.637627564 (1,1.27525508) tEnd=1 other=1 otherT=0.40824829 otherIndex=1 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=1 (0,2 0,0.5 6,2) t=0 (0,2) tEnd=0.40824829 other=2 otherT=1 otherIndex=4 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=1 (0,2 0,0.5 6,2) t=0.40824829 (1,1.27525508) tEnd=0.522705723 other=4 otherT=0.637627564 otherIndex=1 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=1 (0,2 0,0.5 6,2) t=0.522705723 (1.63932765,1.25154662) tEnd=1 other=3 otherT=0.692069746 otherIndex=3 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=2 (6,2 0,2) t=0 (6,2) tEnd=0.711411698 other=1 otherT=1 otherIndex=3 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=2 (6,2 0,2) t=0.711411698 (1.73152983,2) tEnd=0.833333333 other=3 otherT=0.578464835 otherIndex=2 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=2 (6,2 0,2) t=0.833333333 (1,2) tEnd=1 other=3 otherT=0 otherIndex=1 windSum=? windValue=1 oppValue=0
|
2012-10-31 19:00:20 +00:00
|
|
|
</div>
|
|
|
|
|
2013-02-22 21:50:07 +00:00
|
|
|
<div id="cubicOp28u">
|
|
|
|
debugShowActiveSpans id=3 (0,6 2,3 1,0 4,1) t=0 (0,6) tEnd=0.473902244 other=4 otherT=1 otherIndex=3 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=3 (0,6 2,3 1,0 4,1) t=0.473902244 (1.5671773,2.16060209) tEnd=0.57224743 other=1 otherT=0.287206281 otherIndex=1 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=3 (0,6 2,3 1,0 4,1) t=0.57224743 (1.79802597,1.59934199) tEnd=1 other=2 otherT=0.400657994 otherIndex=2 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=4 (4,1 0,6) t=0 (4,1) tEnd=0.13678207 other=3 otherT=1 otherIndex=3 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=4 (4,1 0,6) t=0.13678207 (3.4528718,1.68391037) tEnd=0.145041093 other=1 otherT=0.583645693 otherIndex=3 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=4 (4,1 0,6) t=0.145041093 (3.41983557,1.72520542) tEnd=1 other=1 otherT=0.945703361 otherIndex=6 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=1 (0,1 1,4 6,0 3,2) t=0 (0,1) tEnd=0.287206281 other=2 otherT=1 otherIndex=3 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=1 (0,1 1,4 6,0 3,2) t=0.287206281 (1.5671773,2.16060209) tEnd=0.470588235 other=3 otherT=0.473902244 otherIndex=1 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=1 (0,1 1,4 6,0 3,2) t=0.470588235 (2.81864452,1.93954813) tEnd=0.583645693 other=2 otherT=0.0604518624 otherIndex=1 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=1 (0,1 1,4 6,0 3,2) t=0.583645693 (3.4528718,1.68391037) tEnd=0.614942976 other=4 otherT=0.13678207 otherIndex=1 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=1 (0,1 1,4 6,0 3,2) t=0.614942976 (3.59216309,1.61630249) tEnd=0.916307024 other=1 otherT=0.916307024 otherIndex=5 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=1 (0,1 1,4 6,0 3,2) t=0.916307024 (3.59216309,1.61630249) tEnd=0.945703361 other=1 otherT=0.614942976 otherIndex=4 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=1 (0,1 1,4 6,0 3,2) t=0.945703361 (3.41983557,1.72520542) tEnd=1 other=4 otherT=0.145041093 otherIndex=2 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=2 (3,2 0,1) t=0 (3,2) tEnd=0.0604518624 other=1 otherT=1 otherIndex=7 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=2 (3,2 0,1) t=0.0604518624 (2.81864452,1.93954813) tEnd=0.400657994 other=1 otherT=0.470588235 otherIndex=2 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=2 (3,2 0,1) t=0.400657994 (1.79802597,1.59934199) tEnd=1 other=3 otherT=0.57224743 otherIndex=2 windSum=? windValue=1 oppValue=0
|
|
|
|
</div>
|
|
|
|
|
2013-02-26 15:56:05 +00:00
|
|
|
<div id="cubicOp31d">
|
|
|
|
debugShowActiveSpans id=1 (0,2 0,3 2,1 4,0) t=0 (0,2) tEnd=0.5 other=2 otherT=1 otherIndex=3 windSum=1 windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=1 (0,2 0,3 2,1 4,0) t=0.5 (1.25,1.75) tEnd=1 other=4 otherT=0.875 otherIndex=2 windSum=1 windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=2 (4,0 0,2) t=0 (4,0) tEnd=0.5 other=1 otherT=1 otherIndex=3 windSum=1 windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=2 (4,0 0,2) t=0.586298186 (1.65480721,1.17259634) tEnd=1 other=3 otherT=0.622399169 otherIndex=3 windSum=1 windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=3 (1,2 0,4 2,0 3,0) t=0 (1,2) tEnd=0.5 other=4 otherT=1 otherIndex=4 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=3 (1,2 0,4 2,0 3,0) t=0.500000008 (1.25,1.75) tEnd=0.622399169 other=1 otherT=0.5 otherIndex=1 windSum=-1 windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=4 (3,0 1,2) t=0.5 (2,1) tEnd=0.875 other=2 otherT=0.5 otherIndex=1 windSum=-1 windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=4 (3,0 1,2) t=0.875 (1.25,1.75) tEnd=1 other=1 otherT=0.5 otherIndex=2 windSum=? windValue=1 oppValue=0
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="cubicOp31da">
|
|
|
|
debugShowActiveSpans id=1 (0,2 0,3 2,1 4,0) t=0 (0,2) tEnd=0.5 other=2 otherT=1 otherIndex=3 windSum=1 windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=1 (0,2 0,3 2,1 4,0) t=0.5 (1.25,1.75) tEnd=1 other=4 otherT=0.875 otherIndex=2 windSum=1 windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=3 (1,2 0,4 2,0 3,0) t=0 (1,2) tEnd=0.5 other=4 otherT=1 otherIndex=4 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=3 (1,2 0,4 2,0 3,0) t=0.500000008 (1.25,1.75) tEnd=0.622399169 other=1 otherT=0.5 otherIndex=1 windSum=-1 windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=4 (3,0 1,2) t=0.5 (2,1) tEnd=0.875 other=2 otherT=0.5 otherIndex=1 windSum=-1 windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=4 (3,0 1,2) t=0.875 (1.25,1.75) tEnd=1 other=1 otherT=0.5 otherIndex=2 windSum=? windValue=1 oppValue=0
|
|
|
|
</div>
|
|
|
|
|
2013-02-28 16:12:39 +00:00
|
|
|
<div id="cubicOp35d">
|
|
|
|
SimplifyNew_Test [cubicOp35d]
|
|
|
|
debugShowCubicIntersection no self intersect {{0,1}, {1,5}, {2,1}, {4,0}}
|
|
|
|
debugShowCubicLineIntersection wtTs[0]=0 {{0,1}, {1,5}, {2,1}, {4,0}} {{0,1}} wtTs[1]=1 {{4,0}} wnTs[0]=1 {{4,0}, {0,1}} wnTs[1]=0
|
|
|
|
debugShowCubicIntersection wtTs[0]=0.210357794 {{0,1}, {1,5}, {2,1}, {4,0}} {{0.64038179843233178,2.5646764769093426}} wtTs[1]=0.788675135 {{2.8565880156561105,0.93208711896642604}} wnTs[0]=0.223476 {{1,2}, {0,4}, {1,0}, {5,1}} wnTs[1]=0.788675135
|
|
|
|
debugShowCubicLineIntersection wtTs[0]=0.646900486 {{0,1}, {1,5}, {2,1}, {4,0}} {{2.2114165293341985,1.6971458676664504}} wnTs[0]=0.697146 {{5,1}, {1,2}}
|
|
|
|
debugShowCubicLineIntersection no intersect {{1,2}, {0,4}, {1,0}, {5,1}} {{4,0}, {0,1}}
|
|
|
|
debugShowLineIntersection no intersect {{4,0}, {0,1}} {{5,1}, {1,2}}
|
|
|
|
debugShowCubicIntersection wtTs[0]=0.002763735 {{1,2}, {0,4}, {1,0}, {5,1}} {{0.9917546455060533,2.0164451540317003}} wtTs[1]=0.461521979
|
|
|
|
debugShowCubicLineIntersection wtTs[0]=0 {{1,2}, {0,4}, {1,0}, {5,1}} {{1,2}} wtTs[1]=0.466666667 {{1.0082962962962965,1.9979259259259259}} wtTs[2]=1 {{5,1}} wnTs[0]=1 {{5,1}, {1,2}} wnTs[1]=0.997925926 wnTs[2]=0
|
|
|
|
debugShowActiveSpans id=1 (0,1 1,5 2,1 4,0) t=0 (0,1) tEnd=0.210357794 other=2 otherT=1 otherIndex=1 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=1 (0,1 1,5 2,1 4,0) t=0.210357794 (0.640381813,2.56467652) tEnd=0.646900486 other=3 otherT=0.223476406 otherIndex=2 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=1 (0,1 1,5 2,1 4,0) t=0.646900486 (2.21141648,1.69714582) tEnd=0.788675135 other=4 otherT=0.697145868 otherIndex=1 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=1 (0,1 1,5 2,1 4,0) t=0.788675135 (2.85658813,0.932087123) tEnd=1 other=3 otherT=0.788675135 otherIndex=5 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=2 (4,0 0,1) t=0 (4,0) tEnd=1 other=1 otherT=1 otherIndex=4 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=3 (1,2 0,4 1,0 5,1) t=0 (1,2) tEnd=0.002763735 other=4 otherT=1 otherIndex=3 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=3 (1,2 0,4 1,0 5,1) t=0.002763735 (0.991754651,2.01644516) tEnd=0.223476406 other=3 otherT=0.461521979 otherIndex=3 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=3 (1,2 0,4 1,0 5,1) t=0.223476406 (0.640381813,2.56467652) tEnd=0.461521979 other=1 otherT=0.210357794 otherIndex=1 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=3 (1,2 0,4 1,0 5,1) t=0.461521979 (0.991754651,2.01644516) tEnd=0.466666667 other=3 otherT=0.002763735 otherIndex=1 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=3 (1,2 0,4 1,0 5,1) t=0.466666667 (1.00829625,1.99792588) tEnd=0.788675135 other=4 otherT=0.997925926 otherIndex=2 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=3 (1,2 0,4 1,0 5,1) t=0.788675135 (2.85658813,0.932087123) tEnd=1 other=1 otherT=0.788675135 otherIndex=3 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=4 (5,1 1,2) t=0 (5,1) tEnd=0.697145868 other=3 otherT=1 otherIndex=6 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=4 (5,1 1,2) t=0.697145868 (2.21141648,1.69714582) tEnd=0.997925926 other=1 otherT=0.646900486 otherIndex=2 windSum=? windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=4 (5,1 1,2) t=0.997925926 (1.00829625,1.99792588) tEnd=1 other=3 otherT=0.466666667 otherIndex=4 windSum=? windValue=1 oppValue=0
|
|
|
|
findTop debugShowSort contourWinding=0 oppContourWinding=0 sign=-1
|
|
|
|
debugShowSort [0] id=2 line start=0 (4,0) end=1 (0,1) sign=-1 windValue=1 windSum=? 0->1 (max=1) done=0 tiny=0 opp=0
|
|
|
|
debugShowSort [1] id=1 cubic start=4 (4,0) end=3 (2.85658813,0.932087123) sign=1 windValue=1 windSum=? 1->0 (max=1) done=0 tiny=0 opp=0
|
|
|
|
markWinding id=2 (4,0 0,1) t=0 [0] (4,0) newWindSum=1 newOppSum=0 oppSum=? windSum=? windValue=1
|
|
|
|
markWinding id=1 (0,1 1,5 2,1 4,0) t=0.788675135 [3] (2.85658813,0.932087123) newWindSum=1 newOppSum=0 oppSum=? windSum=? windValue=1
|
|
|
|
markWinding id=2 (4,0 0,1) t=0 [0] (4,0) newWindSum=1 newOppSum=0 oppSum=0 windSum=1 windValue=1
|
|
|
|
markWinding id=1 (0,1 1,5 2,1 4,0) t=0 [0] (0,1) newWindSum=1 newOppSum=0 oppSum=? windSum=? windValue=1
|
|
|
|
activeOp op=diff miFrom=1 miTo=0 suFrom=0 suTo=0 result=1
|
|
|
|
findNextOp simple
|
|
|
|
markDoneBinary id=2 (4,0 0,1) t=0 [0] (4,0) newWindSum=1 newOppSum=0 oppSum=0 windSum=1 windValue=1
|
|
|
|
bridgeOp current id=2 from=(0,1) to=(4,0)
|
|
|
|
findNextOp debugShowSort contourWinding=0 oppContourWinding=0 sign=-1
|
|
|
|
debugShowSort [1] id=1 cubic start=3 (2.85658813,0.932087123) end=4 (4,0) sign=-1 windValue=1 windSum=1 0->1 (max=1) done=0 tiny=0 opp=0
|
|
|
|
debugShowSort [2] id=3 cubic start=5 (2.85658813,0.932087123) end=4 (1.00829625,1.99792588) sign=1 windValue=1 windSum=? 0->-1 (max=-1) done=0 tiny=0 opp=1
|
|
|
|
debugShowSort [3] id=1 cubic start=3 (2.85658813,0.932087123) end=2 (2.21141648,1.69714582) sign=1 windValue=1 windSum=? 1->0 (max=1) done=0 tiny=0 opp=0
|
|
|
|
debugShowSort [0] id=3 cubic start=5 (2.85658813,0.932087123) end=6 (5,1) sign=-1 windValue=1 windSum=? -1->0 (max=-1) done=0 tiny=0 opp=1
|
|
|
|
findNextOp firstIndex=[1] sign=-1
|
|
|
|
activeOp op=diff miFrom=1 miTo=1 suFrom=0 suTo=1 result=1
|
|
|
|
markWinding id=3 (1,2 0,4 1,0 5,1) t=0.466666667 [4] (1.00829625,1.99792588) newWindSum=-1 newOppSum=1 oppSum=? windSum=? windValue=1
|
|
|
|
findNextOp chase.append id=3
|
|
|
|
activeOp op=diff miFrom=1 miTo=0 suFrom=1 suTo=1 result=0
|
|
|
|
markDoneBinary id=1 (0,1 1,5 2,1 4,0) t=0.646900486 [2] (2.21141648,1.69714582) newWindSum=1 newOppSum=-1 oppSum=? windSum=? windValue=1
|
|
|
|
findNextOp chase.append id=1
|
|
|
|
activeOp op=diff miFrom=0 miTo=0 suFrom=1 suTo=0 result=0
|
|
|
|
markDoneBinary id=3 (1,2 0,4 1,0 5,1) t=0.788675135 [5] (2.85658813,0.932087123) newWindSum=-1 newOppSum=0 oppSum=? windSum=? windValue=1
|
|
|
|
markDoneBinary id=4 (5,1 1,2) t=0 [0] (5,1) newWindSum=-1 newOppSum=0 oppSum=? windSum=? windValue=1
|
|
|
|
findNextOp chase.append id=4
|
|
|
|
markDoneBinary id=1 (0,1 1,5 2,1 4,0) t=0.788675135 [3] (2.85658813,0.932087123) newWindSum=1 newOppSum=0 oppSum=0 windSum=1 windValue=1
|
|
|
|
findNextOp from:[1] to:[3] start=5 end=4
|
|
|
|
bridgeOp current id=1 from=(4,0) to=(2.85658813,0.932087123)
|
|
|
|
path.moveTo(0,1);
|
|
|
|
path.lineTo(4,0);
|
|
|
|
path.cubicTo(3.57735038,0.211324871, 3.1993587,0.556624353, 2.85658813,0.932087123);
|
|
|
|
findNextOp debugShowSort contourWinding=-1 oppContourWinding=1 sign=-1
|
|
|
|
debugShowSort [1] id=3 cubic start=4 (1.00829625,1.99792588) end=5 (2.85658813,0.932087123) sign=-1 windValue=1 windSum=-1 -1->0 (max=-1) done=0 tiny=0 opp=0
|
|
|
|
debugShowSort [2] id=4 line start=2 (1.00829625,1.99792588) end=3 (1,2) sign=-1 windValue=1 windSum=? 0->1 (max=1) done=0 tiny=0 opp=0
|
|
|
|
debugShowSort [3] id=3 cubic start=4 (1.00829625,1.99792588) end=3 (0.991754651,2.01644516) sign=1 windValue=1 windSum=? 1->0 (max=1) done=0 tiny=0 opp=0
|
|
|
|
debugShowSort [0] id=4 line start=2 (1.00829625,1.99792588) end=1 (2.21141648,1.69714582) sign=1 windValue=1 windSum=? 0->-1 (max=-1) done=0 tiny=0 opp=0
|
|
|
|
findNextOp firstIndex=[1] sign=-1
|
|
|
|
activeOp op=diff miFrom=1 miTo=1 suFrom=0 suTo=1 result=1
|
|
|
|
markWinding id=4 (5,1 1,2) t=0.997925926 [2] (1.00829625,1.99792588) newWindSum=1 newOppSum=1 oppSum=? windSum=? windValue=1
|
|
|
|
markWinding id=3 (1,2 0,4 1,0 5,1) t=0 [0] (1,2) newWindSum=1 newOppSum=1 oppSum=? windSum=? windValue=1
|
|
|
|
findNextOp chase.append id=3
|
|
|
|
activeOp op=diff miFrom=1 miTo=1 suFrom=1 suTo=0 result=1
|
|
|
|
markWinding id=3 (1,2 0,4 1,0 5,1) t=0.461521979 [3] (0.991754651,2.01644516) newWindSum=1 newOppSum=1 oppSum=? windSum=? windValue=1
|
|
|
|
findNextOp chase.append id=3
|
|
|
|
activeOp op=diff miFrom=1 miTo=1 suFrom=0 suTo=1 result=1
|
|
|
|
markWinding id=4 (5,1 1,2) t=0.697145868 [1] (2.21141648,1.69714582) newWindSum=-1 newOppSum=1 oppSum=? windSum=? windValue=1
|
|
|
|
findNextOp chase.append id=4
|
|
|
|
markDoneBinary id=3 (1,2 0,4 1,0 5,1) t=0.466666667 [4] (1.00829625,1.99792588) newWindSum=-1 newOppSum=1 oppSum=1 windSum=-1 windValue=1
|
|
|
|
findNextOp from:[3] to:[4] start=2 end=3
|
|
|
|
bridgeOp current id=3 from=(2.85658813,0.932087123) to=(1.00829625,1.99792588)
|
|
|
|
path.cubicTo(1.96246409,1.13237906, 1.35749662,1.61008465, 1.00829625,1.99792588);
|
|
|
|
findNextOp simple
|
|
|
|
markDoneBinary id=4 (5,1 1,2) t=0.997925926 [2] (1.00829625,1.99792588) newWindSum=1 newOppSum=1 oppSum=1 windSum=1 windValue=1
|
|
|
|
bridgeOp current id=4 from=(1.00829625,1.99792588) to=(1,2)
|
|
|
|
Program received signal: “EXC_BAD_ACCESS”.
|
|
|
|
findNextOp debugShowSort contourWinding=1 oppContourWinding=1 sign=1
|
|
|
|
debugShowSort [1] id=3 cubic start=1 (0.991754651,2.01644516) end=0 (1,2) sign=1 windValue=1 windSum=1 1->0 (max=1) done=0 tiny=0 opp=0
|
|
|
|
debugShowSort [2] id=3 cubic start=3 (0.991754651,2.01644516) end=2 (0.640381813,2.56467652) sign=1 windValue=1 windSum=? 0->-1 (max=-1) done=0 tiny=0 opp=0
|
|
|
|
debugShowSort [3] id=3 cubic start=1 (0.991754651,2.01644516) end=2 (0.640381813,2.56467652) sign=-1 windValue=1 windSum=? -1->0 (max=-1) done=0 tiny=0 opp=0
|
|
|
|
debugShowSort [0] id=3 cubic start=3 (0.991754651,2.01644516) end=4 (1.00829625,1.99792588) sign=-1 windValue=1 windSum=1 0->1 (max=1) done=0 tiny=0 opp=0
|
|
|
|
findNextOp firstIndex=[1] sign=1
|
|
|
|
activeOp op=diff miFrom=1 miTo=1 suFrom=0 suTo=1 result=1
|
|
|
|
markWinding id=3 (1,2 0,4 1,0 5,1) t=0.223476406 [2] (0.640381813,2.56467652) newWindSum=-1 newOppSum=1 oppSum=? windSum=? windValue=1
|
|
|
|
findNextOp chase.append id=3
|
|
|
|
activeOp op=diff miFrom=1 miTo=1 suFrom=1 suTo=0 result=1
|
|
|
|
markWinding id=3 (1,2 0,4 1,0 5,1) t=0.002763735 [1] (0.991754651,2.01644516) newWindSum=-1 newOppSum=1 oppSum=? windSum=? windValue=1
|
|
|
|
findNextOp chase.append id=3
|
|
|
|
activeOp op=diff miFrom=1 miTo=1 suFrom=0 suTo=1 result=1
|
|
|
|
markDoneBinary id=3 (1,2 0,4 1,0 5,1) t=0 [0] (1,2) newWindSum=1 newOppSum=1 oppSum=1 windSum=1 windValue=1
|
|
|
|
findNextOp from:[3] to:[3] start=3 end=2
|
|
|
|
bridgeOp current id=3 from=(1,2) to=(0.991754651,2.01644516)
|
|
|
|
path.lineTo(1,2);
|
|
|
|
path.cubicTo(0.997236252,2.0055275, 0.994487822,2.01100922, 0.991754651,2.01644516);
|
|
|
|
findNextOp debugShowSort contourWinding=-1 oppContourWinding=1 sign=-1
|
|
|
|
debugShowSort [0] id=3 cubic start=2 (0.640381813,2.56467652) end=3 (0.991754651,2.01644516) sign=-1 windValue=1 windSum=-1 -1->0 (max=-1) done=0 tiny=0 opp=0
|
|
|
|
debugShowSort [1] id=1 cubic start=1 (0.640381813,2.56467652) end=0 (0,1) sign=1 windValue=1 windSum=1 1->0 (max=1) done=0 tiny=0 opp=1
|
|
|
|
debugShowSort [2] id=3 cubic start=2 (0.640381813,2.56467652) end=1 (0.991754651,2.01644516) sign=1 windValue=1 windSum=-1 0->-1 (max=-1) done=0 tiny=0 opp=0
|
|
|
|
debugShowSort [3] id=1 cubic start=1 (0.640381813,2.56467652) end=2 (2.21141648,1.69714582) sign=-1 windValue=1 windSum=? 0->1 (max=1) done=0 tiny=0 opp=1
|
|
|
|
findNextOp firstIndex=[0] sign=-1
|
|
|
|
activeOp op=diff miFrom=1 miTo=0 suFrom=0 suTo=0 result=1
|
|
|
|
activeOp op=diff miFrom=0 miTo=0 suFrom=0 suTo=1 result=0
|
|
|
|
activeOp op=diff miFrom=0 miTo=1 suFrom=1 suTo=1 result=0
|
|
|
|
markDoneBinary id=1 (0,1 1,5 2,1 4,0) t=0.210357794 [1] (0.640381813,2.56467652) newWindSum=1 newOppSum=-1 oppSum=? windSum=? windValue=1
|
|
|
|
findNextOp chase.append id=1
|
|
|
|
markDoneBinary id=3 (1,2 0,4 1,0 5,1) t=0.223476406 [2] (0.640381813,2.56467652) newWindSum=-1 newOppSum=1 oppSum=1 windSum=-1 windValue=1
|
|
|
|
findNextOp from:[3] to:[1] start=1 end=0
|
|
|
|
bridgeOp current id=3 from=(0.991754651,2.01644516) to=(0.640381813,2.56467652)
|
|
|
|
path.cubicTo(0.739642859,2.30096555, 0.627014875,2.53316927, 0.640381813,2.56467652);
|
|
|
|
findNextOp simple
|
|
|
|
markDoneBinary id=1 (0,1 1,5 2,1 4,0) t=0 [0] (0,1) newWindSum=1 newOppSum=0 oppSum=0 windSum=1 windValue=1
|
|
|
|
bridgeOp current id=1 from=(0.640381813,2.56467652) to=(0,1)
|
|
|
|
path.cubicTo(0.42071557,2.32885909, 0.2103578,1.84143114, 0,1);
|
|
|
|
path.close();
|
|
|
|
debugShowActiveSpans id=3 (1,2 0,4 1,0 5,1) t=0.002763735 (0.991754651,2.01644516) tEnd=0.223476406 other=3 otherT=0.461521979 otherIndex=3 windSum=-1 windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=3 (1,2 0,4 1,0 5,1) t=0.461521979 (0.991754651,2.01644516) tEnd=0.466666667 other=3 otherT=0.002763735 otherIndex=1 windSum=1 windValue=1 oppValue=0
|
|
|
|
debugShowActiveSpans id=4 (5,1 1,2) t=0.697145868 (2.21141648,1.69714582) tEnd=0.997925926 other=1 otherT=0.646900486 otherIndex=2 windSum=-1 windValue=1 oppValue=0
|
|
|
|
activeOp op=diff miFrom=1 miTo=1 suFrom=1 suTo=0 result=1
|
|
|
|
findNextOp debugShowSort contourWinding=0 oppContourWinding=1 sign=1
|
|
|
|
debugShowSort [0] id=4 line start=2 (1.00829625,1.99792588) end=1 (2.21141648,1.69714582) sign=1 windValue=1 windSum=-1 0->-1 (max=-1) done=0 tiny=0 opp=0
|
|
|
|
debugShowSort [1] id=3 cubic start=4 (1.00829625,1.99792588) end=5 (2.85658813,0.932087123) sign=-1 windValue=1 windSum=-1 -1->0 (max=-1) done=1 tiny=0 opp=0
|
|
|
|
debugShowSort [2] id=4 line start=2 (1.00829625,1.99792588) end=3 (1,2) sign=-1 windValue=1 windSum=1 0->1 (max=1) done=1 tiny=0 opp=0
|
|
|
|
debugShowSort [3] id=3 cubic start=4 (1.00829625,1.99792588) end=3 (0.991754651,2.01644516) sign=1 windValue=1 windSum=1 1->0 (max=1) done=0 tiny=0 opp=0
|
|
|
|
findNextOp firstIndex=[0] sign=1
|
|
|
|
activeOp op=diff miFrom=1 miTo=1 suFrom=1 suTo=0 result=1
|
|
|
|
activeOp op=diff miFrom=1 miTo=1 suFrom=0 suTo=1 result=1
|
|
|
|
activeOp op=diff miFrom=1 miTo=1 suFrom=1 suTo=0 result=1
|
|
|
|
markDoneBinary id=4 (5,1 1,2) t=0.697145868 [1] (2.21141648,1.69714582) newWindSum=-1 newOppSum=1 oppSum=1 windSum=-1 windValue=1
|
|
|
|
findNextOp from:[4] to:[3] start=4 end=3
|
|
|
|
bridgeOp current id=4 from=(2.21141648,1.69714582) to=(1.00829625,1.99792588)
|
|
|
|
findNextOp debugShowSort contourWinding=0 oppContourWinding=1 sign=-1
|
|
|
|
debugShowSort [0] id=3 cubic start=3 (0.991754651,2.01644516) end=4 (1.00829625,1.99792588) sign=-1 windValue=1 windSum=1 0->1 (max=1) done=0 tiny=0 opp=0
|
|
|
|
debugShowSort [1] id=3 cubic start=1 (0.991754651,2.01644516) end=0 (1,2) sign=1 windValue=1 windSum=1 1->0 (max=1) done=1 tiny=0 opp=0
|
|
|
|
debugShowSort [2] id=3 cubic start=3 (0.991754651,2.01644516) end=2 (0.640381813,2.56467652) sign=1 windValue=1 windSum=-1 0->-1 (max=-1) done=1 tiny=0 opp=0
|
|
|
|
debugShowSort [3] id=3 cubic start=1 (0.991754651,2.01644516) end=2 (0.640381813,2.56467652) sign=-1 windValue=1 windSum=-1 -1->0 (max=-1) done=0 tiny=0 opp=0
|
|
|
|
findNextOp firstIndex=[0] sign=-1
|
|
|
|
activeOp op=diff miFrom=1 miTo=1 suFrom=1 suTo=0 result=1
|
|
|
|
activeOp op=diff miFrom=1 miTo=1 suFrom=0 suTo=1 result=1
|
|
|
|
activeOp op=diff miFrom=1 miTo=1 suFrom=1 suTo=0 result=1
|
|
|
|
markDoneBinary id=3 (1,2 0,4 1,0 5,1) t=0.461521979 [3] (0.991754651,2.01644516) newWindSum=1 newOppSum=1 oppSum=1 windSum=1 windValue=1
|
|
|
|
findNextOp from:[3] to:[3] start=1 end=2
|
|
|
|
bridgeOp current id=3 from=(1.00829625,1.99792588) to=(0.991754651,2.01644516)
|
|
|
|
path.moveTo(2.21141648,1.69714582);
|
|
|
|
path.lineTo(1.00829625,1.99792588);
|
|
|
|
path.cubicTo(1.00271726,2.0041225, 0.99720329,2.01029587, 0.991754651,2.01644516);
|
|
|
|
findNextOp debugShowSort contourWinding=0 oppContourWinding=1 sign=1
|
|
|
|
debugShowSort [2] id=3 cubic start=2 (0.640381813,2.56467652) end=1 (0.991754651,2.01644516) sign=1 windValue=1 windSum=-1 0->-1 (max=-1) done=0 tiny=0 opp=0
|
|
|
|
debugShowSort [3] id=1 cubic start=1 (0.640381813,2.56467652) end=2 (2.21141648,1.69714582) sign=-1 windValue=1 windSum=1 1->2 (max=2) done=1 tiny=0 opp=1
|
|
|
|
debugShowSort [0] id=3 cubic start=2 (0.640381813,2.56467652) end=3 (0.991754651,2.01644516) sign=-1 windValue=1 windSum=-1 -1->0 (max=-1) done=1 tiny=0 opp=0
|
|
|
|
debugShowSort [1] id=1 cubic start=1 (0.640381813,2.56467652) end=0 (0,1) sign=1 windValue=1 windSum=1 2->1 (max=2) done=1 tiny=0 opp=1
|
|
|
|
findNextOp firstIndex=[2] sign=1
|
|
|
|
activeOp op=diff miFrom=1 miTo=1 suFrom=1 suTo=1 result=0
|
|
|
|
activeOp op=diff miFrom=1 miTo=1 suFrom=1 suTo=0 result=1
|
|
|
|
activeOp op=diff miFrom=1 miTo=1 suFrom=0 suTo=0 result=0
|
|
|
|
markDoneBinary id=3 (1,2 0,4 1,0 5,1) t=0.002763735 [1] (0.991754651,2.01644516) newWindSum=-1 newOppSum=1 oppSum=1 windSum=-1 windValue=1
|
|
|
|
findNextOp from:[3] to:[3] start=2 end=3
|
|
|
|
bridgeOp current id=3 from=(0.991754651,2.01644516) to=(0.640381813,2.56467652)
|
|
|
|
path.cubicTo(0.773483634,2.45056915, 0.652775407,2.59388947, 0.640381813,2.56467652);
|
|
|
|
</div>
|
|
|
|
|
2012-10-26 21:03:50 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
var testDivs = [
|
2013-02-28 16:12:39 +00:00
|
|
|
cubicOp35d,
|
2013-02-26 15:56:05 +00:00
|
|
|
cubicOp31da,
|
|
|
|
cubicOp31d,
|
2013-02-22 21:50:07 +00:00
|
|
|
cubicOp28u,
|
|
|
|
cubicOp25i,
|
2013-02-17 01:41:25 +00:00
|
|
|
cubicOp19i,
|
2012-10-26 21:03:50 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
var decimal_places = 3; // make this 3 to show more precision
|
|
|
|
|
|
|
|
var tests = [];
|
|
|
|
var testTitles = [];
|
|
|
|
var testIndex = 0;
|
|
|
|
var ctx;
|
|
|
|
|
|
|
|
var xmin;
|
|
|
|
var ymin;
|
|
|
|
var scale;
|
|
|
|
var mouseX, mouseY;
|
|
|
|
var srcLeft, srcTop;
|
|
|
|
var srcWidth, srcHeight;
|
|
|
|
var screenWidth, screenHeight;
|
2013-02-17 01:41:25 +00:00
|
|
|
var drawnPts, drawnLines, drawnQuads, drawnCubics, deferredLines, deferredQuads, deferredCubics;
|
2012-10-26 21:03:50 +00:00
|
|
|
|
|
|
|
var ptLabels = true;
|
|
|
|
var digit_mode = false;
|
|
|
|
var index_mode = true;
|
|
|
|
var index_bits = -1;
|
|
|
|
var debug_xy = false;
|
|
|
|
var info_mode = false;
|
|
|
|
var intersect_mode = false;
|
|
|
|
var sequence = -1;
|
|
|
|
|
|
|
|
var SPAN_ID = 1;
|
|
|
|
var SPAN_X1 = 2;
|
|
|
|
var SPAN_Y1 = 3;
|
|
|
|
var SPAN_X2 = 4;
|
|
|
|
var SPAN_Y2 = 5;
|
|
|
|
var SPAN_L_T = 6;
|
|
|
|
var SPAN_L_TX = 7;
|
|
|
|
var SPAN_L_TY = 8;
|
2013-02-17 01:41:25 +00:00
|
|
|
var SPAN_L_TEND = 9;
|
|
|
|
var SPAN_L_OTHER = 10;
|
|
|
|
var SPAN_L_OTHERT = 11;
|
|
|
|
var SPAN_L_OTHERI = 12;
|
|
|
|
var SPAN_L_SUM = 13;
|
|
|
|
var SPAN_L_VAL = 14;
|
|
|
|
var SPAN_L_OPP = 15;
|
2012-10-26 21:03:50 +00:00
|
|
|
|
|
|
|
var SPAN_X3 = 6;
|
|
|
|
var SPAN_Y3 = 7;
|
|
|
|
var SPAN_Q_T = 8;
|
|
|
|
var SPAN_Q_TX = 9;
|
|
|
|
var SPAN_Q_TY = 10;
|
2013-02-17 01:41:25 +00:00
|
|
|
var SPAN_Q_TEND = 11;
|
|
|
|
var SPAN_Q_OTHER = 12;
|
|
|
|
var SPAN_Q_OTHERT = 13;
|
|
|
|
var SPAN_Q_OTHERI = 14;
|
|
|
|
var SPAN_Q_SUM = 15;
|
|
|
|
var SPAN_Q_VAL = 16;
|
|
|
|
var SPAN_Q_OPP = 17;
|
|
|
|
|
|
|
|
var SPAN_X4 = 8;
|
|
|
|
var SPAN_Y4 = 9;
|
|
|
|
var SPAN_C_T = 10;
|
|
|
|
var SPAN_C_TX = 11;
|
|
|
|
var SPAN_C_TY = 12;
|
|
|
|
var SPAN_C_TEND = 13;
|
|
|
|
var SPAN_C_OTHER = 14;
|
|
|
|
var SPAN_C_OTHERT = 15;
|
|
|
|
var SPAN_C_OTHERI = 16;
|
|
|
|
var SPAN_C_SUM = 17;
|
|
|
|
var SPAN_C_VAL = 18;
|
|
|
|
var SPAN_C_OPP = 19;
|
2012-10-26 21:03:50 +00:00
|
|
|
|
2012-10-31 19:00:20 +00:00
|
|
|
var ACTIVE_LINE_SPAN = 1;
|
2013-02-28 16:12:39 +00:00
|
|
|
var ACTIVE_QUAD_SPAN = ACTIVE_LINE_SPAN + 1;
|
|
|
|
var ACTIVE_CUBIC_SPAN = ACTIVE_QUAD_SPAN + 1;
|
|
|
|
|
|
|
|
var PATH_MOVETO = ACTIVE_CUBIC_SPAN + 1;
|
|
|
|
var PATH_LINETO = PATH_MOVETO + 1;
|
|
|
|
var PATH_QUADTO = PATH_LINETO + 1;
|
|
|
|
var PATH_CUBICTO = PATH_QUADTO + 1;
|
|
|
|
var PATH_CLOSE = PATH_CUBICTO + 1;
|
|
|
|
|
|
|
|
var INTERSECT_LINE = PATH_CLOSE + 1;
|
|
|
|
var INTERSECT_LINE_2 = INTERSECT_LINE + 1;
|
|
|
|
var INTERSECT_LINE_NO = INTERSECT_LINE_2 + 1;
|
|
|
|
var INTERSECT_QUAD_LINE = INTERSECT_LINE_NO + 1;
|
|
|
|
var INTERSECT_QUAD_LINE_2 = INTERSECT_QUAD_LINE + 1;
|
|
|
|
var INTERSECT_QUAD_LINE_NO = INTERSECT_QUAD_LINE_2 + 1;
|
|
|
|
var INTERSECT_QUAD = INTERSECT_QUAD_LINE_NO + 1;
|
|
|
|
var INTERSECT_QUAD_2 = INTERSECT_QUAD + 1;
|
|
|
|
var INTERSECT_QUAD_NO = INTERSECT_QUAD_2 + 1;
|
|
|
|
var INTERSECT_SELF_CUBIC = INTERSECT_QUAD_NO + 1;
|
|
|
|
var INTERSECT_SELF_CUBIC_NO = INTERSECT_SELF_CUBIC + 1;
|
|
|
|
var INTERSECT_CUBIC_LINE = INTERSECT_SELF_CUBIC_NO + 1;
|
|
|
|
var INTERSECT_CUBIC_LINE_2 = INTERSECT_CUBIC_LINE + 1;
|
|
|
|
var INTERSECT_CUBIC_LINE_3 = INTERSECT_CUBIC_LINE_2 + 1;
|
|
|
|
var INTERSECT_CUBIC_LINE_NO = INTERSECT_CUBIC_LINE_3 + 1;
|
|
|
|
// FIXME: add cubic/quad
|
|
|
|
var INTERSECT_CUBIC = INTERSECT_CUBIC_LINE_NO + 1;
|
|
|
|
var INTERSECT_CUBIC_2 = INTERSECT_CUBIC + 1;
|
|
|
|
var INTERSECT_CUBIC_3 = INTERSECT_CUBIC_2 + 1;
|
|
|
|
var INTERSECT_CUBIC_4 = INTERSECT_CUBIC_3 + 1;
|
|
|
|
// FIXME: add cubic 5- 9
|
|
|
|
var INTERSECT_CUBIC_NO = INTERSECT_CUBIC_4 + 1;
|
|
|
|
|
|
|
|
var SORT_LINE = INTERSECT_CUBIC_NO + 1;
|
|
|
|
var SORT_QUAD = SORT_LINE + 1;
|
|
|
|
var SORT_CUBIC = SORT_QUAD + 1;
|
|
|
|
|
|
|
|
var REC_TYPE_UNKNOWN = -1;
|
|
|
|
var REC_TYPE_PATH = 0;
|
|
|
|
var REC_TYPE_SECT = 1;
|
|
|
|
var REC_TYPE_ACTIVE = 2;
|
|
|
|
var REC_TYPE_ADD = 3;
|
|
|
|
var REC_TYPE_SORT = 4;
|
2012-10-26 21:03:50 +00:00
|
|
|
|
|
|
|
function strs_to_nums(strs) {
|
|
|
|
var result = [];
|
|
|
|
for (var idx in strs) {
|
|
|
|
var str = strs[idx];
|
|
|
|
var num = parseFloat(str);
|
|
|
|
if (isNaN(num)) {
|
|
|
|
result.push(str);
|
|
|
|
} else {
|
|
|
|
result.push(num);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-10-31 19:00:20 +00:00
|
|
|
function construct_regexp(pattern) {
|
|
|
|
var escape = pattern.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
|
|
escape = escape.replace(/PT_VAL/g, "(\\d+\\.?\\d*),(\\d+\\.?\\d*)");
|
|
|
|
escape = escape.replace(/T_VAL/g, "(\\d+\\.?\\d*e?-?\\d*)");
|
|
|
|
escape = escape.replace(/IDX/g, "(\\d+)");
|
|
|
|
escape = escape.replace(/OPT/g, "(\\?|-?\\d+)");
|
|
|
|
return new RegExp(escape, 'i');
|
|
|
|
}
|
|
|
|
|
2012-10-26 21:03:50 +00:00
|
|
|
function parse_debugShowActiveSpans(test, title) {
|
2013-02-17 01:41:25 +00:00
|
|
|
var re_cubic = construct_regexp(" id=IDX (PT_VAL PT_VAL PT_VAL PT_VAL) t=T_VAL (PT_VAL) tEnd=T_VAL other=IDX otherT=T_VAL otherIndex=IDX windSum=OPT windValue=IDX oppValue=IDX");
|
|
|
|
var re_quad = construct_regexp(" id=IDX (PT_VAL PT_VAL PT_VAL) t=T_VAL (PT_VAL) tEnd=T_VAL other=IDX otherT=T_VAL otherIndex=IDX windSum=OPT windValue=IDX oppValue=IDX");
|
|
|
|
var re_line = construct_regexp(" id=IDX (PT_VAL PT_VAL) t=T_VAL (PT_VAL) tEnd=T_VAL other=IDX otherT=T_VAL otherIndex=IDX windSum=OPT windValue=IDX oppValue=IDX");
|
2012-10-26 21:03:50 +00:00
|
|
|
|
|
|
|
var strs = test.split("debugShowActiveSpans");
|
|
|
|
if (strs.length == 1)
|
|
|
|
return;
|
|
|
|
var spans = [];
|
|
|
|
for (var s in strs) {
|
|
|
|
var str = strs[s];
|
|
|
|
if (str == "\n") {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (re_line.test(str)) {
|
|
|
|
var lineStrs = re_line.exec(str);
|
|
|
|
var line = strs_to_nums(lineStrs);
|
2012-10-31 19:00:20 +00:00
|
|
|
spans.push(ACTIVE_LINE_SPAN);
|
2012-10-26 21:03:50 +00:00
|
|
|
spans.push(line);
|
|
|
|
} else if (re_quad.test(str)) {
|
|
|
|
var quadStrs = re_quad.exec(str);
|
|
|
|
var quad = strs_to_nums(quadStrs);
|
2012-10-31 19:00:20 +00:00
|
|
|
spans.push(ACTIVE_QUAD_SPAN);
|
2012-10-26 21:03:50 +00:00
|
|
|
spans.push(quad);
|
2013-02-17 01:41:25 +00:00
|
|
|
} else if (re_cubic.test(str)) {
|
|
|
|
var cubicStrs = re_cubic.exec(str);
|
|
|
|
var cubic = strs_to_nums(cubicStrs);
|
|
|
|
spans.push(ACTIVE_CUBIC_SPAN);
|
|
|
|
spans.push(cubic);
|
2012-10-26 21:03:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (spans.length >= 1) {
|
|
|
|
tests.push(spans);
|
|
|
|
testTitles.push(title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-31 19:00:20 +00:00
|
|
|
function filter_str_by(id, str, regex, array) {
|
|
|
|
if (regex.test(str)) {
|
|
|
|
var strs = regex.exec(str);
|
|
|
|
var result = strs_to_nums(strs);
|
|
|
|
array.push(id);
|
|
|
|
array.push(result);
|
2013-02-28 16:12:39 +00:00
|
|
|
return true;
|
2012-10-31 19:00:20 +00:00
|
|
|
}
|
2013-02-28 16:12:39 +00:00
|
|
|
return false;
|
2012-10-31 19:00:20 +00:00
|
|
|
}
|
|
|
|
|
2013-02-17 01:41:25 +00:00
|
|
|
// FIXME: add cubic support
|
2012-10-31 19:00:20 +00:00
|
|
|
function parse_intersections(test, title) {
|
|
|
|
var re_quad_line = construct_regexp(" wtTs[0]=T_VAL (PT_VAL PT_VAL PT_VAL) (PT_VAL) wnTs[0]=T_VAL (PT_VAL PT_VAL) (PT_VAL)");
|
|
|
|
var re_quad_line_2 = construct_regexp(" wtTs[0]=T_VAL (PT_VAL PT_VAL PT_VAL) (PT_VAL) wtTs[1]=T_VAL (PT_VAL) wnTs[0]=T_VAL (PT_VAL PT_VAL) (PT_VAL) wnTs[1]=T_VAL (PT_VAL)");
|
|
|
|
var re_quad_line_no_intersect = construct_regexp(" no intersect (PT_VAL PT_VAL PT_VAL) (PT_VAL PT_VAL)");
|
|
|
|
var re_quad = construct_regexp(" wtTs[0]=T_VAL (PT_VAL PT_VAL PT_VAL) (PT_VAL) wnTs[0]=T_VAL (PT_VAL PT_VAL PT_VAL) (PT_VAL)");
|
|
|
|
var re_quad_2 = construct_regexp(" wtTs[0]=T_VAL (PT_VAL PT_VAL PT_VAL) (PT_VAL) wtTs[1]=T_VAL wnTs[0]=T_VAL (PT_VAL PT_VAL PT_VAL) (PT_VAL) wnTs[1]=T_VAL");
|
|
|
|
var re_quad_no_intersect = construct_regexp(" no intersect (PT_VAL PT_VAL PT_VAL) (PT_VAL PT_VAL PT_VAL)");
|
|
|
|
|
|
|
|
var strs = test.split(/debugShow[A-Za-z]+Intersection/);
|
|
|
|
if (strs.length == 1)
|
|
|
|
return;
|
|
|
|
var spans = [];
|
|
|
|
for (var s in strs) {
|
|
|
|
var str = strs[s];
|
|
|
|
if (str == "\n") {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
filter_str_by(INTERSECT_QUAD_LINE, str, re_quad_line, spans);
|
|
|
|
filter_str_by(INTERSECT_QUAD_LINE_2, str, re_quad_line_2, spans);
|
|
|
|
filter_str_by(INTERSECT_QUAD_LINE_NO, str, re_quad_line_no_intersect, spans);
|
|
|
|
filter_str_by(INTERSECT_QUAD, str, re_quad, spans);
|
|
|
|
filter_str_by(INTERSECT_QUAD_2, str, re_quad_2, spans);
|
|
|
|
filter_str_by(INTERSECT_QUAD_NO, str, re_quad_no_intersect, spans);
|
|
|
|
}
|
|
|
|
if (spans.length >= 1) {
|
|
|
|
tests.push(spans);
|
|
|
|
testTitles.push(title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-28 16:12:39 +00:00
|
|
|
function construct_regexp2(pattern) {
|
|
|
|
var escape = pattern.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
|
|
escape = escape.replace(/CUBIC_VAL/g, "\\(P_VAL P_VAL P_VAL P_VAL\\)");
|
|
|
|
escape = escape.replace(/QUAD_VAL/g, "\\(P_VAL P_VAL P_VAL\\)");
|
|
|
|
escape = escape.replace(/LINE_VAL/g, "\\(P_VAL P_VAL\\)");
|
|
|
|
escape = escape.replace(/PT_VAL/g, "\\(P_VAL\\)");
|
|
|
|
escape = escape.replace(/P_VAL/g, "(\\d+\\.?\\d*),(\\d+\\.?\\d*)");
|
|
|
|
escape = escape.replace(/T_VAL/g, "(\\d+\\.?\\d*e?-?\\d*)");
|
|
|
|
escape = escape.replace(/IDX/g, "(\\d+)");
|
|
|
|
escape = escape.replace(/NUM/g, "(-?\\d+)");
|
|
|
|
escape = escape.replace(/OPT/g, "(\\?|-?\\d+)");
|
|
|
|
return new RegExp(escape, 'i');
|
|
|
|
}
|
|
|
|
|
|
|
|
function construct_regexp2c(pattern) {
|
|
|
|
var escape = pattern.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
|
|
escape = escape.replace(/CUBIC_VAL/g, "\\{\\{P_VAL\\}, \\{P_VAL\\}, \\{P_VAL\\}, \\{P_VAL\\}\\}");
|
|
|
|
escape = escape.replace(/QUAD_VAL/g, "\\{\\{P_VAL\\}, \\{P_VAL\\}, \\{P_VAL\\}\\}");
|
|
|
|
escape = escape.replace(/LINE_VAL/g, "\\{\\{P_VAL\\}, \\{P_VAL\\}\\}");
|
|
|
|
escape = escape.replace(/PT_VAL/g, "\\{\\{P_VAL\\}\\}");
|
|
|
|
escape = escape.replace(/P_VAL/g, "(\\d+\\.?\\d*),(\\d+\\.?\\d*)");
|
|
|
|
escape = escape.replace(/T_VAL/g, "(\\d+\\.?\\d*e?-?\\d*)");
|
|
|
|
escape = escape.replace(/IDX/g, "(\\d+)");
|
|
|
|
escape = escape.replace(/NUM/g, "(-?\\d+)");
|
|
|
|
escape = escape.replace(/OPT/g, "(\\?|-?\\d+)");
|
|
|
|
return new RegExp(escape, 'i');
|
|
|
|
}
|
|
|
|
|
|
|
|
function match_regexp(str, lineNo, array, id, pattern) {
|
|
|
|
var regex = construct_regexp2(pattern);
|
|
|
|
if (filter_str_by(id, str, regex, array)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
regex = construct_regexp2c(pattern);
|
|
|
|
return filter_str_by(id, str, regex, array);
|
|
|
|
}
|
|
|
|
|
|
|
|
function parse_all(test, title) {
|
|
|
|
var lines = test.match(/[^\r\n]+/g);
|
|
|
|
var records = []; // a rec can be the original paths, a set of intersections, a set of active spans, a sort, or a path add
|
|
|
|
var record = [];
|
|
|
|
var recType = REC_TYPE_UNKNOWN;
|
|
|
|
for (var lineNo in lines) {
|
|
|
|
var line = lines[lineNo];
|
|
|
|
var type = line.lastIndexOf("debugShowSort", 0) === 0 ? REC_TYPE_SORT
|
|
|
|
: line.lastIndexOf("debugShowActiveSpans", 0) === 0 ? REC_TYPE_ACTIVE
|
|
|
|
: line.lastIndexOf("debugShow", 0) === 0 ? REC_TYPE_SECT
|
|
|
|
: line.lastIndexOf("path.", 0) === 0 ? REC_TYPE_ADD
|
|
|
|
: line.lastIndexOf("{{", 0) === 0 ? REC_TYPE_PATH
|
|
|
|
: REC_TYPE_UNKNOWN;
|
|
|
|
if (recType != type) {
|
|
|
|
if (recType != REC_TYPE_UNKNOWN) {
|
|
|
|
records.push(recType);
|
|
|
|
records.push(lineNo);
|
|
|
|
records.push(record);
|
|
|
|
}
|
|
|
|
record = [];
|
|
|
|
recType = type;
|
|
|
|
}
|
|
|
|
var found = false;
|
|
|
|
switch (recType) {
|
|
|
|
case REC_TYPE_ACTIVE:
|
|
|
|
found = match_regexp(line, lineNo, record, ACTIVE_LINE_SPAN, "debugShowActiveSpans" +
|
|
|
|
" id=IDX LINE_VAL t=T_VAL PT_VAL tEnd=T_VAL other=IDX otherT=T_VAL otherIndex=IDX windSum=OPT windValue=IDX oppValue=IDX"
|
|
|
|
) || match_regexp(line, lineNo, record, ACTIVE_QUAD_SPAN, "debugShowActiveSpans" +
|
|
|
|
" id=IDX QUAD_VAL t=T_VAL PT_VAL tEnd=T_VAL other=IDX otherT=T_VAL otherIndex=IDX windSum=OPT windValue=IDX oppValue=IDX"
|
|
|
|
) || match_regexp(line, lineNo, record, ACTIVE_CUBIC_SPAN, "debugShowActiveSpans" +
|
|
|
|
" id=IDX CUBIC_VAL t=T_VAL PT_VAL tEnd=T_VAL other=IDX otherT=T_VAL otherIndex=IDX windSum=OPT windValue=IDX oppValue=IDX"
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case REC_TYPE_ADD:
|
|
|
|
found = match_regexp(line, lineNo, record, PATH_MOVETO, "path.moveToPT_VAL;"
|
|
|
|
) || match_regexp(line, lineNo, record, PATH_LINETO, "path.lineTo(P_VAL);"
|
|
|
|
) || match_regexp(line, lineNo, record, PATH_QUADTO, "path.quadTo(P_VAL, P_VAL);"
|
|
|
|
) || match_regexp(line, lineNo, record, PATH_CUBICTO, "path.cubicTo(P_VAL, P_VAL, P_VAL);"
|
|
|
|
) || match_regexp(line, lineNo, record, PATH_CLOSE, "path.close();"
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case REC_TYPE_SECT:
|
|
|
|
found = match_regexp(line, lineNo, record, INTERSECT_LINE, "debugShowLineIntersection" +
|
|
|
|
" wtTs[0]=T_VAL LINE_VAL PT_VAL wnTs[0]=T_VAL LINE_VAL"
|
|
|
|
) || match_regexp(line, lineNo, record, INTERSECT_LINE_2, "debugShowLineIntersection" +
|
|
|
|
" wtTs[0]=T_VAL LINE_VAL PT_VAL wtTs[1]=T_VAL PT_VAL wnTs[0]=T_VAL LINE_VAL wnTs[1]=T_VAL"
|
|
|
|
) || match_regexp(line, lineNo, record, INTERSECT_LINE_NO, "debugShowLineIntersection" +
|
|
|
|
" no intersect LINE_VAL LINE_VAL"
|
|
|
|
) || match_regexp(line, lineNo, record, INTERSECT_QUAD_LINE, "debugShowQuadLineIntersection" +
|
|
|
|
" wtTs[0]=T_VAL QUAD_VAL PT_VAL wnTs[0]=T_VAL LINE_VAL"
|
|
|
|
) || match_regexp(line, lineNo, record, INTERSECT_QUAD_LINE_2, "debugShowQuadLineIntersection" +
|
|
|
|
" wtTs[0]=T_VAL QUAD_VAL PT_VAL wtTs[1]=T_VAL PT_VAL wnTs[0]=T_VAL LINE_VAL wnTs[1]=T_VAL"
|
|
|
|
) || match_regexp(line, lineNo, record, INTERSECT_QUAD_LINE_NO, "debugShowQuadLineIntersection" +
|
|
|
|
" no intersect QUAD_VAL LINE_VAL"
|
|
|
|
) || match_regexp(line, lineNo, record, INTERSECT_QUAD, "debugShowQuadIntersection" +
|
|
|
|
" wtTs[0]=T_VAL QUAD_VAL PT_VAL wnTs[0]=T_VAL QUAD_VAL"
|
|
|
|
) || match_regexp(line, lineNo, record, INTERSECT_QUAD_2, "debugShowQuadIntersection" +
|
|
|
|
" wtTs[0]=T_VAL QUAD_VAL PT_VAL wtTs[1]=T_VAL wnTs[0]=T_VAL QUAD_VAL wnTs[1]=T_VAL"
|
|
|
|
) || match_regexp(line, lineNo, record, INTERSECT_QUAD_NO, "debugShowQuadIntersection" +
|
|
|
|
" no intersect QUAD_VAL QUAD_VAL"
|
|
|
|
) || match_regexp(line, lineNo, record, INTERSECT_SELF_CUBIC, "debugShowCubicIntersection" +
|
|
|
|
" wtTs[0]=T_VAL CUBIC_VAL PT_VAL wtTs[1]=T_VAL"
|
|
|
|
) || match_regexp(line, lineNo, record, INTERSECT_SELF_CUBIC_NO, "debugShowCubicIntersection" +
|
|
|
|
" no self intersect CUBIC_VAL"
|
|
|
|
) || match_regexp(line, lineNo, record, INTERSECT_CUBIC_LINE, "debugShowCubicLineIntersection" +
|
|
|
|
" wtTs[0]=T_VAL CUBIC_VAL PT_VAL wnTs[0]=T_VAL LINE_VAL"
|
|
|
|
) || match_regexp(line, lineNo, record, INTERSECT_CUBIC_LINE_2, "debugShowCubicLineIntersection" +
|
|
|
|
" wtTs[0]=T_VAL CUBIC_VAL PT_VAL wtTs[1]=T_VAL PT_VAL wnTs[0]=T_VAL LINE_VAL wnTs[1]=T_VAL"
|
|
|
|
) || match_regexp(line, lineNo, record, INTERSECT_CUBIC_LINE_3, "debugShowCubicLineIntersection" +
|
|
|
|
" wtTs[0]=T_VAL CUBIC_VAL PT_VAL wtTs[1]=T_VAL PT_VAL wtTs[2]=T_VAL PT_VAL wnTs[0]=T_VAL LINE_VAL wnTs[1]=T_VAL wnTs[2]=T_VAL"
|
|
|
|
) || match_regexp(line, lineNo, record, INTERSECT_CUBIC_LINE_NO, "debugShowCubicLineIntersection" +
|
|
|
|
" no intersect CUBIC_VAL LINE_VAL"
|
|
|
|
) || match_regexp(line, lineNo, record, INTERSECT_CUBIC, "debugShowCubicIntersection" +
|
|
|
|
" wtTs[0]=T_VAL CUBIC_VAL PT_VAL wnTs[0]=T_VAL CUBIC_VAL"
|
|
|
|
) || match_regexp(line, lineNo, record, INTERSECT_CUBIC_2, "debugShowCubicIntersection" +
|
|
|
|
" wtTs[0]=T_VAL CUBIC_VAL PT_VAL wtTs[1]=T_VAL PT_VAL wnTs[0]=T_VAL CUBIC_VAL wnTs[1]=T_VAL"
|
|
|
|
) || match_regexp(line, lineNo, record, INTERSECT_CUBIC_3, "debugShowCubicIntersection" +
|
|
|
|
" wtTs[0]=T_VAL CUBIC_VAL PT_VAL wtTs[1]=T_VAL PT_VAL wtTs[2]=T_VAL PT_VAL wnTs[0]=T_VAL CUBIC_VAL wnTs[1]=T_VAL wnTs[2]=T_VAL"
|
|
|
|
) || match_regexp(line, lineNo, record, INTERSECT_CUBIC_4, "debugShowCubicIntersection" +
|
|
|
|
" wtTs[0]=T_VAL CUBIC_VAL PT_VAL wtTs[1]=T_VAL PT_VAL wtTs[2]=T_VAL PT_VAL wtTs[3]=T_VAL PT_VAL wnTs[0]=T_VAL CUBIC_VAL wnTs[1]=T_VAL wnTs[2]=T_VAL wnTs[3]=T_VAL"
|
|
|
|
) || match_regexp(line, lineNo, record, INTERSECT_CUBIC_NO, "debugShowCubicIntersection" +
|
|
|
|
" no intersect CUBIC_VAL CUBIC_VAL"
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case REC_TYPE_SORT:
|
|
|
|
found = match_regexp(line, lineNo, record, SORT_LINE, "debugShowSort" +
|
|
|
|
" [IDX] id=IDX line start=IDX PT_VAL end=IDX PT_VAL sign=NUM windValue=IDX windSum=OPT NUM->NUM (max=NUM) done=IDX tiny=IDX opp=IDX"
|
|
|
|
) || match_regexp(line, lineNo, record, SORT_QUAD, "debugShowSort" +
|
|
|
|
" [IDX] id=IDX quad start=IDX PT_VAL end=IDX PT_VAL sign=NUM windValue=IDX windSum=OPT NUM->NUM (max=NUM) done=IDX tiny=IDX opp=IDX"
|
|
|
|
) || match_regexp(line, lineNo, record, SORT_CUBIC, "debugShowSort" +
|
|
|
|
" [IDX] id=IDX cubic start=IDX PT_VAL end=IDX PT_VAL sign=NUM windValue=IDX windSum=OPT NUM->NUM (max=NUM) done=IDX tiny=IDX opp=IDX"
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case REC_TYPE_UNKNOWN:
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
console.log(line + " [" + lineNo + "] of type " + type + " not found");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (records.length >= 1) {
|
|
|
|
tests.push(records);
|
|
|
|
testTitles.push(title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-26 21:03:50 +00:00
|
|
|
function init(test) {
|
|
|
|
var canvas = document.getElementById('canvas');
|
|
|
|
if (!canvas.getContext) return;
|
|
|
|
screenWidth = canvas.width = window.innerWidth - 20;
|
|
|
|
screenHeight = canvas.height = window.innerHeight - 20;
|
|
|
|
ctx = canvas.getContext('2d');
|
|
|
|
xmin = Infinity;
|
|
|
|
var xmax = -Infinity;
|
|
|
|
ymin = Infinity;
|
|
|
|
var ymax = -Infinity;
|
2012-10-31 19:00:20 +00:00
|
|
|
var scanType = -1;
|
|
|
|
for (var scansStr in test) {
|
|
|
|
var scans = parseInt(scansStr);
|
2012-10-26 21:03:50 +00:00
|
|
|
var scan = test[scans];
|
2012-10-31 19:00:20 +00:00
|
|
|
if (scanType == -1) {
|
|
|
|
scanType = scan;
|
|
|
|
continue;
|
|
|
|
}
|
2013-02-17 01:41:25 +00:00
|
|
|
if (scanType == ACTIVE_LINE_SPAN || scanType == ACTIVE_QUAD_SPAN
|
|
|
|
|| scanType == ACTIVE_CUBIC_SPAN) {
|
|
|
|
var last = scanType == ACTIVE_CUBIC_SPAN ? SPAN_X4
|
|
|
|
: scanType == ACTIVE_QUAD_SPAN ? SPAN_X3 : SPAN_X2;
|
2012-10-31 19:00:20 +00:00
|
|
|
for (var idx = SPAN_X1; idx <= last; idx += 2) {
|
|
|
|
xmin = Math.min(xmin, scan[idx]);
|
|
|
|
xmax = Math.max(xmax, scan[idx]);
|
|
|
|
ymin = Math.min(ymin, scan[idx + 1]);
|
|
|
|
ymax = Math.max(ymax, scan[idx + 1]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
var start = 1;
|
|
|
|
if (scanType != INTERSECT_QUAD_LINE_NO && scanType != INTERSECT_QUAD_NO) {
|
|
|
|
start = 2;
|
|
|
|
}
|
|
|
|
for (var idx = start; idx < start + 6; idx += 2) {
|
|
|
|
xmin = Math.min(xmin, scan[idx]);
|
|
|
|
xmax = Math.max(xmax, scan[idx]);
|
|
|
|
ymin = Math.min(ymin, scan[idx + 1]);
|
|
|
|
ymax = Math.max(ymax, scan[idx + 1]);
|
|
|
|
}
|
|
|
|
start = start + 6;
|
|
|
|
if (scanType == INTERSECT_QUAD_LINE || scanType == INTERSECT_QUAD) {
|
|
|
|
start += 3;
|
|
|
|
}
|
|
|
|
if (scanType == INTERSECT_QUAD_LINE_2) {
|
|
|
|
start += 6;
|
|
|
|
}
|
|
|
|
if (scanType == INTERSECT_QUAD_2) {
|
|
|
|
start += 4;
|
|
|
|
}
|
|
|
|
var end = start + 4;
|
|
|
|
if (scanType == INTERSECT_QUAD || scanType == INTERSECT_QUAD_2 || scanType == INTERSECT_QUAD_NO) {
|
|
|
|
end += 2;
|
|
|
|
}
|
|
|
|
for (var idx = start; idx < end; idx += 2) {
|
|
|
|
xmin = Math.min(xmin, scan[idx]);
|
|
|
|
xmax = Math.max(xmax, scan[idx]);
|
|
|
|
ymin = Math.min(ymin, scan[idx + 1]);
|
|
|
|
ymax = Math.max(ymax, scan[idx + 1]);
|
|
|
|
}
|
2012-10-26 21:03:50 +00:00
|
|
|
}
|
2012-10-31 19:00:20 +00:00
|
|
|
scanType = -1;
|
2012-10-26 21:03:50 +00:00
|
|
|
}
|
|
|
|
srcWidth = xmax - xmin;
|
|
|
|
srcHeight = ymax - ymin;
|
|
|
|
var hscale = ctx.canvas.width / srcWidth;
|
|
|
|
var vscale = ctx.canvas.height / srcHeight;
|
|
|
|
var minScale = Math.min(hscale, vscale);
|
|
|
|
scale = minScale;
|
|
|
|
srcLeft = xmin;
|
|
|
|
srcTop = ymin;
|
|
|
|
}
|
|
|
|
|
|
|
|
function drawPoint(px, py) {
|
|
|
|
for (var pts = 0; pts < drawnPts.length; pts += 2) {
|
|
|
|
var x = drawnPts[pts];
|
|
|
|
var y = drawnPts[pts + 1];
|
|
|
|
if (px == x && py == y) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
drawnPts.push(px);
|
|
|
|
drawnPts.push(py);
|
|
|
|
var label = px.toFixed(decimal_places) + ", " + py.toFixed(decimal_places);
|
|
|
|
var _px = (px - srcLeft)* scale;
|
|
|
|
var _py = (py - srcTop) * scale;
|
|
|
|
ctx.beginPath();
|
|
|
|
ctx.arc(_px, _py, 3, 0, Math.PI*2, true);
|
|
|
|
ctx.closePath();
|
|
|
|
ctx.fill();
|
|
|
|
ctx.fillText(label, _px + 5, _py);
|
|
|
|
}
|
|
|
|
|
2012-10-31 19:00:20 +00:00
|
|
|
function drawLine(x1, y1, x2, y2, selected) {
|
|
|
|
for (var pts = 0; pts < drawnLines.length; pts += 4) {
|
|
|
|
if (x1 == drawnLines[pts] && y1 == drawnLines[pts + 1]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (x2 == drawnLines[pts + 2] && x2 == drawnLines[pts + 3]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (selected) {
|
|
|
|
drawnLines.push(x1);
|
|
|
|
drawnLines.push(y1);
|
|
|
|
drawnLines.push(x2);
|
|
|
|
drawnLines.push(y2);
|
|
|
|
ctx.beginPath();
|
|
|
|
ctx.moveTo((x1 - srcLeft) * scale,
|
|
|
|
(y1 - srcTop) * scale);
|
|
|
|
ctx.lineTo((x2 - srcLeft) * scale,
|
|
|
|
(y2 - srcTop) * scale);
|
|
|
|
ctx.stroke();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
deferredLines.push(x1);
|
|
|
|
deferredLines.push(y1);
|
|
|
|
deferredLines.push(x2);
|
|
|
|
deferredLines.push(y2);
|
|
|
|
}
|
|
|
|
|
2013-02-17 01:41:25 +00:00
|
|
|
function drawLinePartial(x1, y1, x2, y2, t1, t2) {
|
|
|
|
var dx = x1 - x2;
|
|
|
|
var dy = y1 - y2;
|
|
|
|
var ax = x1 - t1 * dx;
|
|
|
|
var ay = y1 - t1 * dy;
|
|
|
|
var bx = x1 - t2 * dx;
|
|
|
|
var by = y1 - t2 * dy;
|
|
|
|
ctx.beginPath();
|
|
|
|
ctx.moveTo((ax - srcLeft) * scale,
|
|
|
|
(ay - srcTop) * scale);
|
|
|
|
ctx.lineTo((bx - srcLeft) * scale,
|
|
|
|
(by - srcTop) * scale);
|
|
|
|
ctx.stroke();
|
|
|
|
}
|
|
|
|
|
2012-10-31 19:00:20 +00:00
|
|
|
function drawQuad(x1, y1, x2, y2, x3, y3, selected) {
|
|
|
|
for (var pts = 0; pts < drawnQuads.length; pts += 6) {
|
|
|
|
if (x1 == drawnQuads[pts] && y1 == drawnQuads[pts + 1]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (x2 == drawnQuads[pts + 2] && x2 == drawnQuads[pts + 3]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (x2 == drawnQuads[pts + 4] && x2 == drawnQuads[pts + 5]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (selected) {
|
|
|
|
drawnQuads.push(x1);
|
|
|
|
drawnQuads.push(y1);
|
|
|
|
drawnQuads.push(x2);
|
|
|
|
drawnQuads.push(y2);
|
|
|
|
drawnQuads.push(x3);
|
|
|
|
drawnQuads.push(y3);
|
|
|
|
ctx.beginPath();
|
|
|
|
ctx.moveTo((x1 - srcLeft) * scale,
|
|
|
|
(y1 - srcTop) * scale);
|
|
|
|
ctx.quadraticCurveTo((x2 - srcLeft) * scale,
|
|
|
|
(y2 - srcTop) * scale,
|
|
|
|
(x3 - srcLeft) * scale,
|
|
|
|
(y3 - srcTop) * scale);
|
|
|
|
ctx.stroke();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
deferredQuads.push(x1);
|
|
|
|
deferredQuads.push(y1);
|
|
|
|
deferredQuads.push(x2);
|
|
|
|
deferredQuads.push(y2);
|
|
|
|
deferredQuads.push(x3);
|
|
|
|
deferredQuads.push(y3);
|
|
|
|
}
|
|
|
|
|
2013-02-17 01:41:25 +00:00
|
|
|
function interp(A, B, t) {
|
|
|
|
return A + (B - A) * t;
|
|
|
|
}
|
|
|
|
|
|
|
|
function interp_quad_coords(x1, x2, x3, t)
|
|
|
|
{
|
|
|
|
var ab = interp(x1, x2, t);
|
|
|
|
var bc = interp(x2, x3, t);
|
|
|
|
var abc = interp(ab, bc, t);
|
|
|
|
return abc;
|
|
|
|
}
|
|
|
|
|
|
|
|
function drawQuadPartial(x1, y1, x2, y2, x3, y3, t1, t2) {
|
|
|
|
var ax = interp_quad_coords(x1, x2, x3, t1);
|
|
|
|
var ay = interp_quad_coords(y1, y2, y3, t1);
|
|
|
|
var dx = interp_quad_coords(x1, x2, x3, (t1 + t2) / 2);
|
|
|
|
var dy = interp_quad_coords(y1, y2, y3, (t1 + t2) / 2);
|
|
|
|
var cx = interp_quad_coords(x1, x2, x3, t2);
|
|
|
|
var cy = interp_quad_coords(y1, y2, y3, t2);
|
|
|
|
var bx = 2*dx - (ax + cx)/2;
|
|
|
|
var by = 2*dy - (ay + cy)/2;
|
|
|
|
ctx.beginPath();
|
|
|
|
ctx.moveTo((ax - srcLeft) * scale,
|
|
|
|
(ay - srcTop) * scale);
|
|
|
|
ctx.quadraticCurveTo((bx - srcLeft) * scale,
|
|
|
|
(by - srcTop) * scale,
|
|
|
|
(cx - srcLeft) * scale,
|
|
|
|
(cy - srcTop) * scale);
|
|
|
|
ctx.stroke();
|
|
|
|
}
|
|
|
|
|
|
|
|
function drawCubic(x1, y1, x2, y2, x3, y3, x4, y4, selected) {
|
|
|
|
for (var pts = 0; pts < drawnCubics.length; pts += 8) {
|
|
|
|
if (x1 == drawnCubics[pts] && y1 == drawnCubics[pts + 1]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (x2 == drawnCubics[pts + 2] && x2 == drawnCubics[pts + 3]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (x2 == drawnCubics[pts + 4] && x2 == drawnCubics[pts + 5]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (x2 == drawnCubics[pts + 6] && x2 == drawnCubics[pts + 7]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (selected) {
|
|
|
|
drawnCubics.push(x1);
|
|
|
|
drawnCubics.push(y1);
|
|
|
|
drawnCubics.push(x2);
|
|
|
|
drawnCubics.push(y2);
|
|
|
|
drawnCubics.push(x3);
|
|
|
|
drawnCubics.push(y3);
|
|
|
|
drawnCubics.push(x4);
|
|
|
|
drawnCubics.push(y4);
|
|
|
|
ctx.beginPath();
|
|
|
|
ctx.moveTo((x1 - srcLeft) * scale,
|
|
|
|
(y1 - srcTop) * scale);
|
|
|
|
ctx.bezierCurveTo((x2 - srcLeft) * scale,
|
|
|
|
(y2 - srcTop) * scale,
|
|
|
|
(x3 - srcLeft) * scale,
|
|
|
|
(y3 - srcTop) * scale,
|
|
|
|
(x4 - srcLeft) * scale,
|
|
|
|
(y4 - srcTop) * scale);
|
|
|
|
ctx.stroke();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
deferredCubics.push(x1);
|
|
|
|
deferredCubics.push(y1);
|
|
|
|
deferredCubics.push(x2);
|
|
|
|
deferredCubics.push(y2);
|
|
|
|
deferredCubics.push(x3);
|
|
|
|
deferredCubics.push(y3);
|
|
|
|
deferredCubics.push(x4);
|
|
|
|
deferredCubics.push(y4);
|
|
|
|
}
|
|
|
|
|
|
|
|
function interp_cubic_coords(x1, x2, x3, x4, t)
|
|
|
|
{
|
|
|
|
var ab = interp(x1, x2, t);
|
|
|
|
var bc = interp(x2, x3, t);
|
|
|
|
var cd = interp(x3, x4, t);
|
|
|
|
var abc = interp(ab, bc, t);
|
|
|
|
var bcd = interp(bc, cd, t);
|
|
|
|
var abcd = interp(abc, bcd, t);
|
|
|
|
return abcd;
|
|
|
|
}
|
|
|
|
|
|
|
|
function drawCubicPartial(x1, y1, x2, y2, x3, y3, x4, y4, t1, t2) {
|
|
|
|
var ax = interp_cubic_coords(x1, x2, x3, x4, t1);
|
|
|
|
var ay = interp_cubic_coords(y1, y2, y3, y4, t1);
|
|
|
|
var ex = interp_cubic_coords(x1, x2, x3, x4, (t1*2+t2)/3);
|
|
|
|
var ey = interp_cubic_coords(y1, y2, y3, y4, (t1*2+t2)/3);
|
|
|
|
var fx = interp_cubic_coords(x1, x2, x3, x4, (t1+t2*2)/3);
|
|
|
|
var fy = interp_cubic_coords(y1, y2, y3, y4, (t1+t2*2)/3);
|
|
|
|
var dx = interp_cubic_coords(x1, x2, x3, x4, t2);
|
|
|
|
var dy = interp_cubic_coords(y1, y2, y3, y4, t2);
|
|
|
|
var mx = ex * 27 - ax * 8 - dx;
|
|
|
|
var my = ey * 27 - ay * 8 - dy;
|
|
|
|
var nx = fx * 27 - ax - dx * 8;
|
|
|
|
var ny = fy * 27 - ay - dy * 8;
|
|
|
|
var bx = (mx * 2 - nx) / 18;
|
|
|
|
var by = (my * 2 - ny) / 18;
|
|
|
|
var cx = (nx * 2 - mx) / 18;
|
|
|
|
var cy = (ny * 2 - my) / 18;
|
|
|
|
ctx.beginPath();
|
|
|
|
ctx.moveTo((ax - srcLeft) * scale,
|
|
|
|
(ay - srcTop) * scale);
|
|
|
|
ctx.bezierCurveTo((bx - srcLeft) * scale,
|
|
|
|
(by - srcTop) * scale,
|
|
|
|
(cx - srcLeft) * scale,
|
|
|
|
(cy - srcTop) * scale,
|
|
|
|
(dx - srcLeft) * scale,
|
|
|
|
(dy - srcTop) * scale,
|
|
|
|
(ex - srcLeft) * scale,
|
|
|
|
(ey - srcTop) * scale);
|
|
|
|
ctx.stroke();
|
|
|
|
}
|
|
|
|
|
|
|
|
function drawPartial(test) {
|
|
|
|
ctx.lineWidth = 3;
|
|
|
|
ctx.strokeStyle = "rgba(0,0,255, 0.3)";
|
|
|
|
var scanType = -1;
|
|
|
|
var partIndex = 0;
|
|
|
|
for (var scansStr in test) {
|
|
|
|
var scans = parseInt(scansStr);
|
|
|
|
var scan = test[scans];
|
|
|
|
if (scanType == -1) {
|
|
|
|
scanType = scan;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
partIndex++;
|
|
|
|
var hasId = scanType == ACTIVE_LINE_SPAN || scanType == ACTIVE_QUAD_SPAN
|
|
|
|
|| scanType == ACTIVE_CUBIC_SPAN ? SPAN_ID : -1;
|
|
|
|
if (hasId < 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
var types = [scanType == ACTIVE_LINE_SPAN ? 0 : scanType == ACTIVE_QUAD_SPAN ? 1 : 2];
|
|
|
|
var x1 = scan[SPAN_X1];
|
|
|
|
var y1 = scan[SPAN_Y1];
|
|
|
|
var x2 = scan[SPAN_X2];
|
|
|
|
var y2 = scan[SPAN_Y2];
|
|
|
|
var x3, y3, x3, y4, t1, t2;
|
|
|
|
switch(scanType) {
|
|
|
|
case ACTIVE_LINE_SPAN:
|
|
|
|
t1 = scan[SPAN_L_T];
|
|
|
|
t2 = scan[SPAN_L_TEND];
|
|
|
|
drawLinePartial(x1, y1, x2, y2, t1, t2);
|
|
|
|
break;
|
|
|
|
case ACTIVE_QUAD_SPAN:
|
|
|
|
x3 = scan[SPAN_X3];
|
|
|
|
y3 = scan[SPAN_Y3];
|
|
|
|
t1 = scan[SPAN_Q_T];
|
|
|
|
t2 = scan[SPAN_Q_TEND];
|
|
|
|
drawQuadPartial(x1, y1, x2, y2, x3, y3, t1, t2);
|
|
|
|
break;
|
|
|
|
case ACTIVE_CUBIC_SPAN:
|
|
|
|
x3 = scan[SPAN_X3];
|
|
|
|
y3 = scan[SPAN_Y3];
|
|
|
|
x4 = scan[SPAN_X4];
|
|
|
|
y4 = scan[SPAN_Y4];
|
|
|
|
t1 = scan[SPAN_C_T];
|
|
|
|
t2 = scan[SPAN_C_TEND];
|
|
|
|
drawCubicPartial(x1, y1, x2, y2, x3, y3, x4, y4, t1, t2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
scanType = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-31 19:00:20 +00:00
|
|
|
function drawDeferred() {
|
2013-02-17 01:41:25 +00:00
|
|
|
for (var pts = 0; pts < deferredCubics.length; pts += 8) {
|
|
|
|
drawCubic(deferredCubics[pts], deferredCubics[pts + 1],
|
|
|
|
deferredCubics[pts + 2], deferredCubics[pts + 3],
|
|
|
|
deferredCubics[pts + 4], deferredCubics[pts + 5],
|
|
|
|
deferredCubics[pts + 6], deferredCubics[pts + 7], true);
|
|
|
|
}
|
2012-10-31 19:00:20 +00:00
|
|
|
for (var pts = 0; pts < deferredQuads.length; pts += 6) {
|
|
|
|
drawQuad(deferredQuads[pts], deferredQuads[pts + 1],
|
|
|
|
deferredQuads[pts + 2], deferredQuads[pts + 3],
|
|
|
|
deferredQuads[pts + 4], deferredQuads[pts + 5], true);
|
|
|
|
}
|
|
|
|
for (var pts = 0; pts < deferredLines.length; pts += 4) {
|
|
|
|
drawLine(deferredLines[pts], deferredLines[pts + 1],
|
|
|
|
deferredLines[pts + 2], deferredLines[pts + 3], true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-26 21:03:50 +00:00
|
|
|
function draw(test, title) {
|
|
|
|
ctx.fillStyle = "rgba(0,0,0, 0.1)";
|
|
|
|
ctx.font = "normal 50px Arial";
|
|
|
|
ctx.fillText(title, 50, 50);
|
|
|
|
ctx.font = "normal 10px Arial";
|
|
|
|
ctx.lineWidth = "1.001"; "0.999";
|
2012-10-31 19:00:20 +00:00
|
|
|
var curId = -1;
|
2012-10-26 21:03:50 +00:00
|
|
|
var firstIdx;
|
|
|
|
var lastIdx;
|
|
|
|
var index_tst = -1;
|
|
|
|
drawnPts = [];
|
2012-10-31 19:00:20 +00:00
|
|
|
drawnLines = [];
|
|
|
|
drawnQuads = [];
|
2013-02-17 01:41:25 +00:00
|
|
|
drawnCubics = [];
|
2012-10-31 19:00:20 +00:00
|
|
|
deferredLines = [];
|
|
|
|
deferredQuads = [];
|
2013-02-17 01:41:25 +00:00
|
|
|
deferredCubics = [];
|
2012-10-31 19:00:20 +00:00
|
|
|
var scanType = -1;
|
|
|
|
var partIndex = 0;
|
2012-10-26 21:03:50 +00:00
|
|
|
for (var scansStr in test) {
|
|
|
|
var scans = parseInt(scansStr);
|
|
|
|
var scan = test[scans];
|
2012-10-31 19:00:20 +00:00
|
|
|
if (scanType == -1) {
|
|
|
|
scanType = scan;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
partIndex++;
|
2013-02-17 01:41:25 +00:00
|
|
|
var hasId = scanType == ACTIVE_LINE_SPAN || scanType == ACTIVE_QUAD_SPAN
|
|
|
|
|| scanType == ACTIVE_CUBIC_SPAN ? SPAN_ID : -1;
|
2012-10-31 19:00:20 +00:00
|
|
|
if (hasId >= 0 && curId != scan[hasId]) {
|
2013-02-17 01:41:25 +00:00
|
|
|
curId = scan[hasId];
|
2012-10-31 19:00:20 +00:00
|
|
|
firstIdx = lastIdx = partIndex;
|
|
|
|
index_tst++;
|
2012-10-26 21:03:50 +00:00
|
|
|
var nextIdx = lastIdx + 1;
|
2012-10-31 19:00:20 +00:00
|
|
|
while (nextIdx * 2 < test.length && test[nextIdx * 2][hasId] == curId) {
|
2012-10-26 21:03:50 +00:00
|
|
|
lastIdx = nextIdx++;
|
|
|
|
}
|
2012-10-31 19:00:20 +00:00
|
|
|
} else if (hasId < 0) {
|
|
|
|
firstIdx = lastIdx = partIndex;
|
|
|
|
index_tst++;
|
2012-10-26 21:03:50 +00:00
|
|
|
}
|
2012-10-31 19:00:20 +00:00
|
|
|
var seq = sequence % (test.length / 2);
|
|
|
|
var selected = sequence >= 0 ? seq == partIndex
|
|
|
|
: (index_bits & (1 << index_tst)) != 0 && partIndex == firstIdx;
|
2012-10-26 21:03:50 +00:00
|
|
|
var skippable = (sequence >= 0 && seq >= firstIdx && seq <= lastIdx)
|
2012-10-31 19:00:20 +00:00
|
|
|
|| partIndex != firstIdx;
|
2012-10-26 21:03:50 +00:00
|
|
|
if (skippable && !selected) {
|
2012-10-31 19:00:20 +00:00
|
|
|
scanType = -1;
|
2012-10-26 21:03:50 +00:00
|
|
|
continue;
|
|
|
|
}
|
2013-02-17 01:41:25 +00:00
|
|
|
var types = [scanType == ACTIVE_LINE_SPAN ? 0 : scanType == ACTIVE_QUAD_SPAN ? 1 : 2];
|
2012-10-31 19:00:20 +00:00
|
|
|
var pts = [];
|
2013-02-17 01:41:25 +00:00
|
|
|
if (scanType == ACTIVE_LINE_SPAN || scanType == ACTIVE_QUAD_SPAN || scanType == ACTIVE_CUBIC_SPAN) {
|
2012-10-31 19:00:20 +00:00
|
|
|
pts.push(SPAN_X1);
|
2012-10-26 21:03:50 +00:00
|
|
|
} else {
|
2012-10-31 19:00:20 +00:00
|
|
|
pts.push(scanType != INTERSECT_QUAD_NO && scanType != INTERSECT_QUAD_LINE_NO ? 2 : 1);
|
|
|
|
types.push(scanType == INTERSECT_QUAD_NO || scanType == INTERSECT_QUAD || scanType == INTERSECT_QUAD_2 ? 1 : 0);
|
|
|
|
pts.push(scanType == INTERSECT_QUAD_LINE || scanType == INTERSECT_QUAD ? 11
|
|
|
|
: scanType == INTERSECT_QUAD_LINE_2 ? 14 : scanType == INTERSECT_QUAD_2 ? 12 : 7);
|
|
|
|
}
|
|
|
|
ctx.strokeStyle = "red";
|
|
|
|
for (var typeIndex = 0; typeIndex < types.length; ++typeIndex) {
|
|
|
|
var type = types[typeIndex];
|
|
|
|
var index = pts[typeIndex];
|
2013-02-17 01:41:25 +00:00
|
|
|
if (type == 2) {
|
|
|
|
drawCubic(scan[index + 0], scan[index + 1], scan[index + 2], scan[index + 3],
|
|
|
|
scan[index + 4], scan[index + 5], scan[index + 6], scan[index + 7],
|
|
|
|
selected);
|
|
|
|
} else if (type == 1) {
|
2012-10-31 19:00:20 +00:00
|
|
|
drawQuad(scan[index + 0], scan[index + 1], scan[index + 2], scan[index + 3],
|
|
|
|
scan[index + 4], scan[index + 5], selected);
|
|
|
|
} else {
|
|
|
|
drawLine(scan[index + 0], scan[index + 1], scan[index + 2], scan[index + 3],
|
|
|
|
selected);
|
|
|
|
}
|
2012-10-26 21:03:50 +00:00
|
|
|
}
|
|
|
|
if (debug_xy && selected) {
|
|
|
|
var debugText = "";
|
2012-10-31 19:00:20 +00:00
|
|
|
for (var typeIndex = 0; typeIndex < types.length; ++typeIndex) {
|
|
|
|
var type = types[typeIndex];
|
|
|
|
var index = pts[typeIndex];
|
2013-02-17 01:41:25 +00:00
|
|
|
for (var idx = pts[typeIndex]; idx < pts[typeIndex] + (type + 1) * 2; idx += 2) {
|
2012-10-31 19:00:20 +00:00
|
|
|
var screenX = (scan[idx] - srcLeft) * scale;
|
|
|
|
var screenY = (scan[idx + 1] - srcTop) * scale;
|
|
|
|
debugText += screenX.toFixed(decimal_places) + ", ";
|
|
|
|
debugText += screenY.toFixed(decimal_places) + " ";
|
|
|
|
}
|
2012-10-26 21:03:50 +00:00
|
|
|
}
|
|
|
|
ctx.fillStyle="blue";
|
2012-10-31 19:00:20 +00:00
|
|
|
ctx.fillText(debugText, 50, partIndex * 50 + 100);
|
2012-10-26 21:03:50 +00:00
|
|
|
}
|
|
|
|
if (ptLabels && selected) {
|
|
|
|
ctx.fillStyle="blue";
|
2012-10-31 19:00:20 +00:00
|
|
|
for (var typeIndex = 0; typeIndex < types.length; ++typeIndex) {
|
|
|
|
var type = types[typeIndex];
|
|
|
|
var index = pts[typeIndex];
|
2013-02-17 01:41:25 +00:00
|
|
|
for (var idx = pts[typeIndex]; idx < pts[typeIndex] + (type + 1) * 2; idx += 2) {
|
2012-10-31 19:00:20 +00:00
|
|
|
drawPoint(scan[idx], scan[idx + 1]);
|
|
|
|
}
|
2012-10-26 21:03:50 +00:00
|
|
|
}
|
|
|
|
}
|
2012-10-31 19:00:20 +00:00
|
|
|
var infoText = "";
|
2012-10-26 21:03:50 +00:00
|
|
|
if (info_mode && selected) {
|
2012-10-31 19:00:20 +00:00
|
|
|
infoText += hasId >= 0 ? "id=" + scan[hasId] : partIndex;
|
|
|
|
}
|
|
|
|
if (intersect_mode && selected) {
|
2013-02-17 01:41:25 +00:00
|
|
|
if (scanType == ACTIVE_CUBIC_SPAN) {
|
|
|
|
infoText += " t=" + scan[SPAN_C_T];
|
|
|
|
} else if (scanType == ACTIVE_QUAD_SPAN) {
|
2012-10-31 19:00:20 +00:00
|
|
|
infoText += " t=" + scan[SPAN_Q_T];
|
|
|
|
} else if (scanType == ACTIVE_LINE_SPAN) {
|
|
|
|
infoText += " t=" + scan[SPAN_L_T];
|
|
|
|
} else if (scanType == INTERSECT_QUAD_LINE ||scanType == INTERSECT_QUAD) {
|
|
|
|
infoText += " t0[0]=" + scan[1] + " t1[0]=" + scan[10];
|
|
|
|
} else if (scanType == INTERSECT_QUAD_LINE_2 || scanType == INTERSECT_QUAD_2) {
|
|
|
|
infoText += " t0[0]=" + scan[1] + " t0[1]=" + scan[10] + " t1[0]=" + scan[13];
|
|
|
|
if (scanType == INTERSECT_QUAD_LINE_2) {
|
|
|
|
infoText += " t1[1]=" + scan[18];
|
|
|
|
} else {
|
|
|
|
infoText += " t0[1]=" + scan[20];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (infoText.length > 0) {
|
2012-10-26 21:03:50 +00:00
|
|
|
ctx.fillStyle="green";
|
2012-10-31 19:00:20 +00:00
|
|
|
ctx.fillText(infoText, 10, (hasId >= 0 && sequence >= 0
|
|
|
|
? hasId : partIndex) * 30 + 50);
|
2012-10-26 21:03:50 +00:00
|
|
|
}
|
|
|
|
if (intersect_mode && selected) {
|
|
|
|
ctx.fillStyle="rgba(50,100,200, 1.0)";
|
2013-02-17 01:41:25 +00:00
|
|
|
if (scanType == ACTIVE_CUBIC_SPAN) {
|
|
|
|
drawPoint(scan[SPAN_C_TX], scan[SPAN_C_TY]);
|
|
|
|
} else if (scanType == ACTIVE_QUAD_SPAN) {
|
2012-10-26 21:03:50 +00:00
|
|
|
drawPoint(scan[SPAN_Q_TX], scan[SPAN_Q_TY]);
|
2012-10-31 19:00:20 +00:00
|
|
|
} else if (scanType == ACTIVE_LINE_SPAN) {
|
2012-10-26 21:03:50 +00:00
|
|
|
drawPoint(scan[SPAN_L_TX], scan[SPAN_L_TY]);
|
2012-10-31 19:00:20 +00:00
|
|
|
} else if (scanType != INTERSECT_QUAD_NO && scanType != INTERSECT_QUAD_LINE_NO) {
|
|
|
|
drawPoint(scan[8], scan[9]);
|
|
|
|
if (scanType == INTERSECT_QUAD_LINE_2 || scanType == INTERSECT_QUAD_2) {
|
|
|
|
drawPoint(scan[11], scan[12]);
|
|
|
|
}
|
2012-10-26 21:03:50 +00:00
|
|
|
}
|
|
|
|
}
|
2012-10-31 19:00:20 +00:00
|
|
|
ctx.strokeStyle = "rgba(0,0,0, 0.2)";
|
|
|
|
scanType = -1;
|
2012-10-26 21:03:50 +00:00
|
|
|
}
|
2012-10-31 19:00:20 +00:00
|
|
|
drawDeferred();
|
2013-02-17 01:41:25 +00:00
|
|
|
drawPartial(test);
|
2012-10-26 21:03:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function drawTop() {
|
|
|
|
init(tests[testIndex]);
|
|
|
|
redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
function redraw() {
|
|
|
|
ctx.beginPath();
|
|
|
|
ctx.rect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
|
|
|
ctx.fillStyle="white";
|
|
|
|
ctx.fill();
|
|
|
|
draw(tests[testIndex], testTitles[testIndex]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function doKeyPress(evt) {
|
|
|
|
var char = String.fromCharCode(evt.charCode);
|
|
|
|
switch (char) {
|
|
|
|
case '0':
|
|
|
|
case '1':
|
|
|
|
case '2':
|
|
|
|
case '3':
|
|
|
|
case '4':
|
|
|
|
case '5':
|
|
|
|
case '6':
|
|
|
|
case '7':
|
|
|
|
case '8':
|
|
|
|
case '9':
|
|
|
|
if (digit_mode) {
|
|
|
|
decimal_places = char - '0';
|
|
|
|
} else if (index_mode) {
|
|
|
|
index_bits ^= 1 << (char - '0');
|
|
|
|
}
|
|
|
|
redraw();
|
|
|
|
break;
|
|
|
|
case 'd':
|
|
|
|
digit_mode = true;
|
|
|
|
index_mode = false;
|
|
|
|
break;
|
|
|
|
case 'f':
|
|
|
|
info_mode ^= true;
|
|
|
|
redraw();
|
|
|
|
break;
|
|
|
|
case 'i':
|
|
|
|
digit_mode = false;
|
|
|
|
if (sequence >= 0) {
|
|
|
|
sequence = -1;
|
|
|
|
index_mode = false;
|
|
|
|
} else {
|
|
|
|
index_mode ^= true;
|
|
|
|
}
|
|
|
|
if (index_mode) {
|
|
|
|
index_bits = 0;
|
|
|
|
} else {
|
|
|
|
index_bits = -1;
|
|
|
|
}
|
|
|
|
redraw();
|
|
|
|
break;
|
|
|
|
case 'N':
|
|
|
|
testIndex += 9;
|
|
|
|
case 'n':
|
|
|
|
if (++testIndex >= tests.length)
|
|
|
|
testIndex = 0;
|
|
|
|
drawTop();
|
|
|
|
break;
|
|
|
|
case 'P':
|
|
|
|
testIndex -= 9;
|
|
|
|
case 'p':
|
|
|
|
if (--testIndex < 0)
|
|
|
|
testIndex = tests.length - 1;
|
|
|
|
drawTop();
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
sequence++;
|
2012-10-31 19:00:20 +00:00
|
|
|
redraw();
|
|
|
|
break;
|
|
|
|
case 'S':
|
|
|
|
sequence--;
|
|
|
|
if (sequence < 0) {
|
|
|
|
sequence = 0;
|
|
|
|
}
|
|
|
|
redraw();
|
2012-10-26 21:03:50 +00:00
|
|
|
break;
|
|
|
|
case 't':
|
|
|
|
intersect_mode ^= true;
|
|
|
|
redraw();
|
|
|
|
break;
|
|
|
|
case 'x':
|
|
|
|
ptLabels ^= true;
|
|
|
|
redraw();
|
|
|
|
break;
|
|
|
|
case 'y':
|
|
|
|
debug_xy ^= true;
|
|
|
|
redraw();
|
|
|
|
break;
|
|
|
|
case '-':
|
|
|
|
scale /= 2;
|
|
|
|
calcLeftTop();
|
|
|
|
redraw();
|
|
|
|
break;
|
|
|
|
case '=':
|
|
|
|
case '+':
|
|
|
|
scale *= 2;
|
|
|
|
calcLeftTop();
|
|
|
|
redraw();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function calcXY() {
|
|
|
|
var e = window.event;
|
|
|
|
var tgt = e.target || e.srcElement;
|
|
|
|
var left = tgt.offsetLeft;
|
|
|
|
var top = tgt.offsetTop;
|
|
|
|
var unit = scale;
|
|
|
|
mouseX = (e.clientX - left) / scale + srcLeft;
|
|
|
|
mouseY = (e.clientY - top) / scale + srcTop;
|
|
|
|
}
|
|
|
|
|
|
|
|
function calcLeftTop() {
|
|
|
|
srcLeft = mouseX - screenWidth / 2 / scale;
|
|
|
|
srcTop = mouseY - screenHeight / 2 / scale;
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleMouseClick() {
|
|
|
|
calcXY();
|
|
|
|
calcLeftTop();
|
|
|
|
redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleMouseOver() {
|
|
|
|
calcXY();
|
|
|
|
var num = mouseX.toFixed(decimal_places) + ", " + mouseY.toFixed(decimal_places);
|
|
|
|
ctx.beginPath();
|
|
|
|
ctx.rect(300,100,200,10);
|
|
|
|
ctx.fillStyle="white";
|
|
|
|
ctx.fill();
|
|
|
|
ctx.fillStyle="black";
|
|
|
|
ctx.fillText(num, 300, 108);
|
|
|
|
}
|
|
|
|
|
|
|
|
function start() {
|
|
|
|
for (i = 0; i < testDivs.length; ++i) {
|
|
|
|
var title = testDivs[i].id.toString();
|
|
|
|
var str = testDivs[i].firstChild.data;
|
2013-02-28 16:12:39 +00:00
|
|
|
parse_all(str, title);
|
2012-10-26 21:03:50 +00:00
|
|
|
parse_debugShowActiveSpans(str, title);
|
2012-10-31 19:00:20 +00:00
|
|
|
parse_intersections(str, title);
|
2012-10-26 21:03:50 +00:00
|
|
|
}
|
|
|
|
drawTop();
|
|
|
|
window.addEventListener('keypress', doKeyPress, true);
|
|
|
|
window.onresize = function() {
|
|
|
|
drawTop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body onLoad="start();">
|
|
|
|
<canvas id="canvas" width="750" height="500"
|
|
|
|
onmousemove="handleMouseOver()"
|
|
|
|
onclick="handleMouseClick()"
|
|
|
|
></canvas >
|
|
|
|
</body>
|
|
|
|
</html>
|