OLD | NEW |
---|---|
(Empty) | |
1 description("Series of tests to ensure stroke() works with optional path paramet er."); | |
2 | |
3 var ctx = document.getElementById('canvas').getContext('2d'); | |
4 | |
5 function pixelDataAtPoint() { | |
6 return ctx.getImageData(75, 75, 1, 1).data; | |
7 } | |
8 | |
9 function checkResult(expectedColors, sigma) { | |
10 for (var i = 0; i < 4; i++) | |
11 shouldBeCloseTo("pixelDataAtPoint()[" + i + "]", expectedColors[i], sigma) ; | |
12 } | |
13 | |
14 function drawRectangleOn(contextOrPath) { | |
15 contextOrPath.rect(25, 25, 50, 50); | |
16 } | |
17 | |
18 function formatName(path) { | |
19 return 'stroke(' + (path ? 'path' : '') + ')'; | |
20 } | |
21 | |
22 function testStrokeWith(path) { | |
23 debug('Testing ' + formatName(path)); | |
24 ctx.fillStyle = 'rgb(255,0,0)'; | |
25 ctx.beginPath(); | |
26 ctx.fillRect(0, 0, 100, 100); | |
27 ctx.strokeStyle = 'rgb(0,255,0)'; | |
28 ctx.lineWidth = 5; | |
29 if (path) { | |
30 ctx.stroke(path); | |
31 } else { | |
32 ctx.beginPath(); | |
33 drawRectangleOn(ctx); | |
34 ctx.stroke(); | |
35 } | |
36 debug(''); | |
37 checkResult([0, 255, 0, 255], 5); | |
38 } | |
39 | |
40 // Execute test. | |
41 function prepareTestScenario() { | |
42 var path = new Path(); | |
43 drawRectangleOn(path); | |
44 | |
45 testStrokeWith(); | |
46 testStrokeWith(path); | |
dshwang
2014/01/23 21:17:17
I'm curious how result is changed if following cod
jcgregorio
2014/01/29 17:51:49
Actually, my reading of the spec is that they shou
dshwang
2014/01/31 12:29:00
Your impl scales by 2 into only path object.
See
| |
47 } | |
48 | |
49 // Run test and allow variation of results. | |
50 prepareTestScenario(); | |
OLD | NEW |