Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: LayoutTests/fast/canvas/script-tests/canvas-isPointInStroke-with-path.js

Issue 179383002: Add versions of isPointIn*() that take a Path parameter. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 description("Test the behavior of isPointInStroke in Canvas with path object");
2 var ctx = document.createElement('canvas').getContext('2d');
3
4 document.body.appendChild(ctx.canvas);
5
6 ctx.strokeStyle = '#0ff';
7
8 // Create new path.
9 var path = new Path();
10 path.rect(20,20,100,100);
11
12 debug("Initial behavior: lineWidth = 1.0")
13 shouldBeTrue("ctx.isPointInStroke(path,20,20)");
14 shouldBeTrue("ctx.isPointInStroke(path,120,20)");
15 shouldBeTrue("ctx.isPointInStroke(path,20,120)");
16 shouldBeTrue("ctx.isPointInStroke(path,120,120)");
17 shouldBeTrue("ctx.isPointInStroke(path,70,20)");
18 shouldBeTrue("ctx.isPointInStroke(path,20,70)");
19 shouldBeTrue("ctx.isPointInStroke(path,120,70)");
20 shouldBeTrue("ctx.isPointInStroke(path,70,120)");
21 shouldBeFalse("ctx.isPointInStroke(path,22,22)");
22 shouldBeFalse("ctx.isPointInStroke(path,118,22)");
23 shouldBeFalse("ctx.isPointInStroke(path,22,118)");
24 shouldBeFalse("ctx.isPointInStroke(path,118,118)");
25 shouldBeFalse("ctx.isPointInStroke(path,70,18)");
26 shouldBeFalse("ctx.isPointInStroke(path,122,70)");
27 shouldBeFalse("ctx.isPointInStroke(path,70,122)");
28 shouldBeFalse("ctx.isPointInStroke(path,18,70)");
29 debug("");
30
31 debug("Set lineWidth = 10.0");
32 ctx.lineWidth = 10;
33 shouldBeTrue("ctx.isPointInStroke(path,22,22)");
34 shouldBeTrue("ctx.isPointInStroke(path,118,22)");
35 shouldBeTrue("ctx.isPointInStroke(path,22,118)");
36 shouldBeTrue("ctx.isPointInStroke(path,118,118)");
37 shouldBeTrue("ctx.isPointInStroke(path,70,18)");
38 shouldBeTrue("ctx.isPointInStroke(path,122,70)");
39 shouldBeTrue("ctx.isPointInStroke(path,70,122)");
40 shouldBeTrue("ctx.isPointInStroke(path,18,70)");
41 shouldBeFalse("ctx.isPointInStroke(path,26,70)");
42 shouldBeFalse("ctx.isPointInStroke(path,70,26)");
43 shouldBeFalse("ctx.isPointInStroke(path,70,114)");
44 shouldBeFalse("ctx.isPointInStroke(path,114,70)");
45 debug("");
46
47 debug("Check lineJoin = 'bevel'");
48 path = new Path();
49 path.moveTo(10,10);
50 path.lineTo(110,20);
51 path.lineTo(10,30);
52 ctx.lineJoin = "bevel";
53 shouldBeFalse("ctx.isPointInStroke(path,113,20)");
54 debug("");
55
56 debug("Check lineJoin = 'miter'");
57 ctx.miterLimit = 40.0;
58 ctx.lineJoin = "miter";
59 shouldBeTrue("ctx.isPointInStroke(path,113,20)");
60 debug("");
61
62 debug("Check miterLimit = 2.0");
63 ctx.miterLimit = 2.0;
64 shouldBeFalse("ctx.isPointInStroke(path,113,20)");
65 debug("");
66
67 debug("Check lineCap = 'butt'");
68 path = new Path();
69 path.moveTo(10,10);
70 path.lineTo(110,10);
71 ctx.lineCap = "butt";
72 shouldBeFalse("ctx.isPointInStroke(path,112,10)");
73 debug("");
74
75 debug("Check lineCap = 'round'");
76 ctx.lineCap = "round";
77 shouldBeTrue("ctx.isPointInStroke(path,112,10)");
78 shouldBeFalse("ctx.isPointInStroke(path,117,10)");
79 debug("");
80
81 debug("Check lineCap = 'square'");
82 ctx.lineCap = "square";
83 shouldBeTrue("ctx.isPointInStroke(path,112,10)");
84 shouldBeFalse("ctx.isPointInStroke(path,117,10)");
85 debug("");
86
87 debug("Check setLineDash([10,10])");
88 ctx.lineCap = "butt";
89 ctx.setLineDash([10,10]);
90 shouldBeTrue("ctx.isPointInStroke(path,15,10)");
91 shouldBeFalse("ctx.isPointInStroke(path,25,10)");
92 shouldBeTrue("ctx.isPointInStroke(path,35,10)");
93 debug("");
94
95 debug("Check dashOffset = 10");
96 ctx.lineDashOffset = 10;
97 shouldBeFalse("ctx.isPointInStroke(path,15,10)");
98 shouldBeTrue("ctx.isPointInStroke(path,25,10)");
99 shouldBeFalse("ctx.isPointInStroke(path,35,10)");
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698