mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:27:43 +00:00
LibWeb: Add missing Canvas Context2D transform functions
This commit is contained in:
parent
0d7b13edac
commit
8e7d3a6acc
4 changed files with 81 additions and 2 deletions
45
Tests/LibWeb/Text/input/canvas/transform.html
Normal file
45
Tests/LibWeb/Text/input/canvas/transform.html
Normal file
|
@ -0,0 +1,45 @@
|
|||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
let testCounter = 1;
|
||||
function testPart(part) {
|
||||
println(`${testCounter++}. ${JSON.stringify(part())}`);
|
||||
}
|
||||
|
||||
const canvas = document.createElement("canvas");
|
||||
const context = canvas.getContext("2d");
|
||||
|
||||
// 1. Default transform
|
||||
testPart(() => context.getTransform());
|
||||
|
||||
// 2. Translate transform
|
||||
testPart(() => {
|
||||
context.translate(45, 45);
|
||||
return context.getTransform();
|
||||
});
|
||||
|
||||
// 3. Scale transform
|
||||
testPart(() => {
|
||||
context.scale(2, 2);
|
||||
return context.getTransform();
|
||||
});
|
||||
|
||||
// 4. Rotate transform
|
||||
testPart(() => {
|
||||
context.rotate(45);
|
||||
return context.getTransform();
|
||||
});
|
||||
|
||||
// 5. Set transform
|
||||
testPart(() => {
|
||||
context.setTransform(1, 2, 3, 4, 5, 6);
|
||||
return context.getTransform();
|
||||
});
|
||||
|
||||
// 6. Set transform by DOMMatrix2DInit
|
||||
testPart(() => {
|
||||
context.setTransform({ a: 1, b: 2, c: 3, d: 4, e: 5, f: 6 });
|
||||
return context.getTransform();
|
||||
});
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue