Sign in to follow this  
noone

Texture aspect ratio

Recommended Posts

I'm creating a sprite with random width and height but when I load the texture it stretch and not keeping the aspect ratio, see it here.

How can i fill a sprite with the texture but keep the aspect ratio?

 

Edited by noone

Share this post


Link to post
Share on other sites
8 minutes ago, ivan.popelyshev said:

pixijs doesnt have any resizing options to preserve aspect ratio. Usual stuff, after you load texture, just take "min(scale.x, scale.y)" and assign it to object scale.

Thanks for the reply ivan. Do you mind writing a code snippet on how do i got about it? 

Share this post


Link to post
Share on other sites

Here you go: https://codepen.io/ivanpopelyshev/pen/NWRPLOy

in 4.4.5 you had to do something like that use use pixi loader. in v5 you can do the following to wait for it to load: https://www.pixiplayground.com/#/edit/9z1BH9bfLlwwX4DGcn_N0

Edited by ivan.popelyshev

Share this post


Link to post
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.

Guest
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.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.