caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 1 | <html> |
| 2 | <head> |
| 3 | <div style="height:0"> |
| 4 | |
caryclark@google.com | c83c70e | 2013-02-22 21:50:07 +0000 | [diff] [blame] | 5 | <div id="cubicOp25i"> |
| 6 | 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 |
| 7 | 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 |
| 8 | </div> |
| 9 | |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 10 | <div id="cubicOp19i"> |
| 11 | 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 |
| 12 | 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 |
| 13 | 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 |
| 14 | 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 |
| 15 | 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 |
| 16 | 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 |
| 17 | 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 |
| 18 | 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 |
| 19 | 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 |
| 20 | 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 |
| 21 | 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 |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 22 | </div> |
| 23 | |
caryclark@google.com | c83c70e | 2013-02-22 21:50:07 +0000 | [diff] [blame] | 24 | <div id="cubicOp28u"> |
| 25 | 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 |
| 26 | 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 |
| 27 | 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 |
| 28 | 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 |
| 29 | 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 |
| 30 | 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 |
| 31 | 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 |
| 32 | 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 |
| 33 | 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 |
| 34 | 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 |
| 35 | 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 |
| 36 | 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 |
| 37 | 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 |
| 38 | 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 |
| 39 | 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 |
| 40 | 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 |
| 41 | </div> |
| 42 | |
caryclark@google.com | 7ff5c84 | 2013-02-26 15:56:05 +0000 | [diff] [blame] | 43 | <div id="cubicOp31d"> |
| 44 | 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 |
| 45 | 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 |
| 46 | 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 |
| 47 | 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 |
| 48 | 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 |
| 49 | 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 |
| 50 | 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 |
| 51 | 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 |
| 52 | </div> |
| 53 | |
| 54 | <div id="cubicOp31da"> |
| 55 | 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 |
| 56 | 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 |
| 57 | 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 |
| 58 | 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 |
| 59 | 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 |
| 60 | 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 |
| 61 | </div> |
| 62 | |
caryclark@google.com | 4aaaaea | 2013-02-28 16:12:39 +0000 | [diff] [blame^] | 63 | <div id="cubicOp35d"> |
| 64 | SimplifyNew_Test [cubicOp35d] |
| 65 | debugShowCubicIntersection no self intersect {{0,1}, {1,5}, {2,1}, {4,0}} |
| 66 | 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 |
| 67 | 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 |
| 68 | 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}} |
| 69 | debugShowCubicLineIntersection no intersect {{1,2}, {0,4}, {1,0}, {5,1}} {{4,0}, {0,1}} |
| 70 | debugShowLineIntersection no intersect {{4,0}, {0,1}} {{5,1}, {1,2}} |
| 71 | debugShowCubicIntersection wtTs[0]=0.002763735 {{1,2}, {0,4}, {1,0}, {5,1}} {{0.9917546455060533,2.0164451540317003}} wtTs[1]=0.461521979 |
| 72 | 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 |
| 73 | 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 |
| 74 | 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 |
| 75 | 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 |
| 76 | 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 |
| 77 | debugShowActiveSpans id=2 (4,0 0,1) t=0 (4,0) tEnd=1 other=1 otherT=1 otherIndex=4 windSum=? windValue=1 oppValue=0 |
| 78 | 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 |
| 79 | 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 |
| 80 | 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 |
| 81 | 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 |
| 82 | 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 |
| 83 | 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 |
| 84 | 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 |
| 85 | 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 |
| 86 | 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 |
| 87 | findTop debugShowSort contourWinding=0 oppContourWinding=0 sign=-1 |
| 88 | 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 |
| 89 | 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 |
| 90 | markWinding id=2 (4,0 0,1) t=0 [0] (4,0) newWindSum=1 newOppSum=0 oppSum=? windSum=? windValue=1 |
| 91 | 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 |
| 92 | markWinding id=2 (4,0 0,1) t=0 [0] (4,0) newWindSum=1 newOppSum=0 oppSum=0 windSum=1 windValue=1 |
| 93 | markWinding id=1 (0,1 1,5 2,1 4,0) t=0 [0] (0,1) newWindSum=1 newOppSum=0 oppSum=? windSum=? windValue=1 |
| 94 | activeOp op=diff miFrom=1 miTo=0 suFrom=0 suTo=0 result=1 |
| 95 | findNextOp simple |
| 96 | markDoneBinary id=2 (4,0 0,1) t=0 [0] (4,0) newWindSum=1 newOppSum=0 oppSum=0 windSum=1 windValue=1 |
| 97 | bridgeOp current id=2 from=(0,1) to=(4,0) |
| 98 | findNextOp debugShowSort contourWinding=0 oppContourWinding=0 sign=-1 |
| 99 | 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 |
| 100 | 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 |
| 101 | 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 |
| 102 | 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 |
| 103 | findNextOp firstIndex=[1] sign=-1 |
| 104 | activeOp op=diff miFrom=1 miTo=1 suFrom=0 suTo=1 result=1 |
| 105 | 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 |
| 106 | findNextOp chase.append id=3 |
| 107 | activeOp op=diff miFrom=1 miTo=0 suFrom=1 suTo=1 result=0 |
| 108 | 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 |
| 109 | findNextOp chase.append id=1 |
| 110 | activeOp op=diff miFrom=0 miTo=0 suFrom=1 suTo=0 result=0 |
| 111 | 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 |
| 112 | markDoneBinary id=4 (5,1 1,2) t=0 [0] (5,1) newWindSum=-1 newOppSum=0 oppSum=? windSum=? windValue=1 |
| 113 | findNextOp chase.append id=4 |
| 114 | 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 |
| 115 | findNextOp from:[1] to:[3] start=5 end=4 |
| 116 | bridgeOp current id=1 from=(4,0) to=(2.85658813,0.932087123) |
| 117 | path.moveTo(0,1); |
| 118 | path.lineTo(4,0); |
| 119 | path.cubicTo(3.57735038,0.211324871, 3.1993587,0.556624353, 2.85658813,0.932087123); |
| 120 | findNextOp debugShowSort contourWinding=-1 oppContourWinding=1 sign=-1 |
| 121 | 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 |
| 122 | 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 |
| 123 | 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 |
| 124 | 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 |
| 125 | findNextOp firstIndex=[1] sign=-1 |
| 126 | activeOp op=diff miFrom=1 miTo=1 suFrom=0 suTo=1 result=1 |
| 127 | markWinding id=4 (5,1 1,2) t=0.997925926 [2] (1.00829625,1.99792588) newWindSum=1 newOppSum=1 oppSum=? windSum=? windValue=1 |
| 128 | markWinding id=3 (1,2 0,4 1,0 5,1) t=0 [0] (1,2) newWindSum=1 newOppSum=1 oppSum=? windSum=? windValue=1 |
| 129 | findNextOp chase.append id=3 |
| 130 | activeOp op=diff miFrom=1 miTo=1 suFrom=1 suTo=0 result=1 |
| 131 | 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 |
| 132 | findNextOp chase.append id=3 |
| 133 | activeOp op=diff miFrom=1 miTo=1 suFrom=0 suTo=1 result=1 |
| 134 | markWinding id=4 (5,1 1,2) t=0.697145868 [1] (2.21141648,1.69714582) newWindSum=-1 newOppSum=1 oppSum=? windSum=? windValue=1 |
| 135 | findNextOp chase.append id=4 |
| 136 | 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 |
| 137 | findNextOp from:[3] to:[4] start=2 end=3 |
| 138 | bridgeOp current id=3 from=(2.85658813,0.932087123) to=(1.00829625,1.99792588) |
| 139 | path.cubicTo(1.96246409,1.13237906, 1.35749662,1.61008465, 1.00829625,1.99792588); |
| 140 | findNextOp simple |
| 141 | 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 |
| 142 | bridgeOp current id=4 from=(1.00829625,1.99792588) to=(1,2) |
| 143 | Program received signal: “EXC_BAD_ACCESS”. |
| 144 | findNextOp debugShowSort contourWinding=1 oppContourWinding=1 sign=1 |
| 145 | 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 |
| 146 | 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 |
| 147 | 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 |
| 148 | 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 |
| 149 | findNextOp firstIndex=[1] sign=1 |
| 150 | activeOp op=diff miFrom=1 miTo=1 suFrom=0 suTo=1 result=1 |
| 151 | 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 |
| 152 | findNextOp chase.append id=3 |
| 153 | activeOp op=diff miFrom=1 miTo=1 suFrom=1 suTo=0 result=1 |
| 154 | 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 |
| 155 | findNextOp chase.append id=3 |
| 156 | activeOp op=diff miFrom=1 miTo=1 suFrom=0 suTo=1 result=1 |
| 157 | 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 |
| 158 | findNextOp from:[3] to:[3] start=3 end=2 |
| 159 | bridgeOp current id=3 from=(1,2) to=(0.991754651,2.01644516) |
| 160 | path.lineTo(1,2); |
| 161 | path.cubicTo(0.997236252,2.0055275, 0.994487822,2.01100922, 0.991754651,2.01644516); |
| 162 | findNextOp debugShowSort contourWinding=-1 oppContourWinding=1 sign=-1 |
| 163 | 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 |
| 164 | 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 |
| 165 | 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 |
| 166 | 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 |
| 167 | findNextOp firstIndex=[0] sign=-1 |
| 168 | activeOp op=diff miFrom=1 miTo=0 suFrom=0 suTo=0 result=1 |
| 169 | activeOp op=diff miFrom=0 miTo=0 suFrom=0 suTo=1 result=0 |
| 170 | activeOp op=diff miFrom=0 miTo=1 suFrom=1 suTo=1 result=0 |
| 171 | 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 |
| 172 | findNextOp chase.append id=1 |
| 173 | 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 |
| 174 | findNextOp from:[3] to:[1] start=1 end=0 |
| 175 | bridgeOp current id=3 from=(0.991754651,2.01644516) to=(0.640381813,2.56467652) |
| 176 | path.cubicTo(0.739642859,2.30096555, 0.627014875,2.53316927, 0.640381813,2.56467652); |
| 177 | findNextOp simple |
| 178 | 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 |
| 179 | bridgeOp current id=1 from=(0.640381813,2.56467652) to=(0,1) |
| 180 | path.cubicTo(0.42071557,2.32885909, 0.2103578,1.84143114, 0,1); |
| 181 | path.close(); |
| 182 | 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 |
| 183 | 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 |
| 184 | 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 |
| 185 | activeOp op=diff miFrom=1 miTo=1 suFrom=1 suTo=0 result=1 |
| 186 | findNextOp debugShowSort contourWinding=0 oppContourWinding=1 sign=1 |
| 187 | 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 |
| 188 | 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 |
| 189 | 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 |
| 190 | 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 |
| 191 | findNextOp firstIndex=[0] sign=1 |
| 192 | activeOp op=diff miFrom=1 miTo=1 suFrom=1 suTo=0 result=1 |
| 193 | activeOp op=diff miFrom=1 miTo=1 suFrom=0 suTo=1 result=1 |
| 194 | activeOp op=diff miFrom=1 miTo=1 suFrom=1 suTo=0 result=1 |
| 195 | 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 |
| 196 | findNextOp from:[4] to:[3] start=4 end=3 |
| 197 | bridgeOp current id=4 from=(2.21141648,1.69714582) to=(1.00829625,1.99792588) |
| 198 | findNextOp debugShowSort contourWinding=0 oppContourWinding=1 sign=-1 |
| 199 | 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 |
| 200 | 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 |
| 201 | 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 |
| 202 | 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 |
| 203 | findNextOp firstIndex=[0] sign=-1 |
| 204 | activeOp op=diff miFrom=1 miTo=1 suFrom=1 suTo=0 result=1 |
| 205 | activeOp op=diff miFrom=1 miTo=1 suFrom=0 suTo=1 result=1 |
| 206 | activeOp op=diff miFrom=1 miTo=1 suFrom=1 suTo=0 result=1 |
| 207 | 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 |
| 208 | findNextOp from:[3] to:[3] start=1 end=2 |
| 209 | bridgeOp current id=3 from=(1.00829625,1.99792588) to=(0.991754651,2.01644516) |
| 210 | path.moveTo(2.21141648,1.69714582); |
| 211 | path.lineTo(1.00829625,1.99792588); |
| 212 | path.cubicTo(1.00271726,2.0041225, 0.99720329,2.01029587, 0.991754651,2.01644516); |
| 213 | findNextOp debugShowSort contourWinding=0 oppContourWinding=1 sign=1 |
| 214 | 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 |
| 215 | 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 |
| 216 | 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 |
| 217 | 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 |
| 218 | findNextOp firstIndex=[2] sign=1 |
| 219 | activeOp op=diff miFrom=1 miTo=1 suFrom=1 suTo=1 result=0 |
| 220 | activeOp op=diff miFrom=1 miTo=1 suFrom=1 suTo=0 result=1 |
| 221 | activeOp op=diff miFrom=1 miTo=1 suFrom=0 suTo=0 result=0 |
| 222 | 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 |
| 223 | findNextOp from:[3] to:[3] start=2 end=3 |
| 224 | bridgeOp current id=3 from=(0.991754651,2.01644516) to=(0.640381813,2.56467652) |
| 225 | path.cubicTo(0.773483634,2.45056915, 0.652775407,2.59388947, 0.640381813,2.56467652); |
| 226 | </div> |
| 227 | |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 228 | </div> |
| 229 | |
| 230 | <script type="text/javascript"> |
| 231 | |
| 232 | var testDivs = [ |
caryclark@google.com | 4aaaaea | 2013-02-28 16:12:39 +0000 | [diff] [blame^] | 233 | cubicOp35d, |
caryclark@google.com | 7ff5c84 | 2013-02-26 15:56:05 +0000 | [diff] [blame] | 234 | cubicOp31da, |
| 235 | cubicOp31d, |
caryclark@google.com | c83c70e | 2013-02-22 21:50:07 +0000 | [diff] [blame] | 236 | cubicOp28u, |
| 237 | cubicOp25i, |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 238 | cubicOp19i, |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 239 | ]; |
| 240 | |
| 241 | var decimal_places = 3; // make this 3 to show more precision |
| 242 | |
| 243 | var tests = []; |
| 244 | var testTitles = []; |
| 245 | var testIndex = 0; |
| 246 | var ctx; |
| 247 | |
| 248 | var xmin; |
| 249 | var ymin; |
| 250 | var scale; |
| 251 | var mouseX, mouseY; |
| 252 | var srcLeft, srcTop; |
| 253 | var srcWidth, srcHeight; |
| 254 | var screenWidth, screenHeight; |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 255 | var drawnPts, drawnLines, drawnQuads, drawnCubics, deferredLines, deferredQuads, deferredCubics; |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 256 | |
| 257 | var ptLabels = true; |
| 258 | var digit_mode = false; |
| 259 | var index_mode = true; |
| 260 | var index_bits = -1; |
| 261 | var debug_xy = false; |
| 262 | var info_mode = false; |
| 263 | var intersect_mode = false; |
| 264 | var sequence = -1; |
| 265 | |
| 266 | var SPAN_ID = 1; |
| 267 | var SPAN_X1 = 2; |
| 268 | var SPAN_Y1 = 3; |
| 269 | var SPAN_X2 = 4; |
| 270 | var SPAN_Y2 = 5; |
| 271 | var SPAN_L_T = 6; |
| 272 | var SPAN_L_TX = 7; |
| 273 | var SPAN_L_TY = 8; |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 274 | var SPAN_L_TEND = 9; |
| 275 | var SPAN_L_OTHER = 10; |
| 276 | var SPAN_L_OTHERT = 11; |
| 277 | var SPAN_L_OTHERI = 12; |
| 278 | var SPAN_L_SUM = 13; |
| 279 | var SPAN_L_VAL = 14; |
| 280 | var SPAN_L_OPP = 15; |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 281 | |
| 282 | var SPAN_X3 = 6; |
| 283 | var SPAN_Y3 = 7; |
| 284 | var SPAN_Q_T = 8; |
| 285 | var SPAN_Q_TX = 9; |
| 286 | var SPAN_Q_TY = 10; |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 287 | var SPAN_Q_TEND = 11; |
| 288 | var SPAN_Q_OTHER = 12; |
| 289 | var SPAN_Q_OTHERT = 13; |
| 290 | var SPAN_Q_OTHERI = 14; |
| 291 | var SPAN_Q_SUM = 15; |
| 292 | var SPAN_Q_VAL = 16; |
| 293 | var SPAN_Q_OPP = 17; |
| 294 | |
| 295 | var SPAN_X4 = 8; |
| 296 | var SPAN_Y4 = 9; |
| 297 | var SPAN_C_T = 10; |
| 298 | var SPAN_C_TX = 11; |
| 299 | var SPAN_C_TY = 12; |
| 300 | var SPAN_C_TEND = 13; |
| 301 | var SPAN_C_OTHER = 14; |
| 302 | var SPAN_C_OTHERT = 15; |
| 303 | var SPAN_C_OTHERI = 16; |
| 304 | var SPAN_C_SUM = 17; |
| 305 | var SPAN_C_VAL = 18; |
| 306 | var SPAN_C_OPP = 19; |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 307 | |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 308 | var ACTIVE_LINE_SPAN = 1; |
caryclark@google.com | 4aaaaea | 2013-02-28 16:12:39 +0000 | [diff] [blame^] | 309 | var ACTIVE_QUAD_SPAN = ACTIVE_LINE_SPAN + 1; |
| 310 | var ACTIVE_CUBIC_SPAN = ACTIVE_QUAD_SPAN + 1; |
| 311 | |
| 312 | var PATH_MOVETO = ACTIVE_CUBIC_SPAN + 1; |
| 313 | var PATH_LINETO = PATH_MOVETO + 1; |
| 314 | var PATH_QUADTO = PATH_LINETO + 1; |
| 315 | var PATH_CUBICTO = PATH_QUADTO + 1; |
| 316 | var PATH_CLOSE = PATH_CUBICTO + 1; |
| 317 | |
| 318 | var INTERSECT_LINE = PATH_CLOSE + 1; |
| 319 | var INTERSECT_LINE_2 = INTERSECT_LINE + 1; |
| 320 | var INTERSECT_LINE_NO = INTERSECT_LINE_2 + 1; |
| 321 | var INTERSECT_QUAD_LINE = INTERSECT_LINE_NO + 1; |
| 322 | var INTERSECT_QUAD_LINE_2 = INTERSECT_QUAD_LINE + 1; |
| 323 | var INTERSECT_QUAD_LINE_NO = INTERSECT_QUAD_LINE_2 + 1; |
| 324 | var INTERSECT_QUAD = INTERSECT_QUAD_LINE_NO + 1; |
| 325 | var INTERSECT_QUAD_2 = INTERSECT_QUAD + 1; |
| 326 | var INTERSECT_QUAD_NO = INTERSECT_QUAD_2 + 1; |
| 327 | var INTERSECT_SELF_CUBIC = INTERSECT_QUAD_NO + 1; |
| 328 | var INTERSECT_SELF_CUBIC_NO = INTERSECT_SELF_CUBIC + 1; |
| 329 | var INTERSECT_CUBIC_LINE = INTERSECT_SELF_CUBIC_NO + 1; |
| 330 | var INTERSECT_CUBIC_LINE_2 = INTERSECT_CUBIC_LINE + 1; |
| 331 | var INTERSECT_CUBIC_LINE_3 = INTERSECT_CUBIC_LINE_2 + 1; |
| 332 | var INTERSECT_CUBIC_LINE_NO = INTERSECT_CUBIC_LINE_3 + 1; |
| 333 | // FIXME: add cubic/quad |
| 334 | var INTERSECT_CUBIC = INTERSECT_CUBIC_LINE_NO + 1; |
| 335 | var INTERSECT_CUBIC_2 = INTERSECT_CUBIC + 1; |
| 336 | var INTERSECT_CUBIC_3 = INTERSECT_CUBIC_2 + 1; |
| 337 | var INTERSECT_CUBIC_4 = INTERSECT_CUBIC_3 + 1; |
| 338 | // FIXME: add cubic 5- 9 |
| 339 | var INTERSECT_CUBIC_NO = INTERSECT_CUBIC_4 + 1; |
| 340 | |
| 341 | var SORT_LINE = INTERSECT_CUBIC_NO + 1; |
| 342 | var SORT_QUAD = SORT_LINE + 1; |
| 343 | var SORT_CUBIC = SORT_QUAD + 1; |
| 344 | |
| 345 | var REC_TYPE_UNKNOWN = -1; |
| 346 | var REC_TYPE_PATH = 0; |
| 347 | var REC_TYPE_SECT = 1; |
| 348 | var REC_TYPE_ACTIVE = 2; |
| 349 | var REC_TYPE_ADD = 3; |
| 350 | var REC_TYPE_SORT = 4; |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 351 | |
| 352 | function strs_to_nums(strs) { |
| 353 | var result = []; |
| 354 | for (var idx in strs) { |
| 355 | var str = strs[idx]; |
| 356 | var num = parseFloat(str); |
| 357 | if (isNaN(num)) { |
| 358 | result.push(str); |
| 359 | } else { |
| 360 | result.push(num); |
| 361 | } |
| 362 | } |
| 363 | return result; |
| 364 | } |
| 365 | |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 366 | function construct_regexp(pattern) { |
| 367 | var escape = pattern.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'); |
| 368 | escape = escape.replace(/PT_VAL/g, "(\\d+\\.?\\d*),(\\d+\\.?\\d*)"); |
| 369 | escape = escape.replace(/T_VAL/g, "(\\d+\\.?\\d*e?-?\\d*)"); |
| 370 | escape = escape.replace(/IDX/g, "(\\d+)"); |
| 371 | escape = escape.replace(/OPT/g, "(\\?|-?\\d+)"); |
| 372 | return new RegExp(escape, 'i'); |
| 373 | } |
| 374 | |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 375 | function parse_debugShowActiveSpans(test, title) { |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 376 | 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"); |
| 377 | 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"); |
| 378 | 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"); |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 379 | |
| 380 | var strs = test.split("debugShowActiveSpans"); |
| 381 | if (strs.length == 1) |
| 382 | return; |
| 383 | var spans = []; |
| 384 | for (var s in strs) { |
| 385 | var str = strs[s]; |
| 386 | if (str == "\n") { |
| 387 | continue; |
| 388 | } |
| 389 | if (re_line.test(str)) { |
| 390 | var lineStrs = re_line.exec(str); |
| 391 | var line = strs_to_nums(lineStrs); |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 392 | spans.push(ACTIVE_LINE_SPAN); |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 393 | spans.push(line); |
| 394 | } else if (re_quad.test(str)) { |
| 395 | var quadStrs = re_quad.exec(str); |
| 396 | var quad = strs_to_nums(quadStrs); |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 397 | spans.push(ACTIVE_QUAD_SPAN); |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 398 | spans.push(quad); |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 399 | } else if (re_cubic.test(str)) { |
| 400 | var cubicStrs = re_cubic.exec(str); |
| 401 | var cubic = strs_to_nums(cubicStrs); |
| 402 | spans.push(ACTIVE_CUBIC_SPAN); |
| 403 | spans.push(cubic); |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 404 | } |
| 405 | } |
| 406 | if (spans.length >= 1) { |
| 407 | tests.push(spans); |
| 408 | testTitles.push(title); |
| 409 | } |
| 410 | } |
| 411 | |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 412 | function filter_str_by(id, str, regex, array) { |
| 413 | if (regex.test(str)) { |
| 414 | var strs = regex.exec(str); |
| 415 | var result = strs_to_nums(strs); |
| 416 | array.push(id); |
| 417 | array.push(result); |
caryclark@google.com | 4aaaaea | 2013-02-28 16:12:39 +0000 | [diff] [blame^] | 418 | return true; |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 419 | } |
caryclark@google.com | 4aaaaea | 2013-02-28 16:12:39 +0000 | [diff] [blame^] | 420 | return false; |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 421 | } |
| 422 | |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 423 | // FIXME: add cubic support |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 424 | function parse_intersections(test, title) { |
| 425 | 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)"); |
| 426 | 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)"); |
| 427 | var re_quad_line_no_intersect = construct_regexp(" no intersect (PT_VAL PT_VAL PT_VAL) (PT_VAL PT_VAL)"); |
| 428 | 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)"); |
| 429 | 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"); |
| 430 | var re_quad_no_intersect = construct_regexp(" no intersect (PT_VAL PT_VAL PT_VAL) (PT_VAL PT_VAL PT_VAL)"); |
| 431 | |
| 432 | var strs = test.split(/debugShow[A-Za-z]+Intersection/); |
| 433 | if (strs.length == 1) |
| 434 | return; |
| 435 | var spans = []; |
| 436 | for (var s in strs) { |
| 437 | var str = strs[s]; |
| 438 | if (str == "\n") { |
| 439 | continue; |
| 440 | } |
| 441 | filter_str_by(INTERSECT_QUAD_LINE, str, re_quad_line, spans); |
| 442 | filter_str_by(INTERSECT_QUAD_LINE_2, str, re_quad_line_2, spans); |
| 443 | filter_str_by(INTERSECT_QUAD_LINE_NO, str, re_quad_line_no_intersect, spans); |
| 444 | filter_str_by(INTERSECT_QUAD, str, re_quad, spans); |
| 445 | filter_str_by(INTERSECT_QUAD_2, str, re_quad_2, spans); |
| 446 | filter_str_by(INTERSECT_QUAD_NO, str, re_quad_no_intersect, spans); |
| 447 | } |
| 448 | if (spans.length >= 1) { |
| 449 | tests.push(spans); |
| 450 | testTitles.push(title); |
| 451 | } |
| 452 | } |
| 453 | |
caryclark@google.com | 4aaaaea | 2013-02-28 16:12:39 +0000 | [diff] [blame^] | 454 | function construct_regexp2(pattern) { |
| 455 | var escape = pattern.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'); |
| 456 | escape = escape.replace(/CUBIC_VAL/g, "\\(P_VAL P_VAL P_VAL P_VAL\\)"); |
| 457 | escape = escape.replace(/QUAD_VAL/g, "\\(P_VAL P_VAL P_VAL\\)"); |
| 458 | escape = escape.replace(/LINE_VAL/g, "\\(P_VAL P_VAL\\)"); |
| 459 | escape = escape.replace(/PT_VAL/g, "\\(P_VAL\\)"); |
| 460 | escape = escape.replace(/P_VAL/g, "(\\d+\\.?\\d*),(\\d+\\.?\\d*)"); |
| 461 | escape = escape.replace(/T_VAL/g, "(\\d+\\.?\\d*e?-?\\d*)"); |
| 462 | escape = escape.replace(/IDX/g, "(\\d+)"); |
| 463 | escape = escape.replace(/NUM/g, "(-?\\d+)"); |
| 464 | escape = escape.replace(/OPT/g, "(\\?|-?\\d+)"); |
| 465 | return new RegExp(escape, 'i'); |
| 466 | } |
| 467 | |
| 468 | function construct_regexp2c(pattern) { |
| 469 | var escape = pattern.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'); |
| 470 | escape = escape.replace(/CUBIC_VAL/g, "\\{\\{P_VAL\\}, \\{P_VAL\\}, \\{P_VAL\\}, \\{P_VAL\\}\\}"); |
| 471 | escape = escape.replace(/QUAD_VAL/g, "\\{\\{P_VAL\\}, \\{P_VAL\\}, \\{P_VAL\\}\\}"); |
| 472 | escape = escape.replace(/LINE_VAL/g, "\\{\\{P_VAL\\}, \\{P_VAL\\}\\}"); |
| 473 | escape = escape.replace(/PT_VAL/g, "\\{\\{P_VAL\\}\\}"); |
| 474 | escape = escape.replace(/P_VAL/g, "(\\d+\\.?\\d*),(\\d+\\.?\\d*)"); |
| 475 | escape = escape.replace(/T_VAL/g, "(\\d+\\.?\\d*e?-?\\d*)"); |
| 476 | escape = escape.replace(/IDX/g, "(\\d+)"); |
| 477 | escape = escape.replace(/NUM/g, "(-?\\d+)"); |
| 478 | escape = escape.replace(/OPT/g, "(\\?|-?\\d+)"); |
| 479 | return new RegExp(escape, 'i'); |
| 480 | } |
| 481 | |
| 482 | function match_regexp(str, lineNo, array, id, pattern) { |
| 483 | var regex = construct_regexp2(pattern); |
| 484 | if (filter_str_by(id, str, regex, array)) { |
| 485 | return true; |
| 486 | } |
| 487 | regex = construct_regexp2c(pattern); |
| 488 | return filter_str_by(id, str, regex, array); |
| 489 | } |
| 490 | |
| 491 | function parse_all(test, title) { |
| 492 | var lines = test.match(/[^\r\n]+/g); |
| 493 | var records = []; // a rec can be the original paths, a set of intersections, a set of active spans, a sort, or a path add |
| 494 | var record = []; |
| 495 | var recType = REC_TYPE_UNKNOWN; |
| 496 | for (var lineNo in lines) { |
| 497 | var line = lines[lineNo]; |
| 498 | var type = line.lastIndexOf("debugShowSort", 0) === 0 ? REC_TYPE_SORT |
| 499 | : line.lastIndexOf("debugShowActiveSpans", 0) === 0 ? REC_TYPE_ACTIVE |
| 500 | : line.lastIndexOf("debugShow", 0) === 0 ? REC_TYPE_SECT |
| 501 | : line.lastIndexOf("path.", 0) === 0 ? REC_TYPE_ADD |
| 502 | : line.lastIndexOf("{{", 0) === 0 ? REC_TYPE_PATH |
| 503 | : REC_TYPE_UNKNOWN; |
| 504 | if (recType != type) { |
| 505 | if (recType != REC_TYPE_UNKNOWN) { |
| 506 | records.push(recType); |
| 507 | records.push(lineNo); |
| 508 | records.push(record); |
| 509 | } |
| 510 | record = []; |
| 511 | recType = type; |
| 512 | } |
| 513 | var found = false; |
| 514 | switch (recType) { |
| 515 | case REC_TYPE_ACTIVE: |
| 516 | found = match_regexp(line, lineNo, record, ACTIVE_LINE_SPAN, "debugShowActiveSpans" + |
| 517 | " 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" |
| 518 | ) || match_regexp(line, lineNo, record, ACTIVE_QUAD_SPAN, "debugShowActiveSpans" + |
| 519 | " 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" |
| 520 | ) || match_regexp(line, lineNo, record, ACTIVE_CUBIC_SPAN, "debugShowActiveSpans" + |
| 521 | " 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" |
| 522 | ); |
| 523 | break; |
| 524 | case REC_TYPE_ADD: |
| 525 | found = match_regexp(line, lineNo, record, PATH_MOVETO, "path.moveToPT_VAL;" |
| 526 | ) || match_regexp(line, lineNo, record, PATH_LINETO, "path.lineTo(P_VAL);" |
| 527 | ) || match_regexp(line, lineNo, record, PATH_QUADTO, "path.quadTo(P_VAL, P_VAL);" |
| 528 | ) || match_regexp(line, lineNo, record, PATH_CUBICTO, "path.cubicTo(P_VAL, P_VAL, P_VAL);" |
| 529 | ) || match_regexp(line, lineNo, record, PATH_CLOSE, "path.close();" |
| 530 | ); |
| 531 | break; |
| 532 | case REC_TYPE_SECT: |
| 533 | found = match_regexp(line, lineNo, record, INTERSECT_LINE, "debugShowLineIntersection" + |
| 534 | " wtTs[0]=T_VAL LINE_VAL PT_VAL wnTs[0]=T_VAL LINE_VAL" |
| 535 | ) || match_regexp(line, lineNo, record, INTERSECT_LINE_2, "debugShowLineIntersection" + |
| 536 | " wtTs[0]=T_VAL LINE_VAL PT_VAL wtTs[1]=T_VAL PT_VAL wnTs[0]=T_VAL LINE_VAL wnTs[1]=T_VAL" |
| 537 | ) || match_regexp(line, lineNo, record, INTERSECT_LINE_NO, "debugShowLineIntersection" + |
| 538 | " no intersect LINE_VAL LINE_VAL" |
| 539 | ) || match_regexp(line, lineNo, record, INTERSECT_QUAD_LINE, "debugShowQuadLineIntersection" + |
| 540 | " wtTs[0]=T_VAL QUAD_VAL PT_VAL wnTs[0]=T_VAL LINE_VAL" |
| 541 | ) || match_regexp(line, lineNo, record, INTERSECT_QUAD_LINE_2, "debugShowQuadLineIntersection" + |
| 542 | " wtTs[0]=T_VAL QUAD_VAL PT_VAL wtTs[1]=T_VAL PT_VAL wnTs[0]=T_VAL LINE_VAL wnTs[1]=T_VAL" |
| 543 | ) || match_regexp(line, lineNo, record, INTERSECT_QUAD_LINE_NO, "debugShowQuadLineIntersection" + |
| 544 | " no intersect QUAD_VAL LINE_VAL" |
| 545 | ) || match_regexp(line, lineNo, record, INTERSECT_QUAD, "debugShowQuadIntersection" + |
| 546 | " wtTs[0]=T_VAL QUAD_VAL PT_VAL wnTs[0]=T_VAL QUAD_VAL" |
| 547 | ) || match_regexp(line, lineNo, record, INTERSECT_QUAD_2, "debugShowQuadIntersection" + |
| 548 | " wtTs[0]=T_VAL QUAD_VAL PT_VAL wtTs[1]=T_VAL wnTs[0]=T_VAL QUAD_VAL wnTs[1]=T_VAL" |
| 549 | ) || match_regexp(line, lineNo, record, INTERSECT_QUAD_NO, "debugShowQuadIntersection" + |
| 550 | " no intersect QUAD_VAL QUAD_VAL" |
| 551 | ) || match_regexp(line, lineNo, record, INTERSECT_SELF_CUBIC, "debugShowCubicIntersection" + |
| 552 | " wtTs[0]=T_VAL CUBIC_VAL PT_VAL wtTs[1]=T_VAL" |
| 553 | ) || match_regexp(line, lineNo, record, INTERSECT_SELF_CUBIC_NO, "debugShowCubicIntersection" + |
| 554 | " no self intersect CUBIC_VAL" |
| 555 | ) || match_regexp(line, lineNo, record, INTERSECT_CUBIC_LINE, "debugShowCubicLineIntersection" + |
| 556 | " wtTs[0]=T_VAL CUBIC_VAL PT_VAL wnTs[0]=T_VAL LINE_VAL" |
| 557 | ) || match_regexp(line, lineNo, record, INTERSECT_CUBIC_LINE_2, "debugShowCubicLineIntersection" + |
| 558 | " wtTs[0]=T_VAL CUBIC_VAL PT_VAL wtTs[1]=T_VAL PT_VAL wnTs[0]=T_VAL LINE_VAL wnTs[1]=T_VAL" |
| 559 | ) || match_regexp(line, lineNo, record, INTERSECT_CUBIC_LINE_3, "debugShowCubicLineIntersection" + |
| 560 | " 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" |
| 561 | ) || match_regexp(line, lineNo, record, INTERSECT_CUBIC_LINE_NO, "debugShowCubicLineIntersection" + |
| 562 | " no intersect CUBIC_VAL LINE_VAL" |
| 563 | ) || match_regexp(line, lineNo, record, INTERSECT_CUBIC, "debugShowCubicIntersection" + |
| 564 | " wtTs[0]=T_VAL CUBIC_VAL PT_VAL wnTs[0]=T_VAL CUBIC_VAL" |
| 565 | ) || match_regexp(line, lineNo, record, INTERSECT_CUBIC_2, "debugShowCubicIntersection" + |
| 566 | " wtTs[0]=T_VAL CUBIC_VAL PT_VAL wtTs[1]=T_VAL PT_VAL wnTs[0]=T_VAL CUBIC_VAL wnTs[1]=T_VAL" |
| 567 | ) || match_regexp(line, lineNo, record, INTERSECT_CUBIC_3, "debugShowCubicIntersection" + |
| 568 | " 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" |
| 569 | ) || match_regexp(line, lineNo, record, INTERSECT_CUBIC_4, "debugShowCubicIntersection" + |
| 570 | " 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" |
| 571 | ) || match_regexp(line, lineNo, record, INTERSECT_CUBIC_NO, "debugShowCubicIntersection" + |
| 572 | " no intersect CUBIC_VAL CUBIC_VAL" |
| 573 | ); |
| 574 | break; |
| 575 | case REC_TYPE_SORT: |
| 576 | found = match_regexp(line, lineNo, record, SORT_LINE, "debugShowSort" + |
| 577 | " [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" |
| 578 | ) || match_regexp(line, lineNo, record, SORT_QUAD, "debugShowSort" + |
| 579 | " [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" |
| 580 | ) || match_regexp(line, lineNo, record, SORT_CUBIC, "debugShowSort" + |
| 581 | " [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" |
| 582 | ); |
| 583 | break; |
| 584 | case REC_TYPE_UNKNOWN: |
| 585 | found = true; |
| 586 | break; |
| 587 | } |
| 588 | if (!found) { |
| 589 | console.log(line + " [" + lineNo + "] of type " + type + " not found"); |
| 590 | } |
| 591 | } |
| 592 | if (records.length >= 1) { |
| 593 | tests.push(records); |
| 594 | testTitles.push(title); |
| 595 | } |
| 596 | } |
| 597 | |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 598 | function init(test) { |
| 599 | var canvas = document.getElementById('canvas'); |
| 600 | if (!canvas.getContext) return; |
| 601 | screenWidth = canvas.width = window.innerWidth - 20; |
| 602 | screenHeight = canvas.height = window.innerHeight - 20; |
| 603 | ctx = canvas.getContext('2d'); |
| 604 | xmin = Infinity; |
| 605 | var xmax = -Infinity; |
| 606 | ymin = Infinity; |
| 607 | var ymax = -Infinity; |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 608 | var scanType = -1; |
| 609 | for (var scansStr in test) { |
| 610 | var scans = parseInt(scansStr); |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 611 | var scan = test[scans]; |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 612 | if (scanType == -1) { |
| 613 | scanType = scan; |
| 614 | continue; |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 615 | } |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 616 | if (scanType == ACTIVE_LINE_SPAN || scanType == ACTIVE_QUAD_SPAN |
| 617 | || scanType == ACTIVE_CUBIC_SPAN) { |
| 618 | var last = scanType == ACTIVE_CUBIC_SPAN ? SPAN_X4 |
| 619 | : scanType == ACTIVE_QUAD_SPAN ? SPAN_X3 : SPAN_X2; |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 620 | for (var idx = SPAN_X1; idx <= last; idx += 2) { |
| 621 | xmin = Math.min(xmin, scan[idx]); |
| 622 | xmax = Math.max(xmax, scan[idx]); |
| 623 | ymin = Math.min(ymin, scan[idx + 1]); |
| 624 | ymax = Math.max(ymax, scan[idx + 1]); |
| 625 | } |
| 626 | } else { |
| 627 | var start = 1; |
| 628 | if (scanType != INTERSECT_QUAD_LINE_NO && scanType != INTERSECT_QUAD_NO) { |
| 629 | start = 2; |
| 630 | } |
| 631 | for (var idx = start; idx < start + 6; idx += 2) { |
| 632 | xmin = Math.min(xmin, scan[idx]); |
| 633 | xmax = Math.max(xmax, scan[idx]); |
| 634 | ymin = Math.min(ymin, scan[idx + 1]); |
| 635 | ymax = Math.max(ymax, scan[idx + 1]); |
| 636 | } |
| 637 | start = start + 6; |
| 638 | if (scanType == INTERSECT_QUAD_LINE || scanType == INTERSECT_QUAD) { |
| 639 | start += 3; |
| 640 | } |
| 641 | if (scanType == INTERSECT_QUAD_LINE_2) { |
| 642 | start += 6; |
| 643 | } |
| 644 | if (scanType == INTERSECT_QUAD_2) { |
| 645 | start += 4; |
| 646 | } |
| 647 | var end = start + 4; |
| 648 | if (scanType == INTERSECT_QUAD || scanType == INTERSECT_QUAD_2 || scanType == INTERSECT_QUAD_NO) { |
| 649 | end += 2; |
| 650 | } |
| 651 | for (var idx = start; idx < end; idx += 2) { |
| 652 | xmin = Math.min(xmin, scan[idx]); |
| 653 | xmax = Math.max(xmax, scan[idx]); |
| 654 | ymin = Math.min(ymin, scan[idx + 1]); |
| 655 | ymax = Math.max(ymax, scan[idx + 1]); |
| 656 | } |
| 657 | } |
| 658 | scanType = -1; |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 659 | } |
| 660 | srcWidth = xmax - xmin; |
| 661 | srcHeight = ymax - ymin; |
| 662 | var hscale = ctx.canvas.width / srcWidth; |
| 663 | var vscale = ctx.canvas.height / srcHeight; |
| 664 | var minScale = Math.min(hscale, vscale); |
| 665 | scale = minScale; |
| 666 | srcLeft = xmin; |
| 667 | srcTop = ymin; |
| 668 | } |
| 669 | |
| 670 | function drawPoint(px, py) { |
| 671 | for (var pts = 0; pts < drawnPts.length; pts += 2) { |
| 672 | var x = drawnPts[pts]; |
| 673 | var y = drawnPts[pts + 1]; |
| 674 | if (px == x && py == y) { |
| 675 | return; |
| 676 | } |
| 677 | } |
| 678 | drawnPts.push(px); |
| 679 | drawnPts.push(py); |
| 680 | var label = px.toFixed(decimal_places) + ", " + py.toFixed(decimal_places); |
| 681 | var _px = (px - srcLeft)* scale; |
| 682 | var _py = (py - srcTop) * scale; |
| 683 | ctx.beginPath(); |
| 684 | ctx.arc(_px, _py, 3, 0, Math.PI*2, true); |
| 685 | ctx.closePath(); |
| 686 | ctx.fill(); |
| 687 | ctx.fillText(label, _px + 5, _py); |
| 688 | } |
| 689 | |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 690 | function drawLine(x1, y1, x2, y2, selected) { |
| 691 | for (var pts = 0; pts < drawnLines.length; pts += 4) { |
| 692 | if (x1 == drawnLines[pts] && y1 == drawnLines[pts + 1]) { |
| 693 | return; |
| 694 | } |
| 695 | if (x2 == drawnLines[pts + 2] && x2 == drawnLines[pts + 3]) { |
| 696 | return; |
| 697 | } |
| 698 | } |
| 699 | if (selected) { |
| 700 | drawnLines.push(x1); |
| 701 | drawnLines.push(y1); |
| 702 | drawnLines.push(x2); |
| 703 | drawnLines.push(y2); |
| 704 | ctx.beginPath(); |
| 705 | ctx.moveTo((x1 - srcLeft) * scale, |
| 706 | (y1 - srcTop) * scale); |
| 707 | ctx.lineTo((x2 - srcLeft) * scale, |
| 708 | (y2 - srcTop) * scale); |
| 709 | ctx.stroke(); |
| 710 | return; |
| 711 | } |
| 712 | deferredLines.push(x1); |
| 713 | deferredLines.push(y1); |
| 714 | deferredLines.push(x2); |
| 715 | deferredLines.push(y2); |
| 716 | } |
| 717 | |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 718 | function drawLinePartial(x1, y1, x2, y2, t1, t2) { |
| 719 | var dx = x1 - x2; |
| 720 | var dy = y1 - y2; |
| 721 | var ax = x1 - t1 * dx; |
| 722 | var ay = y1 - t1 * dy; |
| 723 | var bx = x1 - t2 * dx; |
| 724 | var by = y1 - t2 * dy; |
| 725 | ctx.beginPath(); |
| 726 | ctx.moveTo((ax - srcLeft) * scale, |
| 727 | (ay - srcTop) * scale); |
| 728 | ctx.lineTo((bx - srcLeft) * scale, |
| 729 | (by - srcTop) * scale); |
| 730 | ctx.stroke(); |
| 731 | } |
| 732 | |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 733 | function drawQuad(x1, y1, x2, y2, x3, y3, selected) { |
| 734 | for (var pts = 0; pts < drawnQuads.length; pts += 6) { |
| 735 | if (x1 == drawnQuads[pts] && y1 == drawnQuads[pts + 1]) { |
| 736 | return; |
| 737 | } |
| 738 | if (x2 == drawnQuads[pts + 2] && x2 == drawnQuads[pts + 3]) { |
| 739 | return; |
| 740 | } |
| 741 | if (x2 == drawnQuads[pts + 4] && x2 == drawnQuads[pts + 5]) { |
| 742 | return; |
| 743 | } |
| 744 | } |
| 745 | if (selected) { |
| 746 | drawnQuads.push(x1); |
| 747 | drawnQuads.push(y1); |
| 748 | drawnQuads.push(x2); |
| 749 | drawnQuads.push(y2); |
| 750 | drawnQuads.push(x3); |
| 751 | drawnQuads.push(y3); |
| 752 | ctx.beginPath(); |
| 753 | ctx.moveTo((x1 - srcLeft) * scale, |
| 754 | (y1 - srcTop) * scale); |
| 755 | ctx.quadraticCurveTo((x2 - srcLeft) * scale, |
| 756 | (y2 - srcTop) * scale, |
| 757 | (x3 - srcLeft) * scale, |
| 758 | (y3 - srcTop) * scale); |
| 759 | ctx.stroke(); |
| 760 | return; |
| 761 | } |
| 762 | deferredQuads.push(x1); |
| 763 | deferredQuads.push(y1); |
| 764 | deferredQuads.push(x2); |
| 765 | deferredQuads.push(y2); |
| 766 | deferredQuads.push(x3); |
| 767 | deferredQuads.push(y3); |
| 768 | } |
| 769 | |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 770 | function interp(A, B, t) { |
| 771 | return A + (B - A) * t; |
| 772 | } |
| 773 | |
| 774 | function interp_quad_coords(x1, x2, x3, t) |
| 775 | { |
| 776 | var ab = interp(x1, x2, t); |
| 777 | var bc = interp(x2, x3, t); |
| 778 | var abc = interp(ab, bc, t); |
| 779 | return abc; |
| 780 | } |
| 781 | |
| 782 | function drawQuadPartial(x1, y1, x2, y2, x3, y3, t1, t2) { |
| 783 | var ax = interp_quad_coords(x1, x2, x3, t1); |
| 784 | var ay = interp_quad_coords(y1, y2, y3, t1); |
| 785 | var dx = interp_quad_coords(x1, x2, x3, (t1 + t2) / 2); |
| 786 | var dy = interp_quad_coords(y1, y2, y3, (t1 + t2) / 2); |
| 787 | var cx = interp_quad_coords(x1, x2, x3, t2); |
| 788 | var cy = interp_quad_coords(y1, y2, y3, t2); |
| 789 | var bx = 2*dx - (ax + cx)/2; |
| 790 | var by = 2*dy - (ay + cy)/2; |
| 791 | ctx.beginPath(); |
| 792 | ctx.moveTo((ax - srcLeft) * scale, |
| 793 | (ay - srcTop) * scale); |
| 794 | ctx.quadraticCurveTo((bx - srcLeft) * scale, |
| 795 | (by - srcTop) * scale, |
| 796 | (cx - srcLeft) * scale, |
| 797 | (cy - srcTop) * scale); |
| 798 | ctx.stroke(); |
| 799 | } |
| 800 | |
| 801 | function drawCubic(x1, y1, x2, y2, x3, y3, x4, y4, selected) { |
| 802 | for (var pts = 0; pts < drawnCubics.length; pts += 8) { |
| 803 | if (x1 == drawnCubics[pts] && y1 == drawnCubics[pts + 1]) { |
| 804 | return; |
| 805 | } |
| 806 | if (x2 == drawnCubics[pts + 2] && x2 == drawnCubics[pts + 3]) { |
| 807 | return; |
| 808 | } |
| 809 | if (x2 == drawnCubics[pts + 4] && x2 == drawnCubics[pts + 5]) { |
| 810 | return; |
| 811 | } |
| 812 | if (x2 == drawnCubics[pts + 6] && x2 == drawnCubics[pts + 7]) { |
| 813 | return; |
| 814 | } |
| 815 | } |
| 816 | if (selected) { |
| 817 | drawnCubics.push(x1); |
| 818 | drawnCubics.push(y1); |
| 819 | drawnCubics.push(x2); |
| 820 | drawnCubics.push(y2); |
| 821 | drawnCubics.push(x3); |
| 822 | drawnCubics.push(y3); |
| 823 | drawnCubics.push(x4); |
| 824 | drawnCubics.push(y4); |
| 825 | ctx.beginPath(); |
| 826 | ctx.moveTo((x1 - srcLeft) * scale, |
| 827 | (y1 - srcTop) * scale); |
| 828 | ctx.bezierCurveTo((x2 - srcLeft) * scale, |
| 829 | (y2 - srcTop) * scale, |
| 830 | (x3 - srcLeft) * scale, |
| 831 | (y3 - srcTop) * scale, |
| 832 | (x4 - srcLeft) * scale, |
| 833 | (y4 - srcTop) * scale); |
| 834 | ctx.stroke(); |
| 835 | return; |
| 836 | } |
| 837 | deferredCubics.push(x1); |
| 838 | deferredCubics.push(y1); |
| 839 | deferredCubics.push(x2); |
| 840 | deferredCubics.push(y2); |
| 841 | deferredCubics.push(x3); |
| 842 | deferredCubics.push(y3); |
| 843 | deferredCubics.push(x4); |
| 844 | deferredCubics.push(y4); |
| 845 | } |
| 846 | |
| 847 | function interp_cubic_coords(x1, x2, x3, x4, t) |
| 848 | { |
| 849 | var ab = interp(x1, x2, t); |
| 850 | var bc = interp(x2, x3, t); |
| 851 | var cd = interp(x3, x4, t); |
| 852 | var abc = interp(ab, bc, t); |
| 853 | var bcd = interp(bc, cd, t); |
| 854 | var abcd = interp(abc, bcd, t); |
| 855 | return abcd; |
| 856 | } |
| 857 | |
| 858 | function drawCubicPartial(x1, y1, x2, y2, x3, y3, x4, y4, t1, t2) { |
| 859 | var ax = interp_cubic_coords(x1, x2, x3, x4, t1); |
| 860 | var ay = interp_cubic_coords(y1, y2, y3, y4, t1); |
| 861 | var ex = interp_cubic_coords(x1, x2, x3, x4, (t1*2+t2)/3); |
| 862 | var ey = interp_cubic_coords(y1, y2, y3, y4, (t1*2+t2)/3); |
| 863 | var fx = interp_cubic_coords(x1, x2, x3, x4, (t1+t2*2)/3); |
| 864 | var fy = interp_cubic_coords(y1, y2, y3, y4, (t1+t2*2)/3); |
| 865 | var dx = interp_cubic_coords(x1, x2, x3, x4, t2); |
| 866 | var dy = interp_cubic_coords(y1, y2, y3, y4, t2); |
| 867 | var mx = ex * 27 - ax * 8 - dx; |
| 868 | var my = ey * 27 - ay * 8 - dy; |
| 869 | var nx = fx * 27 - ax - dx * 8; |
| 870 | var ny = fy * 27 - ay - dy * 8; |
| 871 | var bx = (mx * 2 - nx) / 18; |
| 872 | var by = (my * 2 - ny) / 18; |
| 873 | var cx = (nx * 2 - mx) / 18; |
| 874 | var cy = (ny * 2 - my) / 18; |
| 875 | ctx.beginPath(); |
| 876 | ctx.moveTo((ax - srcLeft) * scale, |
| 877 | (ay - srcTop) * scale); |
| 878 | ctx.bezierCurveTo((bx - srcLeft) * scale, |
| 879 | (by - srcTop) * scale, |
| 880 | (cx - srcLeft) * scale, |
| 881 | (cy - srcTop) * scale, |
| 882 | (dx - srcLeft) * scale, |
| 883 | (dy - srcTop) * scale, |
| 884 | (ex - srcLeft) * scale, |
| 885 | (ey - srcTop) * scale); |
| 886 | ctx.stroke(); |
| 887 | } |
| 888 | |
| 889 | function drawPartial(test) { |
| 890 | ctx.lineWidth = 3; |
| 891 | ctx.strokeStyle = "rgba(0,0,255, 0.3)"; |
| 892 | var scanType = -1; |
| 893 | var partIndex = 0; |
| 894 | for (var scansStr in test) { |
| 895 | var scans = parseInt(scansStr); |
| 896 | var scan = test[scans]; |
| 897 | if (scanType == -1) { |
| 898 | scanType = scan; |
| 899 | continue; |
| 900 | } |
| 901 | partIndex++; |
| 902 | var hasId = scanType == ACTIVE_LINE_SPAN || scanType == ACTIVE_QUAD_SPAN |
| 903 | || scanType == ACTIVE_CUBIC_SPAN ? SPAN_ID : -1; |
| 904 | if (hasId < 0) { |
| 905 | continue; |
| 906 | } |
| 907 | var types = [scanType == ACTIVE_LINE_SPAN ? 0 : scanType == ACTIVE_QUAD_SPAN ? 1 : 2]; |
| 908 | var x1 = scan[SPAN_X1]; |
| 909 | var y1 = scan[SPAN_Y1]; |
| 910 | var x2 = scan[SPAN_X2]; |
| 911 | var y2 = scan[SPAN_Y2]; |
| 912 | var x3, y3, x3, y4, t1, t2; |
| 913 | switch(scanType) { |
| 914 | case ACTIVE_LINE_SPAN: |
| 915 | t1 = scan[SPAN_L_T]; |
| 916 | t2 = scan[SPAN_L_TEND]; |
| 917 | drawLinePartial(x1, y1, x2, y2, t1, t2); |
| 918 | break; |
| 919 | case ACTIVE_QUAD_SPAN: |
| 920 | x3 = scan[SPAN_X3]; |
| 921 | y3 = scan[SPAN_Y3]; |
| 922 | t1 = scan[SPAN_Q_T]; |
| 923 | t2 = scan[SPAN_Q_TEND]; |
| 924 | drawQuadPartial(x1, y1, x2, y2, x3, y3, t1, t2); |
| 925 | break; |
| 926 | case ACTIVE_CUBIC_SPAN: |
| 927 | x3 = scan[SPAN_X3]; |
| 928 | y3 = scan[SPAN_Y3]; |
| 929 | x4 = scan[SPAN_X4]; |
| 930 | y4 = scan[SPAN_Y4]; |
| 931 | t1 = scan[SPAN_C_T]; |
| 932 | t2 = scan[SPAN_C_TEND]; |
| 933 | drawCubicPartial(x1, y1, x2, y2, x3, y3, x4, y4, t1, t2); |
| 934 | break; |
| 935 | } |
| 936 | scanType = -1; |
| 937 | } |
| 938 | } |
| 939 | |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 940 | function drawDeferred() { |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 941 | for (var pts = 0; pts < deferredCubics.length; pts += 8) { |
| 942 | drawCubic(deferredCubics[pts], deferredCubics[pts + 1], |
| 943 | deferredCubics[pts + 2], deferredCubics[pts + 3], |
| 944 | deferredCubics[pts + 4], deferredCubics[pts + 5], |
| 945 | deferredCubics[pts + 6], deferredCubics[pts + 7], true); |
| 946 | } |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 947 | for (var pts = 0; pts < deferredQuads.length; pts += 6) { |
| 948 | drawQuad(deferredQuads[pts], deferredQuads[pts + 1], |
| 949 | deferredQuads[pts + 2], deferredQuads[pts + 3], |
| 950 | deferredQuads[pts + 4], deferredQuads[pts + 5], true); |
| 951 | } |
| 952 | for (var pts = 0; pts < deferredLines.length; pts += 4) { |
| 953 | drawLine(deferredLines[pts], deferredLines[pts + 1], |
| 954 | deferredLines[pts + 2], deferredLines[pts + 3], true); |
| 955 | } |
| 956 | } |
| 957 | |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 958 | function draw(test, title) { |
| 959 | ctx.fillStyle = "rgba(0,0,0, 0.1)"; |
| 960 | ctx.font = "normal 50px Arial"; |
| 961 | ctx.fillText(title, 50, 50); |
| 962 | ctx.font = "normal 10px Arial"; |
| 963 | ctx.lineWidth = "1.001"; "0.999"; |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 964 | var curId = -1; |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 965 | var firstIdx; |
| 966 | var lastIdx; |
| 967 | var index_tst = -1; |
| 968 | drawnPts = []; |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 969 | drawnLines = []; |
| 970 | drawnQuads = []; |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 971 | drawnCubics = []; |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 972 | deferredLines = []; |
| 973 | deferredQuads = []; |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 974 | deferredCubics = []; |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 975 | var scanType = -1; |
| 976 | var partIndex = 0; |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 977 | for (var scansStr in test) { |
| 978 | var scans = parseInt(scansStr); |
| 979 | var scan = test[scans]; |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 980 | if (scanType == -1) { |
| 981 | scanType = scan; |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 982 | continue; |
| 983 | } |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 984 | partIndex++; |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 985 | var hasId = scanType == ACTIVE_LINE_SPAN || scanType == ACTIVE_QUAD_SPAN |
| 986 | || scanType == ACTIVE_CUBIC_SPAN ? SPAN_ID : -1; |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 987 | if (hasId >= 0 && curId != scan[hasId]) { |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 988 | curId = scan[hasId]; |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 989 | firstIdx = lastIdx = partIndex; |
| 990 | index_tst++; |
| 991 | var nextIdx = lastIdx + 1; |
| 992 | while (nextIdx * 2 < test.length && test[nextIdx * 2][hasId] == curId) { |
| 993 | lastIdx = nextIdx++; |
| 994 | } |
| 995 | } else if (hasId < 0) { |
| 996 | firstIdx = lastIdx = partIndex; |
| 997 | index_tst++; |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 998 | } |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 999 | var seq = sequence % (test.length / 2); |
| 1000 | var selected = sequence >= 0 ? seq == partIndex |
| 1001 | : (index_bits & (1 << index_tst)) != 0 && partIndex == firstIdx; |
| 1002 | var skippable = (sequence >= 0 && seq >= firstIdx && seq <= lastIdx) |
| 1003 | || partIndex != firstIdx; |
| 1004 | if (skippable && !selected) { |
| 1005 | scanType = -1; |
| 1006 | continue; |
| 1007 | } |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 1008 | var types = [scanType == ACTIVE_LINE_SPAN ? 0 : scanType == ACTIVE_QUAD_SPAN ? 1 : 2]; |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 1009 | var pts = []; |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 1010 | if (scanType == ACTIVE_LINE_SPAN || scanType == ACTIVE_QUAD_SPAN || scanType == ACTIVE_CUBIC_SPAN) { |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 1011 | pts.push(SPAN_X1); |
| 1012 | } else { |
| 1013 | pts.push(scanType != INTERSECT_QUAD_NO && scanType != INTERSECT_QUAD_LINE_NO ? 2 : 1); |
| 1014 | types.push(scanType == INTERSECT_QUAD_NO || scanType == INTERSECT_QUAD || scanType == INTERSECT_QUAD_2 ? 1 : 0); |
| 1015 | pts.push(scanType == INTERSECT_QUAD_LINE || scanType == INTERSECT_QUAD ? 11 |
| 1016 | : scanType == INTERSECT_QUAD_LINE_2 ? 14 : scanType == INTERSECT_QUAD_2 ? 12 : 7); |
| 1017 | } |
| 1018 | ctx.strokeStyle = "red"; |
| 1019 | for (var typeIndex = 0; typeIndex < types.length; ++typeIndex) { |
| 1020 | var type = types[typeIndex]; |
| 1021 | var index = pts[typeIndex]; |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 1022 | if (type == 2) { |
| 1023 | drawCubic(scan[index + 0], scan[index + 1], scan[index + 2], scan[index + 3], |
| 1024 | scan[index + 4], scan[index + 5], scan[index + 6], scan[index + 7], |
| 1025 | selected); |
| 1026 | } else if (type == 1) { |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 1027 | drawQuad(scan[index + 0], scan[index + 1], scan[index + 2], scan[index + 3], |
| 1028 | scan[index + 4], scan[index + 5], selected); |
| 1029 | } else { |
| 1030 | drawLine(scan[index + 0], scan[index + 1], scan[index + 2], scan[index + 3], |
| 1031 | selected); |
| 1032 | } |
| 1033 | } |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 1034 | if (debug_xy && selected) { |
| 1035 | var debugText = ""; |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 1036 | for (var typeIndex = 0; typeIndex < types.length; ++typeIndex) { |
| 1037 | var type = types[typeIndex]; |
| 1038 | var index = pts[typeIndex]; |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 1039 | for (var idx = pts[typeIndex]; idx < pts[typeIndex] + (type + 1) * 2; idx += 2) { |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 1040 | var screenX = (scan[idx] - srcLeft) * scale; |
| 1041 | var screenY = (scan[idx + 1] - srcTop) * scale; |
| 1042 | debugText += screenX.toFixed(decimal_places) + ", "; |
| 1043 | debugText += screenY.toFixed(decimal_places) + " "; |
| 1044 | } |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 1045 | } |
| 1046 | ctx.fillStyle="blue"; |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 1047 | ctx.fillText(debugText, 50, partIndex * 50 + 100); |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 1048 | } |
| 1049 | if (ptLabels && selected) { |
| 1050 | ctx.fillStyle="blue"; |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 1051 | for (var typeIndex = 0; typeIndex < types.length; ++typeIndex) { |
| 1052 | var type = types[typeIndex]; |
| 1053 | var index = pts[typeIndex]; |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 1054 | for (var idx = pts[typeIndex]; idx < pts[typeIndex] + (type + 1) * 2; idx += 2) { |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 1055 | drawPoint(scan[idx], scan[idx + 1]); |
| 1056 | } |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 1057 | } |
| 1058 | } |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 1059 | var infoText = ""; |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 1060 | if (info_mode && selected) { |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 1061 | infoText += hasId >= 0 ? "id=" + scan[hasId] : partIndex; |
| 1062 | } |
| 1063 | if (intersect_mode && selected) { |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 1064 | if (scanType == ACTIVE_CUBIC_SPAN) { |
| 1065 | infoText += " t=" + scan[SPAN_C_T]; |
| 1066 | } else if (scanType == ACTIVE_QUAD_SPAN) { |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 1067 | infoText += " t=" + scan[SPAN_Q_T]; |
| 1068 | } else if (scanType == ACTIVE_LINE_SPAN) { |
| 1069 | infoText += " t=" + scan[SPAN_L_T]; |
| 1070 | } else if (scanType == INTERSECT_QUAD_LINE ||scanType == INTERSECT_QUAD) { |
| 1071 | infoText += " t0[0]=" + scan[1] + " t1[0]=" + scan[10]; |
| 1072 | } else if (scanType == INTERSECT_QUAD_LINE_2 || scanType == INTERSECT_QUAD_2) { |
| 1073 | infoText += " t0[0]=" + scan[1] + " t0[1]=" + scan[10] + " t1[0]=" + scan[13]; |
| 1074 | if (scanType == INTERSECT_QUAD_LINE_2) { |
| 1075 | infoText += " t1[1]=" + scan[18]; |
| 1076 | } else { |
| 1077 | infoText += " t0[1]=" + scan[20]; |
| 1078 | } |
| 1079 | } |
| 1080 | } |
| 1081 | if (infoText.length > 0) { |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 1082 | ctx.fillStyle="green"; |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 1083 | ctx.fillText(infoText, 10, (hasId >= 0 && sequence >= 0 |
| 1084 | ? hasId : partIndex) * 30 + 50); |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 1085 | } |
| 1086 | if (intersect_mode && selected) { |
| 1087 | ctx.fillStyle="rgba(50,100,200, 1.0)"; |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 1088 | if (scanType == ACTIVE_CUBIC_SPAN) { |
| 1089 | drawPoint(scan[SPAN_C_TX], scan[SPAN_C_TY]); |
| 1090 | } else if (scanType == ACTIVE_QUAD_SPAN) { |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 1091 | drawPoint(scan[SPAN_Q_TX], scan[SPAN_Q_TY]); |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 1092 | } else if (scanType == ACTIVE_LINE_SPAN) { |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 1093 | drawPoint(scan[SPAN_L_TX], scan[SPAN_L_TY]); |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 1094 | } else if (scanType != INTERSECT_QUAD_NO && scanType != INTERSECT_QUAD_LINE_NO) { |
| 1095 | drawPoint(scan[8], scan[9]); |
| 1096 | if (scanType == INTERSECT_QUAD_LINE_2 || scanType == INTERSECT_QUAD_2) { |
| 1097 | drawPoint(scan[11], scan[12]); |
| 1098 | } |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 1099 | } |
| 1100 | } |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 1101 | ctx.strokeStyle = "rgba(0,0,0, 0.2)"; |
| 1102 | scanType = -1; |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 1103 | } |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 1104 | drawDeferred(); |
caryclark@google.com | 47d73da | 2013-02-17 01:41:25 +0000 | [diff] [blame] | 1105 | drawPartial(test); |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 1106 | } |
| 1107 | |
| 1108 | function drawTop() { |
| 1109 | init(tests[testIndex]); |
| 1110 | redraw(); |
| 1111 | } |
| 1112 | |
| 1113 | function redraw() { |
| 1114 | ctx.beginPath(); |
| 1115 | ctx.rect(0, 0, ctx.canvas.width, ctx.canvas.height); |
| 1116 | ctx.fillStyle="white"; |
| 1117 | ctx.fill(); |
| 1118 | draw(tests[testIndex], testTitles[testIndex]); |
| 1119 | } |
| 1120 | |
| 1121 | function doKeyPress(evt) { |
| 1122 | var char = String.fromCharCode(evt.charCode); |
| 1123 | switch (char) { |
| 1124 | case '0': |
| 1125 | case '1': |
| 1126 | case '2': |
| 1127 | case '3': |
| 1128 | case '4': |
| 1129 | case '5': |
| 1130 | case '6': |
| 1131 | case '7': |
| 1132 | case '8': |
| 1133 | case '9': |
| 1134 | if (digit_mode) { |
| 1135 | decimal_places = char - '0'; |
| 1136 | } else if (index_mode) { |
| 1137 | index_bits ^= 1 << (char - '0'); |
| 1138 | } |
| 1139 | redraw(); |
| 1140 | break; |
| 1141 | case 'd': |
| 1142 | digit_mode = true; |
| 1143 | index_mode = false; |
| 1144 | break; |
| 1145 | case 'f': |
| 1146 | info_mode ^= true; |
| 1147 | redraw(); |
| 1148 | break; |
| 1149 | case 'i': |
| 1150 | digit_mode = false; |
| 1151 | if (sequence >= 0) { |
| 1152 | sequence = -1; |
| 1153 | index_mode = false; |
| 1154 | } else { |
| 1155 | index_mode ^= true; |
| 1156 | } |
| 1157 | if (index_mode) { |
| 1158 | index_bits = 0; |
| 1159 | } else { |
| 1160 | index_bits = -1; |
| 1161 | } |
| 1162 | redraw(); |
| 1163 | break; |
| 1164 | case 'N': |
| 1165 | testIndex += 9; |
| 1166 | case 'n': |
| 1167 | if (++testIndex >= tests.length) |
| 1168 | testIndex = 0; |
| 1169 | drawTop(); |
| 1170 | break; |
| 1171 | case 'P': |
| 1172 | testIndex -= 9; |
| 1173 | case 'p': |
| 1174 | if (--testIndex < 0) |
| 1175 | testIndex = tests.length - 1; |
| 1176 | drawTop(); |
| 1177 | break; |
| 1178 | case 's': |
| 1179 | sequence++; |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 1180 | redraw(); |
| 1181 | break; |
| 1182 | case 'S': |
| 1183 | sequence--; |
| 1184 | if (sequence < 0) { |
| 1185 | sequence = 0; |
| 1186 | } |
| 1187 | redraw(); |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 1188 | break; |
| 1189 | case 't': |
| 1190 | intersect_mode ^= true; |
| 1191 | redraw(); |
| 1192 | break; |
| 1193 | case 'x': |
| 1194 | ptLabels ^= true; |
| 1195 | redraw(); |
| 1196 | break; |
| 1197 | case 'y': |
| 1198 | debug_xy ^= true; |
| 1199 | redraw(); |
| 1200 | break; |
| 1201 | case '-': |
| 1202 | scale /= 2; |
| 1203 | calcLeftTop(); |
| 1204 | redraw(); |
| 1205 | break; |
| 1206 | case '=': |
| 1207 | case '+': |
| 1208 | scale *= 2; |
| 1209 | calcLeftTop(); |
| 1210 | redraw(); |
| 1211 | break; |
| 1212 | } |
| 1213 | } |
| 1214 | |
| 1215 | function calcXY() { |
| 1216 | var e = window.event; |
| 1217 | var tgt = e.target || e.srcElement; |
| 1218 | var left = tgt.offsetLeft; |
| 1219 | var top = tgt.offsetTop; |
| 1220 | var unit = scale; |
| 1221 | mouseX = (e.clientX - left) / scale + srcLeft; |
| 1222 | mouseY = (e.clientY - top) / scale + srcTop; |
| 1223 | } |
| 1224 | |
| 1225 | function calcLeftTop() { |
| 1226 | srcLeft = mouseX - screenWidth / 2 / scale; |
| 1227 | srcTop = mouseY - screenHeight / 2 / scale; |
| 1228 | } |
| 1229 | |
| 1230 | function handleMouseClick() { |
| 1231 | calcXY(); |
| 1232 | calcLeftTop(); |
| 1233 | redraw(); |
| 1234 | } |
| 1235 | |
| 1236 | function handleMouseOver() { |
| 1237 | calcXY(); |
| 1238 | var num = mouseX.toFixed(decimal_places) + ", " + mouseY.toFixed(decimal_places); |
| 1239 | ctx.beginPath(); |
| 1240 | ctx.rect(300,100,200,10); |
| 1241 | ctx.fillStyle="white"; |
| 1242 | ctx.fill(); |
| 1243 | ctx.fillStyle="black"; |
| 1244 | ctx.fillText(num, 300, 108); |
| 1245 | } |
| 1246 | |
| 1247 | function start() { |
| 1248 | for (i = 0; i < testDivs.length; ++i) { |
| 1249 | var title = testDivs[i].id.toString(); |
| 1250 | var str = testDivs[i].firstChild.data; |
caryclark@google.com | 4aaaaea | 2013-02-28 16:12:39 +0000 | [diff] [blame^] | 1251 | parse_all(str, title); |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 1252 | parse_debugShowActiveSpans(str, title); |
caryclark@google.com | 0b7da43 | 2012-10-31 19:00:20 +0000 | [diff] [blame] | 1253 | parse_intersections(str, title); |
caryclark@google.com | f839c03 | 2012-10-26 21:03:50 +0000 | [diff] [blame] | 1254 | } |
| 1255 | drawTop(); |
| 1256 | window.addEventListener('keypress', doKeyPress, true); |
| 1257 | window.onresize = function() { |
| 1258 | drawTop(); |
| 1259 | } |
| 1260 | } |
| 1261 | |
| 1262 | </script> |
| 1263 | </head> |
| 1264 | |
| 1265 | <body onLoad="start();"> |
| 1266 | <canvas id="canvas" width="750" height="500" |
| 1267 | onmousemove="handleMouseOver()" |
| 1268 | onclick="handleMouseClick()" |
| 1269 | ></canvas > |
| 1270 | </body> |
| 1271 | </html> |