Add rotate filter.

This commit is contained in:
Juliusz Chroboczek
2025-04-08 15:22:56 +02:00
parent ea30dd3b40
commit c32286c42f
+16
View File
@@ -1333,6 +1333,22 @@ let filters = {
return true;
},
},
'rotate': {
description: 'Rotate',
draw: async function(src, ctx) {
if(!(ctx instanceof CanvasRenderingContext2D))
throw new Error('bad context type');
if(ctx.canvas.width !== src.videoWidth ||
ctx.canvas.height !== src.videoHeight) {
ctx.canvas.width = src.videoWidth;
ctx.canvas.height = src.videoHeight;
}
ctx.scale(-1, -1);
ctx.drawImage(src, -src.videoWidth, -src.videoHeight);
ctx.resetTransform();
return true;
},
},
'background-blur': {
description: 'Background blur',
predicate: async function() {