1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:47:45 +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,6 @@
1. {"x":10,"y":20,"z":0,"w":1}
2. {"x":1,"y":2,"z":3,"w":4}
3. {"a":10,"b":20,"c":30,"d":40,"e":50,"f":60,"m11":10,"m12":20,"m13":0,"m14":0,"m21":30,"m22":40,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":50,"m42":60,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
4. {"x":750,"y":1060,"z":0,"w":1}
5. {"x":750,"y":1060,"z":0,"w":1}
6. {"x":750,"y":1060,"z":0,"w":1}

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>