tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

2d.line.width.transformed.html (2073B)


      1 <!DOCTYPE html>
      2 <!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
      3 <meta charset="UTF-8">
      4 <title>OffscreenCanvas test: 2d.line.width.transformed</title>
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="/html/canvas/resources/canvas-tests.js"></script>
      8 
      9 <h1>2d.line.width.transformed</h1>
     10 <p class="desc">Line stroke widths are affected by scale transformations</p>
     11 
     12 
     13 <script>
     14 var t = async_test("Line stroke widths are affected by scale transformations");
     15 var t_pass = t.done.bind(t);
     16 var t_fail = t.step_func(function(reason) {
     17    throw reason;
     18 });
     19 t.step(function() {
     20 
     21  var canvas = new OffscreenCanvas(100, 50);
     22  var ctx = canvas.getContext('2d');
     23 
     24  ctx.fillStyle = '#0f0';
     25  ctx.fillRect(0, 0, 100, 50);
     26 
     27  ctx.lineWidth = 4;
     28  // Draw a green line over a red box, to check the line is not too small
     29  ctx.fillStyle = '#f00';
     30  ctx.strokeStyle = '#0f0';
     31  ctx.fillRect(15, 15, 20, 20);
     32  ctx.save();
     33   ctx.scale(5, 1);
     34   ctx.beginPath();
     35   ctx.moveTo(5, 15);
     36   ctx.lineTo(5, 35);
     37   ctx.stroke();
     38  ctx.restore();
     39 
     40  // Draw a green box over a red line, to check the line is not too large
     41  ctx.fillStyle = '#0f0';
     42  ctx.strokeStyle = '#f00';
     43  ctx.save();
     44   ctx.scale(-5, 1);
     45   ctx.beginPath();
     46   ctx.moveTo(-15, 15);
     47   ctx.lineTo(-15, 35);
     48   ctx.stroke();
     49  ctx.restore();
     50  ctx.fillRect(65, 15, 20, 20);
     51 
     52  _assertPixel(canvas, 14,25, 0,255,0,255);
     53  _assertPixel(canvas, 15,25, 0,255,0,255);
     54  _assertPixel(canvas, 16,25, 0,255,0,255);
     55  _assertPixel(canvas, 25,25, 0,255,0,255);
     56  _assertPixel(canvas, 34,25, 0,255,0,255);
     57  _assertPixel(canvas, 35,25, 0,255,0,255);
     58  _assertPixel(canvas, 36,25, 0,255,0,255);
     59 
     60  _assertPixel(canvas, 64,25, 0,255,0,255);
     61  _assertPixel(canvas, 65,25, 0,255,0,255);
     62  _assertPixel(canvas, 66,25, 0,255,0,255);
     63  _assertPixel(canvas, 75,25, 0,255,0,255);
     64  _assertPixel(canvas, 84,25, 0,255,0,255);
     65  _assertPixel(canvas, 85,25, 0,255,0,255);
     66  _assertPixel(canvas, 86,25, 0,255,0,255);
     67  t.done();
     68 
     69 });
     70 </script>