pskink / matrix_gesture_detector

A gesture detector mapping translation/rotation/scale gestures to a Matrix4 object.
Other
134 stars 102 forks source link

Get xy , width and rotation angle #38

Open simranKa opened 8 months ago

simranKa commented 8 months ago

I am using this widget in video editing app. I have implemented it successfully but not getting how to get left,top, width and roatation angle to save video with watermark. This is my code:

MatrixGestureDetector( onMatrixUpdate: (m, tm, sm, rm) { controller.matrix = MatrixGestureDetector.compose(m, tm, sm, rm); notifier.value++; }, child: AspectRatio( aspectRatio: controller.aspectRatio.value != 0.0 ? controller.aspectRatio.value : controller.controller.video.value.aspectRatio, child: AnimatedBuilder( animation: notifier, builder: (ctx, child) { return Transform( transform: controller.matrix, child: MeasureSize( onChange: (Size size) { controller.size = size; }, child: FittedBox( fit: BoxFit.contain, child: controller.icon == null ? CustomPaint( painter: DottedBorderPainter(), child: Obx(() => Container( color: Color(controller.bgColor.value != 0 ? controller.bgColor.value : Colors.transparent.value), margin: const EdgeInsets.all(4), padding: const EdgeInsets.all(4), child: Center( child: Text(key: controller.textKey, controller.text, style: TextStyle(fontSize: 33.5, color: Color(controller.textColor.value != 0 ? controller.textColor.value : Colors.black.value))), ), )), ) : Container(key: controller.key, child: Image.network(controller.icon!)) ), ), ); }, ), ), )

and I have used : var x = MatrixUtils.transformRect(matrix, key.currentContext!.findRenderObject()!.paintBounds).left; var y = MatrixUtils.transformRect(matrix, key.currentContext!.findRenderObject()!.paintBounds).top;

   var width = MatrixUtils.transformRect(matrix, key.currentContext!.findRenderObject()!.paintBounds).width;

to get corrdinates and width and not sure about rotation but these are not working