mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-14 13:32:23 +00:00
LibWeb: Add missing Canvas Context2D transform functions
This commit is contained in:
parent
0d7b13edac
commit
8e7d3a6acc
Notes:
sideshowbarker
2024-07-18 00:54:03 +09:00
Author: https://github.com/bplaat
Commit: 8e7d3a6acc
Pull-request: https://github.com/SerenityOS/serenity/pull/20983
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/awesomekling
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