2d.fillStyle.CSSHSL.html (1386B)
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.fillStyle.CSSHSL</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.fillStyle.CSSHSL</h1> 10 <p class="desc">CSSHSL works as color input</p> 11 12 13 <script> 14 var t = async_test("CSSHSL works as color input"); 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 = new CSSHSL(CSS.deg(180), 0.5, 0.5); 25 ctx.fillRect(0, 0, 100, 50); 26 _assertPixelApprox(canvas, 50,25, 64,191,191,255, 3); 27 28 const color = new CSSHSL(CSS.deg(180), 1, 1); 29 ctx.fillStyle = color; 30 _assertSame(ctx.fillStyle, '#ffffff', "ctx.fillStyle", "'#ffffff'"); 31 ctx.fillRect(0, 0, 100, 50); 32 _assertPixel(canvas, 50,25, 255,255,255,255); 33 color.l = 0.5; 34 ctx.fillStyle = color; 35 _assertSame(ctx.fillStyle, '#00ffff', "ctx.fillStyle", "'#00ffff'"); 36 ctx.fillRect(0, 0, 100, 50); 37 _assertPixel(canvas, 50,25, 0,255,255,255); 38 39 color.h = CSS.deg(120); 40 color.s = 1; 41 color.l = 0.5; 42 ctx.fillStyle = color; 43 ctx.fillRect(0, 0, 100, 50); 44 t.done(); 45 46 }); 47 </script>