summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/canvas/element/manual/context-attributes/drawImage_alpha_false.html
blob: 64f38bceb1e7880aec6ad5f797063f39c2cb5e9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<!DOCTYPE html>
<meta charset="utf-8">
<title>CanvasRenderingContext 2D with alpha=flase, drawing a transparent image</title>
<link rel="author" title="Justin Novosad" href="mailto:junov@chromium.org">
<link rel="help" href="https://html.spec.whatwg.org/#concept-canvas-alpha">
<link rel="match" href="drawImage_alpha_false-ref.html">
<meta name="assert" content="Canvas pixels remain opaque black when drawing a transparent image.">
<p>Test passes if a 100x100 black square is displayed below.</p>
<canvas id="c" width=100 height=100></canvas>
<script>
const source = document.createElement('canvas');
source.width = source.height = 20;
const source_ctx = source.getContext("2d"); // leave default transparent content

const ctx = document.getElementById("c").getContext("2d", {alpha: false});
ctx.globalCompositOperation = 'copy';
ctx.drawImage(source, 0, 0);
ctx.globalCompositOperation = 'source-over';
ctx.drawImage(source, 20, 0);
</script>