You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to get the selection's original x,y after the canvas scale.
I have viewed the source code and googled a lot ,but I can not find a way to get it or calculte it.
Any suggestions?
Thanks a lot!
The text was updated successfully, but these errors were encountered:
If you want real image dimensions from the canvas selection you can use the following function:
setTransform(){constcropperImage=this.$refs.cropperImageasCropperImage;constcropperSelection=this.$refs.cropperSelectionasCropperSelection;// convert image matrix to image crop data (x,y,scale,rotate)constmatrix=cropperImage.$getTransform();constimageActualWidth=cropperImage.$image.width*matrix[0];constimageActualHeight=cropperImage.$image.height*matrix[3];constimageActualX=matrix[4]+(cropperImage.$image.width-imageActualWidth)/2;constimageActualY=matrix[5]+(cropperImage.$image.height-imageActualHeight)/2;constrotate=Math.round(Math.atan2(matrix[1],matrix[0])*(180/Math.PI));// convert selection to actual image dimensionsconstscaleX=imageActualWidth/cropperImage.$image.width;constscaleY=imageActualHeight/cropperImage.$image.height;constx=(cropperSelection.x-imageActualX)/scaleX;consty=(cropperSelection.y-imageActualY)/scaleY;constwidth=Math.ceil(cropperSelection.width/scaleX);constheight=Math.ceil(cropperSelection.height/scaleY);return{ x, y, width, height, rotate };}
I want to get the selection's original x,y after the canvas scale.
I have viewed the source code and googled a lot ,but I can not find a way to get it or calculte it.
Any suggestions?
Thanks a lot!
The text was updated successfully, but these errors were encountered: