1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:17:35 +00:00

LibWeb: Add DOMPoint matrixTransform and DOMMatrix transformPoint

This commit is contained in:
Bastiaan van der Plaat 2023-08-15 13:16:45 +02:00 committed by Jelle Raaijmakers
parent 38bc8836d6
commit b4ae719664
9 changed files with 106 additions and 2 deletions

View file

@ -0,0 +1,37 @@
<script src="../include.js"></script>
<script>
test(() => {
let testCounter = 1;
function testPart(part) {
println(`${testCounter++}. ${JSON.stringify(part())}`);
}
// 1. Creating a DOMPoint
testPart(() => new DOMPoint(10, 20));
// 2. Creating DOMPoint with fromPoint
testPart(() => DOMPoint.fromPoint({ x: 1, y: 2, z: 3, w: 4 }));
// 3. Creating a DOMMatrix
testPart(() => new DOMMatrix([10, 20, 30, 40, 50, 60]));
// 4. Transforming a DOMPoint using a DOMMatrix
testPart(function () {
const matrix = new DOMMatrix([10, 20, 30, 40, 50, 60]);
const point = new DOMPoint(10, 20);
return point.matrixTransform(matrix);
});
// 5. Transforming a point using a DOMMatrix
testPart(function () {
const matrix = new DOMMatrix([10, 20, 30, 40, 50, 60]);
return matrix.transformPoint(new DOMPoint(10, 20));
});
// 6. Transforming a point using a DOMMatrix
testPart(function () {
const matrix = new DOMMatrix([10, 20, 30, 40, 50, 60]);
return matrix.transformPoint({x: 10, y: 20});
});
});
</script>