Jump to content


Recommended Posts

Hi Team,

 I am banging my head against wall from 2 days. I have a video of different sizes. User can crop video (Just showing cropping area on top  of video and getting x,y, coordinates of cropping area). End of the day using back end server I will capture cropped video until I have to mask the video as cropped. 

Lets assume video original size if 720x1280,  the size I am going to show may not be with same size (e.g. 520x292). So after cropping done, I will get the x-scale and y-scale using below formula.

var scaleX = 520/720;

var scaleY = 1280/292;

var cropX = croppedX * scaleX;

var cropY = croppedY * scaleY;

I could able get actual cropping dimensions but I could not understand how to implement scale in pixi sprite to mask as a cropped video.

I am using setTransform method but could not meet desired result.

let scaleX = (this._assetSprite.width/newMediaData.croppedDimensions.width);
let scaleY = (this._assetSprite.height/newMediaData.croppedDimensions.height);
this._assetSprite.setTransform (-(newMediaData.croppedDimensions.x * (scaleX)),
-(newMediaData.croppedDimensions.y * (scaleY)));


Link to comment
Share on other sites

It should be easy, but I dont understand, do you want to crop it or un-crop it? Can you make a simple demo that we can fix?

setTransform() just sets position and scale. If you want to crop existing texture. Depends on the case, you also have to change "sprite.texture.frame" and update its uvs.

Yes, its a very difficult task if its your first time working with Flash/PixiJS/whatever transforms and texture crops.

Welcome to the forums!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...