mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
80 lines
2.6 KiB
HTML
80 lines
2.6 KiB
HTML
<!DOCTYPE HTML>
|
|
<title>Canvas test: 2d.path.arcTo.shape.curve1</title>
|
|
<!-- Testing: arcTo() curves in the right kind of shape -->
|
|
<script src="/MochiKit/MochiKit.js"></script>
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
|
|
<body>
|
|
<canvas id="c" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
|
<script>
|
|
function isPixel(ctx, x,y, r,g,b,a, pos, colour, d) {
|
|
var pixel = ctx.getImageData(x, y, 1, 1);
|
|
var pr = pixel.data[0],
|
|
pg = pixel.data[1],
|
|
pb = pixel.data[2],
|
|
pa = pixel.data[3];
|
|
ok(r-d <= pr && pr <= r+d &&
|
|
g-d <= pg && pg <= g+d &&
|
|
b-d <= pb && pb <= b+d &&
|
|
a-d <= pa && pa <= a+d,
|
|
"pixel "+pos+" is "+pr+","+pg+","+pb+","+pa+"; expected "+colour+" +/- "+d);
|
|
}
|
|
function todo_isPixel(ctx, x,y, r,g,b,a, pos, colour, d) {
|
|
var pixel = ctx.getImageData(x, y, 1, 1);
|
|
var pr = pixel.data[0],
|
|
pg = pixel.data[1],
|
|
pb = pixel.data[2],
|
|
pa = pixel.data[3];
|
|
todo(r-d <= pr && pr <= r+d &&
|
|
g-d <= pg && pg <= g+d &&
|
|
b-d <= pb && pb <= b+d &&
|
|
a-d <= pa && pa <= a+d,
|
|
"pixel "+pos+" is "+pr+","+pg+","+pb+","+pa+"; expected "+colour+" +/- "+d);
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
MochiKit.DOM.addLoadEvent(function () {
|
|
|
|
var canvas = document.getElementById('c');
|
|
var ctx = canvas.getContext('2d');
|
|
|
|
var tol = 1.5; // tolerance to avoid antialiasing artifacts
|
|
|
|
ctx.fillStyle = '#0f0';
|
|
ctx.fillRect(0, 0, 100, 50);
|
|
|
|
ctx.strokeStyle = '#f00';
|
|
ctx.lineWidth = 10;
|
|
ctx.beginPath();
|
|
ctx.moveTo(10, 25);
|
|
ctx.arcTo(75, 25, 75, 60, 20);
|
|
ctx.stroke();
|
|
|
|
ctx.fillStyle = '#0f0';
|
|
ctx.beginPath();
|
|
ctx.rect(10, 20, 45, 10);
|
|
ctx.moveTo(80, 45);
|
|
ctx.arc(55, 45, 25+tol, 0, -Math.PI/2, true);
|
|
ctx.arc(55, 45, 15-tol, -Math.PI/2, 0, false);
|
|
ctx.fill();
|
|
|
|
isPixel(ctx, 50,25, 0,255,0,255, "50,25", "0,255,0,255", 0);
|
|
isPixel(ctx, 55,19, 0,255,0,255, "55,19", "0,255,0,255", 0);
|
|
isPixel(ctx, 55,20, 0,255,0,255, "55,20", "0,255,0,255", 0);
|
|
isPixel(ctx, 55,21, 0,255,0,255, "55,21", "0,255,0,255", 0);
|
|
isPixel(ctx, 64,22, 0,255,0,255, "64,22", "0,255,0,255", 0);
|
|
isPixel(ctx, 65,21, 0,255,0,255, "65,21", "0,255,0,255", 0);
|
|
isPixel(ctx, 72,28, 0,255,0,255, "72,28", "0,255,0,255", 0);
|
|
isPixel(ctx, 73,27, 0,255,0,255, "73,27", "0,255,0,255", 0);
|
|
isPixel(ctx, 78,36, 0,255,0,255, "78,36", "0,255,0,255", 0);
|
|
isPixel(ctx, 79,35, 0,255,0,255, "79,35", "0,255,0,255", 0);
|
|
isPixel(ctx, 80,44, 0,255,0,255, "80,44", "0,255,0,255", 0);
|
|
todo_isPixel(ctx, 80,45, 0,255,0,255, "80,45", "0,255,0,255", 0);
|
|
todo_isPixel(ctx, 80,46, 0,255,0,255, "80,46", "0,255,0,255", 0);
|
|
|
|
SimpleTest.finish();
|
|
|
|
});
|
|
</script>
|
|
|