diff --git a/src/modules/qt/filter_qtblend.cpp b/src/modules/qt/filter_qtblend.cpp index ec34d422d4..07038b534e 100644 --- a/src/modules/qt/filter_qtblend.cpp +++ b/src/modules/qt/filter_qtblend.cpp @@ -166,12 +166,23 @@ static int filter_get_image(mlt_frame frame, if (mlt_properties_get(properties, "rotation")) { double angle = mlt_properties_anim_get_double(properties, "rotation", position, length); if (angle != 0.0) { - if (mlt_properties_get_int(properties, "rotate_center")) { + if (mlt_properties_get(properties, "rotate_anchor")) { + mlt_rect anchor + = mlt_properties_anim_get_rect(properties, "rotate_anchor", position, length); + // Use custom anchor point (x,y are normalized 0-1 coordinates) where 0, 0 is top left and 1, 1 is bottom right + // negative values are allowed so its possible to rotate around a point outside the rectangle + double anchor_x = anchor.x * rect.w; + double anchor_y = anchor.y * rect.h; + transform.translate(anchor_x, anchor_y); + transform.rotate(angle); + transform.translate(-anchor_x, -anchor_y); + } else if (mlt_properties_get_int(properties, "rotate_center")) { + // old style rotation (from center) to keep compatibility, equivalent to rotate_anchor = 0.5, 0.5 transform.translate(rect.w / 2.0, rect.h / 2.0); transform.rotate(angle); transform.translate(-rect.w / 2.0, -rect.h / 2.0); } else { - // old style rotation (from top left corner) to keep compatibility + // old style rotation (from top left corner) to keep compatibility, equivalent to rotate_anchor = 0, 0 transform.rotate(angle); } hasAlpha = true; diff --git a/src/modules/qt/filter_qtblend.yml b/src/modules/qt/filter_qtblend.yml index 461d3ae3ae..35fad5bf84 100644 --- a/src/modules/qt/filter_qtblend.yml +++ b/src/modules/qt/filter_qtblend.yml @@ -2,7 +2,7 @@ schema_version: 7.0 type: filter identifier: qtblend title: Composite and transform -version: 2 +version: 3 copyright: Meltytech, LLC creator: Jean-Baptiste Mardelle license: LGPLv2.1 @@ -56,6 +56,16 @@ parameters: mutable: yes widget: checkbox + - identifier: rotate_anchor + title: Rotation anchor point + type: rect + description: > + Keyframable anchor point for rotation. X and Y coordinates define the rotation center. + Values are normalized (0-1 for inside rectangle, negative or >1 for outside). + Default is center (0.5, 0.5). Takes precedence over rotate_center when set. + mutable: yes + animation: yes + - identifier: background_color title: Background color type: integer