Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <meta charset="utf-8"> |
michael@0 | 5 | <title>Canvas test: isPointInStroke</title> |
michael@0 | 6 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 7 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 8 | </head> |
michael@0 | 9 | <body> |
michael@0 | 10 | <canvas id="c" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> |
michael@0 | 11 | <script type="application/javascript"> |
michael@0 | 12 | |
michael@0 | 13 | var canvas = document.getElementById('c'); |
michael@0 | 14 | var ctx = canvas.getContext('2d'); |
michael@0 | 15 | |
michael@0 | 16 | |
michael@0 | 17 | ctx.lineWidth = 5; |
michael@0 | 18 | |
michael@0 | 19 | |
michael@0 | 20 | ok(ctx.isPointInStroke(50, 25) === false, 'ctx.isPointInStroke(50, 25) === false'); |
michael@0 | 21 | |
michael@0 | 22 | |
michael@0 | 23 | ctx.beginPath(); |
michael@0 | 24 | ctx.rect(0, 0, 20, 20); |
michael@0 | 25 | |
michael@0 | 26 | ok(ctx.isPointInStroke(-4, -4) === false, 'ctx.isPointInStroke(-4, -4) === false'); |
michael@0 | 27 | ok(ctx.isPointInStroke(4, 4) === false, 'ctx.isPointInStroke(4, 4) === false'); |
michael@0 | 28 | ok(ctx.isPointInStroke(16, 16) === false, 'ctx.isPointInStroke(16, 16) === false'); |
michael@0 | 29 | ok(ctx.isPointInStroke(24, 24) === false, 'ctx.isPointInStroke(24, 24) === false'); |
michael@0 | 30 | |
michael@0 | 31 | ok(ctx.isPointInStroke(-2, -2) === true, 'ctx.isPointInStroke(-2, -2) === true'); |
michael@0 | 32 | ok(ctx.isPointInStroke(2, 2) === true, 'ctx.isPointInStroke(2, 2) === true'); |
michael@0 | 33 | ok(ctx.isPointInStroke(18, 18) === true, 'ctx.isPointInStroke(18, 18) === true'); |
michael@0 | 34 | ok(ctx.isPointInStroke(22, 22) === true, 'ctx.isPointInStroke(22, 22) === true'); |
michael@0 | 35 | |
michael@0 | 36 | |
michael@0 | 37 | ctx.beginPath(); |
michael@0 | 38 | ctx.rect(25, 25, 20, 20); |
michael@0 | 39 | |
michael@0 | 40 | ok(ctx.isPointInStroke(21, 21) === false, 'ctx.isPointInStroke(21, 21) === false'); |
michael@0 | 41 | ok(ctx.isPointInStroke(29, 29) === false, 'ctx.isPointInStroke(29, 29) === false'); |
michael@0 | 42 | ok(ctx.isPointInStroke(42, 42) === false, 'ctx.isPointInStroke(42, 42) === false'); |
michael@0 | 43 | ok(ctx.isPointInStroke(50, 50) === false, 'ctx.isPointInStroke(50, 50) === false'); |
michael@0 | 44 | |
michael@0 | 45 | ok(ctx.isPointInStroke(23, 23) === true, 'ctx.isPointInStroke(23, 23) === true'); |
michael@0 | 46 | ok(ctx.isPointInStroke(27, 27) === true, 'ctx.isPointInStroke(27, 27) === true'); |
michael@0 | 47 | ok(ctx.isPointInStroke(43, 43) === true, 'ctx.isPointInStroke(43, 43) === true'); |
michael@0 | 48 | ok(ctx.isPointInStroke(47, 47) === true, 'ctx.isPointInStroke(47, 47) === true'); |
michael@0 | 49 | |
michael@0 | 50 | |
michael@0 | 51 | ctx.beginPath(); |
michael@0 | 52 | ctx.moveTo(25, 25); |
michael@0 | 53 | ctx.bezierCurveTo(50, -50, 50, 100, 75, 25); |
michael@0 | 54 | |
michael@0 | 55 | ok(ctx.isPointInStroke(23, 26) === false, 'ctx.isPointInStroke(23, 26) === false'); |
michael@0 | 56 | ok(ctx.isPointInStroke(75, 23) === false, 'ctx.isPointInStroke(75, 23) === false'); |
michael@0 | 57 | ok(ctx.isPointInStroke(37, 8) === false, 'ctx.isPointInStroke(37, 8) === false'); |
michael@0 | 58 | ok(ctx.isPointInStroke(61, 42) === false, 'ctx.isPointInStroke(61, 42) === false'); |
michael@0 | 59 | |
michael@0 | 60 | ok(ctx.isPointInStroke(24, 24) === true, 'ctx.isPointInStroke(24, 24) === true'); |
michael@0 | 61 | ok(ctx.isPointInStroke(74, 25) === true, 'ctx.isPointInStroke(74, 25) === true'); |
michael@0 | 62 | ok(ctx.isPointInStroke(37, 2) === true, 'ctx.isPointInStroke(37, 2) === true'); |
michael@0 | 63 | ok(ctx.isPointInStroke(61, 47) === true, 'ctx.isPointInStroke(61, 47) === true'); |
michael@0 | 64 | |
michael@0 | 65 | |
michael@0 | 66 | ctx.beginPath(); |
michael@0 | 67 | ctx.arc(50, 25, 10, 0, Math.PI, false); |
michael@0 | 68 | |
michael@0 | 69 | ok(ctx.isPointInStroke(39, 23) === false, 'ctx.isPointInStroke(39, 23) === false'); |
michael@0 | 70 | ok(ctx.isPointInStroke(50, 15) === false, 'ctx.isPointInStroke(50, 15) === false'); |
michael@0 | 71 | ok(ctx.isPointInStroke(60, 23) === false, 'ctx.isPointInStroke(60, 23) === false'); |
michael@0 | 72 | ok(ctx.isPointInStroke(50, 25) === false, 'ctx.isPointInStroke(50, 25) === false'); |
michael@0 | 73 | |
michael@0 | 74 | ok(ctx.isPointInStroke(39, 26) === true, 'ctx.isPointInStroke(39, 26) === true'); |
michael@0 | 75 | ok(ctx.isPointInStroke(45, 33) === true, 'ctx.isPointInStroke(45, 33) === true'); |
michael@0 | 76 | ok(ctx.isPointInStroke(53, 33) === true, 'ctx.isPointInStroke(53, 33) === true'); |
michael@0 | 77 | ok(ctx.isPointInStroke(59, 26) === true, 'ctx.isPointInStroke(59, 26) === true'); |
michael@0 | 78 | |
michael@0 | 79 | |
michael@0 | 80 | ctx.beginPath(); |
michael@0 | 81 | ctx.arc(50, 25, 10, 0, 2 * Math.PI, false); |
michael@0 | 82 | |
michael@0 | 83 | ok(ctx.isPointInStroke(34, 25) === false, 'ctx.isPointInStroke(34, 25) === false'); |
michael@0 | 84 | ok(ctx.isPointInStroke(44, 25) === false, 'ctx.isPointInStroke(44, 25) === false'); |
michael@0 | 85 | ok(ctx.isPointInStroke(49, 30) === false, 'ctx.isPointInStroke(49, 30) === false'); |
michael@0 | 86 | ok(ctx.isPointInStroke(49, 40) === false, 'ctx.isPointInStroke(49, 40) === false'); |
michael@0 | 87 | |
michael@0 | 88 | ok(ctx.isPointInStroke(39, 23) === true, 'ctx.isPointInStroke(39, 23) === true'); |
michael@0 | 89 | ok(ctx.isPointInStroke(50, 15) === true, 'ctx.isPointInStroke(50, 15) === true'); |
michael@0 | 90 | ok(ctx.isPointInStroke(60, 23) === true, 'ctx.isPointInStroke(60, 23) === true'); |
michael@0 | 91 | ok(ctx.isPointInStroke(49, 34) === true, 'ctx.isPointInStroke(49, 34) === true'); |
michael@0 | 92 | |
michael@0 | 93 | |
michael@0 | 94 | ctx.beginPath(); |
michael@0 | 95 | ctx.save(); |
michael@0 | 96 | ctx.translate(20, 20); |
michael@0 | 97 | ctx.rect(0, 0, 20, 20); |
michael@0 | 98 | |
michael@0 | 99 | ok(ctx.isPointInStroke(16, 16) === false, 'ctx.isPointInStroke(16, 16) === false'); |
michael@0 | 100 | ok(ctx.isPointInStroke(24, 24) === false, 'ctx.isPointInStroke(24, 24) === false'); |
michael@0 | 101 | ok(ctx.isPointInStroke(36, 36) === false, 'ctx.isPointInStroke(36, 36) === false'); |
michael@0 | 102 | ok(ctx.isPointInStroke(44, 44) === false, 'ctx.isPointInStroke(44, 44) === false'); |
michael@0 | 103 | |
michael@0 | 104 | ok(ctx.isPointInStroke(18, 18) === true, 'ctx.isPointInStroke(18, 18) === true'); |
michael@0 | 105 | ok(ctx.isPointInStroke(22, 22) === true, 'ctx.isPointInStroke(22, 22) === true'); |
michael@0 | 106 | ok(ctx.isPointInStroke(38, 38) === true, 'ctx.isPointInStroke(38, 38) === true'); |
michael@0 | 107 | ok(ctx.isPointInStroke(42, 42) === true, 'ctx.isPointInStroke(42, 42) === true'); |
michael@0 | 108 | |
michael@0 | 109 | ctx.restore(); |
michael@0 | 110 | |
michael@0 | 111 | |
michael@0 | 112 | ctx.beginPath(); |
michael@0 | 113 | ctx.save(); |
michael@0 | 114 | ctx.scale(-1, 1); |
michael@0 | 115 | ctx.rect(-30, 20, 20, 20); |
michael@0 | 116 | |
michael@0 | 117 | ok(ctx.isPointInStroke(16, 16) === false, 'ctx.isPointInStroke(16, 16) === false'); |
michael@0 | 118 | ok(ctx.isPointInStroke(14, 24) === false, 'ctx.isPointInStroke(14, 24) === false'); |
michael@0 | 119 | ok(ctx.isPointInStroke(26, 36) === false, 'ctx.isPointInStroke(26, 36) === false'); |
michael@0 | 120 | ok(ctx.isPointInStroke(34, 44) === false, 'ctx.isPointInStroke(34, 44) === false'); |
michael@0 | 121 | |
michael@0 | 122 | ok(ctx.isPointInStroke(8, 18) === true, 'ctx.isPointInStroke(8, 18) === true'); |
michael@0 | 123 | ok(ctx.isPointInStroke(12, 22) === true, 'ctx.isPointInStroke(12, 22) === true'); |
michael@0 | 124 | ok(ctx.isPointInStroke(28, 38) === true, 'ctx.isPointInStroke(28, 38) === true'); |
michael@0 | 125 | ok(ctx.isPointInStroke(32, 42) === true, 'ctx.isPointInStroke(32, 42) === true'); |
michael@0 | 126 | |
michael@0 | 127 | ctx.restore(); |
michael@0 | 128 | |
michael@0 | 129 | |
michael@0 | 130 | ctx.beginPath(); |
michael@0 | 131 | ctx.save(); |
michael@0 | 132 | ctx.lineWidth = 2; |
michael@0 | 133 | ctx.translate(50, 25); |
michael@0 | 134 | ctx.rotate(180 * Math.PI / 180); |
michael@0 | 135 | ctx.scale(5, 5); |
michael@0 | 136 | ctx.arc(0, 0, 2, 0, Math.PI, false); |
michael@0 | 137 | |
michael@0 | 138 | ok(ctx.isPointInStroke(39, 26) === false, 'ctx.isPointInStroke(39, 26) === false'); |
michael@0 | 139 | ok(ctx.isPointInStroke(45, 33) === false, 'ctx.isPointInStroke(45, 33) === false'); |
michael@0 | 140 | ok(ctx.isPointInStroke(53, 33) === false, 'ctx.isPointInStroke(53, 33) === false'); |
michael@0 | 141 | ok(ctx.isPointInStroke(59, 26) === false, 'ctx.isPointInStroke(59, 26) === false'); |
michael@0 | 142 | |
michael@0 | 143 | ok(ctx.isPointInStroke(39, 23) === true, 'ctx.isPointInStroke(39, 23) === true'); |
michael@0 | 144 | ok(ctx.isPointInStroke(45, 15) === true, 'ctx.isPointInStroke(50, 15) === true'); |
michael@0 | 145 | ok(ctx.isPointInStroke(55, 15) === true, 'ctx.isPointInStroke(50, 25) === true'); |
michael@0 | 146 | ok(ctx.isPointInStroke(60, 23) === true, 'ctx.isPointInStroke(60, 23) === true'); |
michael@0 | 147 | |
michael@0 | 148 | ctx.restore(); |
michael@0 | 149 | |
michael@0 | 150 | |
michael@0 | 151 | ctx.beginPath(); |
michael@0 | 152 | |
michael@0 | 153 | ctx.moveTo(10, 10); |
michael@0 | 154 | ctx.lineTo(30, 10); |
michael@0 | 155 | ctx.save(); |
michael@0 | 156 | ctx.lineWidth = 2; |
michael@0 | 157 | ctx.scale(5, 5); |
michael@0 | 158 | ctx.lineTo(6, 6); |
michael@0 | 159 | ctx.lineTo(2, 6); |
michael@0 | 160 | ctx.restore(); |
michael@0 | 161 | ctx.closePath(); |
michael@0 | 162 | |
michael@0 | 163 | ok(ctx.isPointInStroke(6, 6) === false, 'ctx.isPointInStroke(6, 6) === false'); |
michael@0 | 164 | ok(ctx.isPointInStroke(14, 14) === false, 'ctx.isPointInStroke(14, 14) === false'); |
michael@0 | 165 | ok(ctx.isPointInStroke(26, 26) === false, 'ctx.isPointInStroke(26, 26) === false'); |
michael@0 | 166 | ok(ctx.isPointInStroke(34, 34) === false, 'ctx.isPointInStroke(34, 34) === false'); |
michael@0 | 167 | |
michael@0 | 168 | ok(ctx.isPointInStroke(8, 8) === true, 'ctx.isPointInStroke(8, 8) === true'); |
michael@0 | 169 | ok(ctx.isPointInStroke(12, 12) === true, 'ctx.isPointInStroke(12, 12) === true'); |
michael@0 | 170 | ok(ctx.isPointInStroke(28, 28) === true, 'ctx.isPointInStroke(28, 28) === true'); |
michael@0 | 171 | ok(ctx.isPointInStroke(32, 32) === true, 'ctx.isPointInStroke(32, 32) === true'); |
michael@0 | 172 | |
michael@0 | 173 | |
michael@0 | 174 | ctx.beginPath(); |
michael@0 | 175 | ctx.rect(-30, -30, 20, 20); |
michael@0 | 176 | |
michael@0 | 177 | ok(ctx.isPointInStroke(-34, -34) === false, 'ctx.isPointInStroke(-34, -34) === false'); |
michael@0 | 178 | ok(ctx.isPointInStroke(-26, -26) === false, 'ctx.isPointInStroke(-26, -26) === false'); |
michael@0 | 179 | ok(ctx.isPointInStroke(-14, -14) === false, 'ctx.isPointInStroke(-14, -14) === false'); |
michael@0 | 180 | ok(ctx.isPointInStroke(-6, -6) === false, 'ctx.isPointInStroke(-6, -6) === false'); |
michael@0 | 181 | |
michael@0 | 182 | ok(ctx.isPointInStroke(-32, -32) === true, 'ctx.isPointInStroke(-32, -32) === true'); |
michael@0 | 183 | ok(ctx.isPointInStroke(-28, -28) === true, 'ctx.isPointInStroke(-28, -28) === true'); |
michael@0 | 184 | ok(ctx.isPointInStroke(-12, -12) === true, 'ctx.isPointInStroke(-12, -12) === true'); |
michael@0 | 185 | ok(ctx.isPointInStroke(-8, -8) === true, 'ctx.isPointInStroke(-8, -8) === true'); |
michael@0 | 186 | |
michael@0 | 187 | |
michael@0 | 188 | ctx.beginPath(); |
michael@0 | 189 | ctx.moveTo(20, 25); |
michael@0 | 190 | ctx.lineTo(80, 25); |
michael@0 | 191 | |
michael@0 | 192 | ok(ctx.isPointInStroke(19, 25) === false, 'ctx.isPointInStroke(19, 25) === false'); |
michael@0 | 193 | ok(ctx.isPointInStroke(50, 21) === false, 'ctx.isPointInStroke(50, 21) === false'); |
michael@0 | 194 | ok(ctx.isPointInStroke(81, 25) === false, 'ctx.isPointInStroke(81, 25) === false'); |
michael@0 | 195 | ok(ctx.isPointInStroke(50, 29) === false, 'ctx.isPointInStroke(50, 29) === false'); |
michael@0 | 196 | |
michael@0 | 197 | ok(ctx.isPointInStroke(21, 25) === true, 'ctx.isPointInStroke(21, 25) === true'); |
michael@0 | 198 | ok(ctx.isPointInStroke(50, 23) === true, 'ctx.isPointInStroke(50, 23) === true'); |
michael@0 | 199 | ok(ctx.isPointInStroke(79, 25) === true, 'ctx.isPointInStroke(79, 25) === true'); |
michael@0 | 200 | ok(ctx.isPointInStroke(50, 27) === true, 'ctx.isPointInStroke(50, 27) === true'); |
michael@0 | 201 | |
michael@0 | 202 | |
michael@0 | 203 | ctx.lineWidth = 15; |
michael@0 | 204 | ctx.lineCap = 'round'; |
michael@0 | 205 | |
michael@0 | 206 | |
michael@0 | 207 | ctx.beginPath(); |
michael@0 | 208 | ctx.moveTo(20, 25); |
michael@0 | 209 | ctx.lineTo(80, 25); |
michael@0 | 210 | |
michael@0 | 211 | ok(ctx.isPointInStroke(13, 18) === false, 'ctx.isPointInStroke(13, 18) === false'); |
michael@0 | 212 | ok(ctx.isPointInStroke(13, 31) === false, 'ctx.isPointInStroke(13, 31) === false'); |
michael@0 | 213 | ok(ctx.isPointInStroke(86, 18) === false, 'ctx.isPointInStroke(86, 18) === false'); |
michael@0 | 214 | ok(ctx.isPointInStroke(86, 31) === false, 'ctx.isPointInStroke(86, 31) === false'); |
michael@0 | 215 | |
michael@0 | 216 | ok(ctx.isPointInStroke(13, 25) === true, 'ctx.isPointInStroke(13, 25) === true'); |
michael@0 | 217 | ok(ctx.isPointInStroke(50, 18) === true, 'ctx.isPointInStroke(50, 18) === true'); |
michael@0 | 218 | ok(ctx.isPointInStroke(86, 25) === true, 'ctx.isPointInStroke(86, 25) === true'); |
michael@0 | 219 | ok(ctx.isPointInStroke(50, 31) === true, 'ctx.isPointInStroke(50, 31) === true'); |
michael@0 | 220 | |
michael@0 | 221 | |
michael@0 | 222 | ctx.lineJoin = 'round'; |
michael@0 | 223 | |
michael@0 | 224 | |
michael@0 | 225 | ctx.beginPath(); |
michael@0 | 226 | ctx.moveTo(20, 15); |
michael@0 | 227 | ctx.lineTo(80, 15); |
michael@0 | 228 | ctx.lineTo(80, 35); |
michael@0 | 229 | |
michael@0 | 230 | ok(ctx.isPointInStroke(86, 8) === false, 'ctx.isPointInStroke(86, 8) === false'); |
michael@0 | 231 | ok(ctx.isPointInStroke(70, 24) === false, 'ctx.isPointInStroke(70, 24) === false'); |
michael@0 | 232 | ok(ctx.isPointInStroke(73, 41) === false, 'ctx.isPointInStroke(73, 41) === false'); |
michael@0 | 233 | ok(ctx.isPointInStroke(86, 41) === false, 'ctx.isPointInStroke(86, 41) === false'); |
michael@0 | 234 | |
michael@0 | 235 | ok(ctx.isPointInStroke(14, 15) === true, 'ctx.isPointInStroke(14, 15) === true'); |
michael@0 | 236 | ok(ctx.isPointInStroke(81, 15) === true, 'ctx.isPointInStroke(81, 15) === true'); |
michael@0 | 237 | ok(ctx.isPointInStroke(79, 41) === true, 'ctx.isPointInStroke(79, 41) === true'); |
michael@0 | 238 | ok(ctx.isPointInStroke(73, 21) === true, 'ctx.isPointInStroke(73, 21) === true'); |
michael@0 | 239 | |
michael@0 | 240 | </script> |
michael@0 | 241 | </pre> |
michael@0 | 242 | </body> |
michael@0 | 243 | </html> |
michael@0 | 244 |