| OLD | NEW |
| 1 description("Basic test for setLineDash, getLineDash and lineDashOffset"); | 1 description("Basic test for setLineDash, getLineDash and lineDashOffset"); |
| 2 | 2 |
| 3 var canvas = document.createElement('canvas'); | 3 var canvas = document.createElement('canvas'); |
| 4 document.body.appendChild(canvas); | 4 document.body.appendChild(canvas); |
| 5 canvas.setAttribute('width', '700'); | 5 canvas.setAttribute('width', '700'); |
| 6 canvas.setAttribute('height', '700'); | 6 canvas.setAttribute('height', '700'); |
| 7 var ctx = canvas.getContext('2d'); | 7 var ctx = canvas.getContext('2d'); |
| 8 | 8 |
| 9 function dataToArray(data) { | 9 function dataToArray(data) { |
| 10 var result = new Array(data.length) | 10 var result = new Array(data.length) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 ctx.lineDashOffset = 5; | 32 ctx.lineDashOffset = 5; |
| 33 ctx.strokeRect (10,10,100,100); | 33 ctx.strokeRect (10,10,100,100); |
| 34 | 34 |
| 35 // Verify dash and offset. | 35 // Verify dash and offset. |
| 36 var lineDash; | 36 var lineDash; |
| 37 lineDash = ctx.getLineDash(); | 37 lineDash = ctx.getLineDash(); |
| 38 shouldBe('lineDash[0]', '15'); | 38 shouldBe('lineDash[0]', '15'); |
| 39 shouldBe('lineDash[1]', '10'); | 39 shouldBe('lineDash[1]', '10'); |
| 40 shouldBe('ctx.lineDashOffset', '5'); | 40 shouldBe('ctx.lineDashOffset', '5'); |
| 41 | 41 |
| 42 // Verify setting line dash to sequence of nulls is interpreted as zeros |
| 43 ctx.setLineDash([null, null]); |
| 44 lineDash = ctx.getLineDash(); |
| 45 shouldBe('lineDash[0]', '0'); |
| 46 shouldBe('lineDash[1]', '0'); |
| 47 |
| 42 // Set dash style to even number | 48 // Set dash style to even number |
| 43 ctx.setLineDash([5, 10, 15]); | 49 ctx.setLineDash([5, 10, 15]); |
| 44 ctx.strokeRect(20, 20, 120, 120); | 50 ctx.strokeRect(20, 20, 120, 120); |
| 45 | 51 |
| 46 // Verify dash pattern is normalized | 52 // Verify dash pattern is normalized |
| 47 lineDash = ctx.getLineDash(); | 53 lineDash = ctx.getLineDash(); |
| 48 shouldBe('lineDash[0]', '5'); | 54 shouldBe('lineDash[0]', '5'); |
| 49 shouldBe('lineDash[1]', '10'); | 55 shouldBe('lineDash[1]', '10'); |
| 50 shouldBe('lineDash[2]', '15'); | 56 shouldBe('lineDash[2]', '15'); |
| 51 shouldBe('lineDash[3]', '5'); | 57 shouldBe('lineDash[3]', '5'); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 ctx.strokeRect(90.5, 10.5, 30, 30); | 103 ctx.strokeRect(90.5, 10.5, 30, 30); |
| 98 pixelShouldBe(95, 10, [0, 0, 0, 0]); | 104 pixelShouldBe(95, 10, [0, 0, 0, 0]); |
| 99 pixelShouldBe(105, 10, [0, 255, 0, 255]); | 105 pixelShouldBe(105, 10, [0, 255, 0, 255]); |
| 100 pixelShouldBe(120, 15, [0, 0, 0, 0]); | 106 pixelShouldBe(120, 15, [0, 0, 0, 0]); |
| 101 pixelShouldBe(120, 25, [0, 255, 0, 255]); | 107 pixelShouldBe(120, 25, [0, 255, 0, 255]); |
| 102 pixelShouldBe(115, 40, [0, 0, 0, 0]); | 108 pixelShouldBe(115, 40, [0, 0, 0, 0]); |
| 103 pixelShouldBe(105, 40, [0, 255, 0, 255]); | 109 pixelShouldBe(105, 40, [0, 255, 0, 255]); |
| 104 pixelShouldBe(90, 35, [0, 0, 0, 0]); | 110 pixelShouldBe(90, 35, [0, 0, 0, 0]); |
| 105 pixelShouldBe(90, 25, [0, 255, 0, 255]); | 111 pixelShouldBe(90, 25, [0, 255, 0, 255]); |
| 106 | 112 |
| 113 // Verify that all zero dash sequence results in no dashing |
| 114 ctx.setLineDash([0, 0]); |
| 115 ctx.lineDashOffset = 0; |
| 116 ctx.strokeRect(130.5, 10.5, 30, 30); |
| 117 pixelShouldBe(130, 10, [0, 255, 0, 255]); |
| 118 pixelShouldBe(130, 15, [0, 255, 0, 255]); |
| 119 pixelShouldBe(130, 25, [0, 255, 0, 255]); |
| 120 pixelShouldBe(130, 35, [0, 255, 0, 255]); |
| OLD | NEW |