| OLD | NEW |
| 1 description("Test the behavior of isPointInStroke in Canvas with path object"); | 1 description("Test the behavior of isPointInStroke in Canvas with path object"); |
| 2 var ctx = document.createElement('canvas').getContext('2d'); | 2 var ctx = document.createElement('canvas').getContext('2d'); |
| 3 | 3 |
| 4 document.body.appendChild(ctx.canvas); | 4 document.body.appendChild(ctx.canvas); |
| 5 | 5 |
| 6 ctx.strokeStyle = '#0ff'; | 6 ctx.strokeStyle = '#0ff'; |
| 7 | 7 |
| 8 // Create new path. | 8 // Create new path. |
| 9 var path = new Path(); | 9 var path = new Path2D(); |
| 10 path.rect(20,20,100,100); | 10 path.rect(20,20,100,100); |
| 11 | 11 |
| 12 debug("Initial behavior: lineWidth = 1.0") | 12 debug("Initial behavior: lineWidth = 1.0") |
| 13 shouldBeTrue("ctx.isPointInStroke(path,20,20)"); | 13 shouldBeTrue("ctx.isPointInStroke(path,20,20)"); |
| 14 shouldBeTrue("ctx.isPointInStroke(path,120,20)"); | 14 shouldBeTrue("ctx.isPointInStroke(path,120,20)"); |
| 15 shouldBeTrue("ctx.isPointInStroke(path,20,120)"); | 15 shouldBeTrue("ctx.isPointInStroke(path,20,120)"); |
| 16 shouldBeTrue("ctx.isPointInStroke(path,120,120)"); | 16 shouldBeTrue("ctx.isPointInStroke(path,120,120)"); |
| 17 shouldBeTrue("ctx.isPointInStroke(path,70,20)"); | 17 shouldBeTrue("ctx.isPointInStroke(path,70,20)"); |
| 18 shouldBeTrue("ctx.isPointInStroke(path,20,70)"); | 18 shouldBeTrue("ctx.isPointInStroke(path,20,70)"); |
| 19 shouldBeTrue("ctx.isPointInStroke(path,120,70)"); | 19 shouldBeTrue("ctx.isPointInStroke(path,120,70)"); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 46 shouldBeTrue("ctx.isPointInStroke(path,122,70)"); | 46 shouldBeTrue("ctx.isPointInStroke(path,122,70)"); |
| 47 shouldBeTrue("ctx.isPointInStroke(path,70,122)"); | 47 shouldBeTrue("ctx.isPointInStroke(path,70,122)"); |
| 48 shouldBeTrue("ctx.isPointInStroke(path,18,70)"); | 48 shouldBeTrue("ctx.isPointInStroke(path,18,70)"); |
| 49 shouldBeFalse("ctx.isPointInStroke(path,26,70)"); | 49 shouldBeFalse("ctx.isPointInStroke(path,26,70)"); |
| 50 shouldBeFalse("ctx.isPointInStroke(path,70,26)"); | 50 shouldBeFalse("ctx.isPointInStroke(path,70,26)"); |
| 51 shouldBeFalse("ctx.isPointInStroke(path,70,114)"); | 51 shouldBeFalse("ctx.isPointInStroke(path,70,114)"); |
| 52 shouldBeFalse("ctx.isPointInStroke(path,114,70)"); | 52 shouldBeFalse("ctx.isPointInStroke(path,114,70)"); |
| 53 debug(""); | 53 debug(""); |
| 54 | 54 |
| 55 debug("Check lineJoin = 'bevel'"); | 55 debug("Check lineJoin = 'bevel'"); |
| 56 path = new Path(); | 56 path = new Path2D(); |
| 57 path.moveTo(10,10); | 57 path.moveTo(10,10); |
| 58 path.lineTo(110,20); | 58 path.lineTo(110,20); |
| 59 path.lineTo(10,30); | 59 path.lineTo(10,30); |
| 60 ctx.lineJoin = "bevel"; | 60 ctx.lineJoin = "bevel"; |
| 61 shouldBeFalse("ctx.isPointInStroke(path,113,20)"); | 61 shouldBeFalse("ctx.isPointInStroke(path,113,20)"); |
| 62 debug(""); | 62 debug(""); |
| 63 | 63 |
| 64 debug("Check lineJoin = 'miter'"); | 64 debug("Check lineJoin = 'miter'"); |
| 65 ctx.miterLimit = 40.0; | 65 ctx.miterLimit = 40.0; |
| 66 ctx.lineJoin = "miter"; | 66 ctx.lineJoin = "miter"; |
| 67 shouldBeTrue("ctx.isPointInStroke(path,113,20)"); | 67 shouldBeTrue("ctx.isPointInStroke(path,113,20)"); |
| 68 debug(""); | 68 debug(""); |
| 69 | 69 |
| 70 debug("Check miterLimit = 2.0"); | 70 debug("Check miterLimit = 2.0"); |
| 71 ctx.miterLimit = 2.0; | 71 ctx.miterLimit = 2.0; |
| 72 shouldBeFalse("ctx.isPointInStroke(path,113,20)"); | 72 shouldBeFalse("ctx.isPointInStroke(path,113,20)"); |
| 73 debug(""); | 73 debug(""); |
| 74 | 74 |
| 75 debug("Check lineCap = 'butt'"); | 75 debug("Check lineCap = 'butt'"); |
| 76 path = new Path(); | 76 path = new Path2D(); |
| 77 path.moveTo(10,10); | 77 path.moveTo(10,10); |
| 78 path.lineTo(110,10); | 78 path.lineTo(110,10); |
| 79 ctx.lineCap = "butt"; | 79 ctx.lineCap = "butt"; |
| 80 shouldBeFalse("ctx.isPointInStroke(path,112,10)"); | 80 shouldBeFalse("ctx.isPointInStroke(path,112,10)"); |
| 81 debug(""); | 81 debug(""); |
| 82 | 82 |
| 83 debug("Check lineCap = 'round'"); | 83 debug("Check lineCap = 'round'"); |
| 84 ctx.lineCap = "round"; | 84 ctx.lineCap = "round"; |
| 85 shouldBeTrue("ctx.isPointInStroke(path,112,10)"); | 85 shouldBeTrue("ctx.isPointInStroke(path,112,10)"); |
| 86 shouldBeFalse("ctx.isPointInStroke(path,117,10)"); | 86 shouldBeFalse("ctx.isPointInStroke(path,117,10)"); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 98 shouldBeTrue("ctx.isPointInStroke(path,15,10)"); | 98 shouldBeTrue("ctx.isPointInStroke(path,15,10)"); |
| 99 shouldBeFalse("ctx.isPointInStroke(path,25,10)"); | 99 shouldBeFalse("ctx.isPointInStroke(path,25,10)"); |
| 100 shouldBeTrue("ctx.isPointInStroke(path,35,10)"); | 100 shouldBeTrue("ctx.isPointInStroke(path,35,10)"); |
| 101 debug(""); | 101 debug(""); |
| 102 | 102 |
| 103 debug("Check dashOffset = 10"); | 103 debug("Check dashOffset = 10"); |
| 104 ctx.lineDashOffset = 10; | 104 ctx.lineDashOffset = 10; |
| 105 shouldBeFalse("ctx.isPointInStroke(path,15,10)"); | 105 shouldBeFalse("ctx.isPointInStroke(path,15,10)"); |
| 106 shouldBeTrue("ctx.isPointInStroke(path,25,10)"); | 106 shouldBeTrue("ctx.isPointInStroke(path,25,10)"); |
| 107 shouldBeFalse("ctx.isPointInStroke(path,35,10)"); | 107 shouldBeFalse("ctx.isPointInStroke(path,35,10)"); |
| OLD | NEW |