-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from w3c/master
Catch up to base repo.
- Loading branch information
Showing
1,747 changed files
with
71,354 additions
and
18,942 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
2dcontext/drawing-text-to-the-canvas/2d.text.draw.fill.maxWidth.NaN.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,32 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> | ||
<title>Canvas test: 2d.text.draw.fill.maxWidth.NaN</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/canvas-tests.js"></script> | ||
<link rel="stylesheet" href="/common/canvas-tests.css"> | ||
<body class="show_output"> | ||
|
||
<h1>2d.text.draw.fill.maxWidth.NaN</h1> | ||
<p class="desc">fillText handles maxWidth correctly</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("fillText handles maxWidth correctly"); | ||
_addTest(function(canvas, ctx) { | ||
|
||
ctx.fillStyle = '#0f0'; | ||
ctx.fillRect(0, 0, 100, 50); | ||
ctx.fillStyle = '#f00'; | ||
ctx.font = '35px Arial, sans-serif'; | ||
ctx.fillText('fail fail fail fail fail', 5, 35, NaN); | ||
_assertGreen(ctx, 100, 50); | ||
|
||
|
||
}); | ||
</script> | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,119 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>CanvasRenderingContext2D imageSmoothingEnabled test</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<link rel="author" title="ShinHyunjin" href="mailto:jini7927@gmail.com"> | ||
<link rel="help" href="http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas/#image-smoothing"> | ||
</head> | ||
<body> | ||
<div id="log"></div> | ||
<canvas id="test_canvas_1"></canvas> | ||
<canvas id="test_canvas_2"></canvas> | ||
<canvas id="test_canvas_3"></canvas> | ||
|
||
<script> | ||
(function() { | ||
test(function() { | ||
var canvas = document.getElementById('test_canvas_1'); | ||
var ctx = canvas.getContext('2d'); | ||
|
||
assert_true(ctx.imageSmoothingEnabled); | ||
}, "When the CanvasRenderingContext2D object is created, the attribute must be set to true."); | ||
|
||
test(function() { | ||
var canvas = document.getElementById('test_canvas_2'); | ||
var ctx = canvas.getContext('2d'); | ||
|
||
ctx.imageSmoothingEnabled = false; | ||
assert_false(ctx.imageSmoothingEnabled); | ||
}, "On getting the imageSmoothingEnabled attribute, the user agent must return the last value it was set to."); | ||
|
||
test(function() { | ||
var canvas = document.getElementById('test_canvas_3'); | ||
var ctx = canvas.getContext('2d'); | ||
|
||
ctx.imageSmoothingEnabled = false; | ||
assert_equals(ctx.imageSmoothingEnabled, false); | ||
}, "On setting the imageSmoothingEnabled attribute, it must be set to the new value."); | ||
})(); | ||
|
||
|
||
</script> | ||
</body> | ||
</html> | ||
<meta charset="utf-8"> | ||
<title>CanvasRenderingContext2D imageSmoothingEnabled test</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/scripting.html#image-smoothing"> | ||
<script> | ||
function createTestImage() { | ||
var image = document.createElement('canvas'); | ||
var imgctx = image.getContext('2d'); | ||
imgctx.fillStyle = "#F00"; | ||
imgctx.fillRect(0, 0, 2, 2); | ||
imgctx.fillStyle = "#0F0"; | ||
imgctx.fillRect(0, 0, 1, 1); | ||
return image; | ||
} | ||
|
||
test(function() { | ||
var ctx = document.createElement('canvas').getContext('2d'); | ||
assert_true(ctx.imageSmoothingEnabled); | ||
}, "When the canvas context is created, imageSmoothingEnabled must be set to true."); | ||
|
||
test(function() { | ||
var ctx = document.createElement('canvas').getContext('2d'); | ||
ctx.imageSmoothingEnabled = false; | ||
assert_false(ctx.imageSmoothingEnabled); | ||
}, "On getting imageSmoothingEnabled, the user agent must return the last value it was set to."); | ||
|
||
test(function() { | ||
var ctx = document.createElement('canvas').getContext('2d'); | ||
var image = createTestImage(); | ||
ctx.scale(10, 10); | ||
ctx.drawImage(image, 0, 0); | ||
var pixels = ctx.getImageData(9, 9, 1, 1).data; | ||
assert_not_equals(pixels[0], 0); | ||
assert_not_equals(pixels[1], 255); | ||
}, "Test that image smoothing is actually on by default and just the attribute value."); | ||
|
||
test(function() { | ||
var ctx = document.createElement('canvas').getContext('2d'); | ||
ctx.imageSmoothingEnabled = true; | ||
var image = createTestImage(); | ||
ctx.scale(10, 10); | ||
ctx.drawImage(image, 0, 0); | ||
var pixels = ctx.getImageData(9, 9, 1, 1).data; | ||
assert_not_equals(pixels[0], 0); | ||
assert_not_equals(pixels[1], 255); | ||
}, "Test that image smoothing works when imageSmoothingEnabled is set to true"); | ||
|
||
test(function() { | ||
var ctx = document.createElement('canvas').getContext('2d'); | ||
var image = createTestImage(); | ||
ctx.imageSmoothingEnabled = false; | ||
ctx.scale(10, 10); | ||
ctx.drawImage(image, 0, 0); | ||
var pixels = ctx.getImageData(9, 9, 1, 1).data; | ||
assert_array_equals(pixels, [0, 255, 0, 255]); | ||
}, "Test that imageSmoothingEnabled = false (nearest-neighbor interpolation) works with drawImage()."); | ||
|
||
test(function() { | ||
var ctx = document.createElement('canvas').getContext('2d'); | ||
var image = createTestImage(); | ||
ctx.imageSmoothingEnabled = false; | ||
ctx.scale(10, 10); | ||
ctx.fillStyle = ctx.createPattern(image, 'repeat'); | ||
ctx.fillRect(0, 0, 10, 10); | ||
var pixels = ctx.getImageData(9, 9, 1, 1).data; | ||
assert_array_equals(pixels, [0, 255, 0, 255]); | ||
}, "Test that imageSmoothingEnabled = false (nearest-neighbor interpolation) works with fillRect and createPattern()."); | ||
|
||
test(function() { | ||
var ctx = document.createElement('canvas').getContext('2d'); | ||
var image = createTestImage(); | ||
ctx.imageSmoothingEnabled = false; | ||
ctx.fillStyle = ctx.createPattern(image, 'repeat'); | ||
ctx.scale(10, 10); | ||
ctx.rect(0, 0, 10, 10); | ||
ctx.fill(); | ||
var pixels = ctx.getImageData(9, 9, 1, 1).data; | ||
assert_array_equals(pixels, [0, 255, 0, 255]); | ||
}, "Test that imageSmoothingEnabled = false (nearest-neighbor interpolation) works with fill() and createPattern()."); | ||
|
||
test(function() { | ||
var ctx = document.createElement('canvas').getContext('2d'); | ||
var image = createTestImage(); | ||
ctx.strokeStyle = ctx.createPattern(image, 'repeat'); | ||
ctx.lineWidth = 5; | ||
ctx.imageSmoothingEnabled = false; | ||
ctx.scale(10, 10); | ||
ctx.beginPath(); | ||
ctx.moveTo(0, 0); | ||
ctx.lineTo(10, 10); | ||
ctx.stroke(); | ||
var pixels = ctx.getImageData(9, 9, 1, 1).data; | ||
assert_array_equals(pixels, [0, 255, 0, 255]); | ||
}, "Test that imageSmoothingEnabled = false (nearest-neighbor interpolation) works with stroke() and createPattern()."); | ||
|
||
test(function() { | ||
var repaints = 5; | ||
var ctx = document.createElement('canvas').getContext('2d'); | ||
|
||
function draw() { | ||
ctx.clearRect(0, 0, 10, 10); | ||
ctx.setTransform(1, 0, 0, 1, 0, 0); | ||
var image = createTestImage(); | ||
ctx.imageSmoothingEnabled = false; | ||
ctx.scale(10, 10); | ||
ctx.drawImage(image, 0, 0); | ||
var pixels = ctx.getImageData(9, 9, 1, 1).data; | ||
assert_array_equals(pixels, [0, 255, 0, 255]); | ||
} | ||
|
||
while (repaints > 0) { | ||
draw(); | ||
repaints = repaints - 1; | ||
} | ||
|
||
}, "Test that imageSmoothingEnabled = false (nearest-neighbor interpolation) still works after repaints."); | ||
</script> |
47 changes: 47 additions & 0 deletions
47
2dcontext/the-canvas-state/2d.state.saverestore.imageSmoothingEnabled.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,47 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>CanvasRenderingContext2D imageSmoothingEnabled save/restore test</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/scripting.html#image-smoothing"> | ||
<script> | ||
function createTestImage() { | ||
var image = document.createElement('canvas'); | ||
var imgctx = image.getContext('2d'); | ||
imgctx.fillStyle = "#F00"; | ||
imgctx.fillRect(0, 0, 2, 2); | ||
imgctx.fillStyle = "#0F0"; | ||
imgctx.fillRect(0, 0, 1, 1); | ||
return image; | ||
} | ||
|
||
test(function() { | ||
var ctx = document.createElement('canvas').getContext('2d'); | ||
ctx.save(); | ||
ctx.imageSmoothingEnabled = false; | ||
ctx.restore(); | ||
assert_equals(ctx.imageSmoothingEnabled, true); | ||
}, "Test that restore() undoes any modifications to imageSmoothingEnabled."); | ||
|
||
test(function() { | ||
var ctx = document.createElement('canvas').getContext('2d'); | ||
ctx.imageSmoothingEnabled = false; | ||
var old = ctx.imageSmoothingEnabled; | ||
ctx.save(); | ||
assert_equals(ctx.imageSmoothingEnabled, old); | ||
ctx.restore(); | ||
}, "Test that save() doesn't modify the values of imageSmoothingEnabled."); | ||
|
||
test(function() { | ||
var ctx = document.createElement('canvas').getContext('2d'); | ||
ctx.imageSmoothingEnabled = false; | ||
ctx.save(); | ||
ctx.imageSmoothingEnabled = true; | ||
ctx.restore(); | ||
var image = createTestImage(); | ||
ctx.scale(10, 10); | ||
ctx.drawImage(image, 0, 0); | ||
var pixels = ctx.getImageData(0, 0, 1, 1).data; | ||
assert_array_equals(pixels, [0, 255, 0, 255]); | ||
}, "Test that restoring actually changes smoothing and not just the attribute value."); | ||
</script> |
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
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
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
Oops, something went wrong.