mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 17:17:45 +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
6
Tests/LibWeb/Text/expected/canvas/transform.txt
Normal file
6
Tests/LibWeb/Text/expected/canvas/transform.txt
Normal file
|
@ -0,0 +1,6 @@
|
|||
1. {"a":1,"b":0,"c":0,"d":1,"e":0,"f":0,"m11":1,"m12":0,"m13":0,"m14":0,"m21":0,"m22":1,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":0,"m42":0,"m43":0,"m44":1,"is2D":true,"isIdentity":true}
|
||||
2. {"a":1,"b":0,"c":0,"d":1,"e":45,"f":45,"m11":1,"m12":0,"m13":0,"m14":0,"m21":0,"m22":1,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":45,"m42":45,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
|
||||
3. {"a":2,"b":0,"c":0,"d":2,"e":45,"f":45,"m11":2,"m12":0,"m13":0,"m14":0,"m21":0,"m22":2,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":45,"m42":45,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
|
||||
4. {"a":1.0506439208984375,"b":1.7018070220947266,"c":-1.7018070220947266,"d":1.0506439208984375,"e":45,"f":45,"m11":1.0506439208984375,"m12":1.7018070220947266,"m13":0,"m14":0,"m21":-1.7018070220947266,"m22":1.0506439208984375,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":45,"m42":45,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
|
||||
5. {"a":1,"b":2,"c":3,"d":4,"e":5,"f":6,"m11":1,"m12":2,"m13":0,"m14":0,"m21":3,"m22":4,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":5,"m42":6,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
|
||||
6. {"a":1,"b":2,"c":3,"d":4,"e":5,"f":6,"m11":1,"m12":2,"m13":0,"m14":0,"m21":3,"m22":4,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":5,"m42":6,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
|
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