Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement createConicGradient for the new canvas 2d API
Currently hidden behind the --new-canvas-2d-api flag. https://github.com/fserb/canvas2D/blob/master/spec/conic-gradient.md whatwg/html#5431 Bug: 1097034 Change-Id: I2267539087546b29f0fd04ecef7158e7a61bb97f
- Loading branch information
1 parent
1156b01
commit 0f2d473
Showing
5 changed files
with
134 additions
and
4 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
html/canvas/element/fill-and-stroke-styles/2d.gradient.conic.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<title>Canvas test: 2d.gradient.conic</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.gradient.conic</h1> | ||
<p class="desc">Conic gradient function exists</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("Conic gradient function exists"); | ||
_addTest(function(canvas, ctx) { | ||
|
||
const g = ctx.createConicGradient(0, 0, 25); | ||
g.addColorStop(0, "#0f0"); | ||
g.addColorStop(0.5, "#0f0"); | ||
g.addColorStop(0.51, "#f00"); | ||
g.addColorStop(1, "#f00"); | ||
ctx.fillStyle = g; | ||
ctx.fillRect(0, 0, 100, 50); | ||
_assertPixel(canvas, 25,25, 0,255,0,255, "25,25", "0,255,0,255"); | ||
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255"); | ||
_assertPixel(canvas, 75,25, 0,255,0,255, "75,25", "0,255,0,255"); | ||
|
||
|
||
}); | ||
</script> | ||
|
36 changes: 36 additions & 0 deletions
36
html/canvas/offscreen/fill-and-stroke-styles/2d.gradient.conic.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<title>OffscreenCanvas test: 2d.gradient.conic</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/html/canvas/resources/canvas-tests.js"></script> | ||
|
||
<h1>2d.gradient.conic</h1> | ||
<p class="desc">Conic gradient function exists</p> | ||
|
||
|
||
<script> | ||
var t = async_test("Conic gradient function exists"); | ||
var t_pass = t.done.bind(t); | ||
var t_fail = t.step_func(function(reason) { | ||
throw reason; | ||
}); | ||
t.step(function() { | ||
|
||
var offscreenCanvas = new OffscreenCanvas(100, 50); | ||
var ctx = offscreenCanvas.getContext('2d'); | ||
|
||
const g = ctx.createConicGradient(0, 0, 25); | ||
g.addColorStop(0, "#0f0"); | ||
g.addColorStop(0.5, "#0f0"); | ||
g.addColorStop(0.5, "#f00"); | ||
g.addColorStop(1, "#f00"); | ||
ctx.fillStyle = g; | ||
ctx.fillRect(0, 0, 100, 50); | ||
_assertPixel(offscreenCanvas, 25,25, 0,255,0,255, "25,25", "0,255,0,255"); | ||
_assertPixel(offscreenCanvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255"); | ||
_assertPixel(offscreenCanvas, 75,25, 0,255,0,255, "75,25", "0,255,0,255"); | ||
t.done(); | ||
|
||
}); | ||
</script> |
32 changes: 32 additions & 0 deletions
32
html/canvas/offscreen/fill-and-stroke-styles/2d.gradient.conic.worker.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. | ||
// OffscreenCanvas test in a worker:2d.gradient.conic | ||
// Description:Conic gradient function exists | ||
// Note: | ||
|
||
importScripts("/resources/testharness.js"); | ||
importScripts("/html/canvas/resources/canvas-tests.js"); | ||
|
||
var t = async_test("Conic gradient function exists"); | ||
var t_pass = t.done.bind(t); | ||
var t_fail = t.step_func(function(reason) { | ||
throw reason; | ||
}); | ||
t.step(function() { | ||
|
||
var offscreenCanvas = new OffscreenCanvas(100, 50); | ||
var ctx = offscreenCanvas.getContext('2d'); | ||
|
||
const g = ctx.createConicGradient(0, 0, 25); | ||
g.addColorStop(0, "#0f0"); | ||
g.addColorStop(0.5, "#0f0"); | ||
g.addColorStop(0.5, "#f00"); | ||
g.addColorStop(1, "#f00"); | ||
ctx.fillStyle = g; | ||
ctx.fillRect(0, 0, 100, 50); | ||
_assertPixel(offscreenCanvas, 25,25, 0,255,0,255, "25,25", "0,255,0,255"); | ||
_assertPixel(offscreenCanvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255"); | ||
_assertPixel(offscreenCanvas, 75,25, 0,255,0,255, "75,25", "0,255,0,255"); | ||
t.done(); | ||
|
||
}); | ||
done(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters