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 Path2D(); | 9 var path = new Path2D(); |
10 path.rect(20,20,100,100); | 10 path.rect(20,20,100,100); |
(...skipping 12 matching lines...) Expand all Loading... |
23 shouldBeFalse("ctx.isPointInStroke(path,22,118)"); | 23 shouldBeFalse("ctx.isPointInStroke(path,22,118)"); |
24 shouldBeFalse("ctx.isPointInStroke(path,118,118)"); | 24 shouldBeFalse("ctx.isPointInStroke(path,118,118)"); |
25 shouldBeFalse("ctx.isPointInStroke(path,70,18)"); | 25 shouldBeFalse("ctx.isPointInStroke(path,70,18)"); |
26 shouldBeFalse("ctx.isPointInStroke(path,122,70)"); | 26 shouldBeFalse("ctx.isPointInStroke(path,122,70)"); |
27 shouldBeFalse("ctx.isPointInStroke(path,70,122)"); | 27 shouldBeFalse("ctx.isPointInStroke(path,70,122)"); |
28 shouldBeFalse("ctx.isPointInStroke(path,18,70)"); | 28 shouldBeFalse("ctx.isPointInStroke(path,18,70)"); |
29 shouldBeFalse("ctx.isPointInStroke(path,NaN,122)"); | 29 shouldBeFalse("ctx.isPointInStroke(path,NaN,122)"); |
30 shouldBeFalse("ctx.isPointInStroke(path,18,NaN)"); | 30 shouldBeFalse("ctx.isPointInStroke(path,18,NaN)"); |
31 debug(""); | 31 debug(""); |
32 | 32 |
33 debug("Check null and invalid type"); | 33 debug("Check invalid type"); |
34 shouldThrow("ctx.isPointInStroke(null,70,20)"); | 34 shouldThrow("ctx.isPointInStroke(null,70,20)"); |
| 35 shouldThrow("ctx.isPointInStroke(undefined,70,20)"); |
35 shouldThrow("ctx.isPointInStroke([],20,70)"); | 36 shouldThrow("ctx.isPointInStroke([],20,70)"); |
36 shouldThrow("ctx.isPointInStroke({},120,70)"); | 37 shouldThrow("ctx.isPointInStroke({},120,70)"); |
37 debug(""); | 38 debug(""); |
38 | 39 |
39 debug("Set lineWidth = 10.0"); | 40 debug("Set lineWidth = 10.0"); |
40 ctx.lineWidth = 10; | 41 ctx.lineWidth = 10; |
41 shouldBeTrue("ctx.isPointInStroke(path,22,22)"); | 42 shouldBeTrue("ctx.isPointInStroke(path,22,22)"); |
42 shouldBeTrue("ctx.isPointInStroke(path,118,22)"); | 43 shouldBeTrue("ctx.isPointInStroke(path,118,22)"); |
43 shouldBeTrue("ctx.isPointInStroke(path,22,118)"); | 44 shouldBeTrue("ctx.isPointInStroke(path,22,118)"); |
44 shouldBeTrue("ctx.isPointInStroke(path,118,118)"); | 45 shouldBeTrue("ctx.isPointInStroke(path,118,118)"); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 shouldBeTrue("ctx.isPointInStroke(path,15,10)"); | 99 shouldBeTrue("ctx.isPointInStroke(path,15,10)"); |
99 shouldBeFalse("ctx.isPointInStroke(path,25,10)"); | 100 shouldBeFalse("ctx.isPointInStroke(path,25,10)"); |
100 shouldBeTrue("ctx.isPointInStroke(path,35,10)"); | 101 shouldBeTrue("ctx.isPointInStroke(path,35,10)"); |
101 debug(""); | 102 debug(""); |
102 | 103 |
103 debug("Check dashOffset = 10"); | 104 debug("Check dashOffset = 10"); |
104 ctx.lineDashOffset = 10; | 105 ctx.lineDashOffset = 10; |
105 shouldBeFalse("ctx.isPointInStroke(path,15,10)"); | 106 shouldBeFalse("ctx.isPointInStroke(path,15,10)"); |
106 shouldBeTrue("ctx.isPointInStroke(path,25,10)"); | 107 shouldBeTrue("ctx.isPointInStroke(path,25,10)"); |
107 shouldBeFalse("ctx.isPointInStroke(path,35,10)"); | 108 shouldBeFalse("ctx.isPointInStroke(path,35,10)"); |
OLD | NEW |