summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/canvas/element/fill-and-stroke-styles/2d.strokeStyle.colorObject.html
blob: 308e6b54b782620b28a2bfda98367f54f62b19b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<title>Canvas test: 2d.strokeStyle.colorObject</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/canvas/resources/canvas-tests.js"></script>
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
<body class="show_output">

<h1>2d.strokeStyle.colorObject</h1>
<p class="desc">ctx.strokeStyle works with color objects</p>


<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("ctx.strokeStyle works with color objects");
_addTest(function(canvas, ctx) {

  ctx.lineWidth = 50;
  ctx.strokeStyle = {r: 1, g: 0, b: 0};
  ctx.strokeRect(25, 24, 50, 2);
  _assertPixel(canvas, 50,25, 255,0,0,255);
  ctx.strokeStyle = {r: 0, g: 0, b: 1};
  ctx.strokeRect(25, 24, 50, 2);
  _assertPixel(canvas, 50,25, 0,0,255,255);
  ctx.strokeStyle = {r: 0.2, g: 0.4, b: 0.6};
  ctx.strokeRect(25, 24, 50, 2);
  _assertPixel(canvas, 50,25, 51,102,153,255);
  ctx.strokeStyle = {r: 0, g: 1, b: 0};
  ctx.strokeRect(25, 24, 50, 2);
  _assertPixel(canvas, 50,25, 0,255,0,255);
  ctx.strokeStyle = {r: -1, g: 0, b: 0};
  ctx.strokeRect(25, 24, 50, 2);
  _assertPixel(canvas, 50,25, 0,0,0,255);
  ctx.strokeStyle = {r: 0, g: 2, b: 0};
  ctx.strokeRect(25, 24, 50, 2);
  _assertPixel(canvas, 50,25, 0,255,0,255);

});
</script>