Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
hospadam

Resetting Scale on Image? [SOLVED]

Recommended Posts

Hey There - I think I have a fairly straight-forward question. In my application, I'm offering the user the ability to either use an Image from Flickr, or a personal image they've uploaded. Well, when they switch between one or the other, I'm using the same image object, and just changing the source.

 

The problem I'm running into is thatthe images are different resolutions. So lets say a user uploads a 400x400 personal image. They use transform manager, and they make it take up the full canvas. Then they want to switch to their Flickr image. Well, their Flickr Image might be 2000x2000. At the same scale, when the URL is changed, it's huge, and goes off the canvas (even though they're both scaled to .1 for example).

 

Is there a way to contrain the new Image to the bounding box of the existing image on the canvas?

 

I'm sorry if that doesn't make sense. Does anyone have any ideas? or any other "Creative" solutions? Thanks in advance!!

Link to comment
Share on other sites

Yeah, sorry, but you'll need to do the math when you load the new image to figure out what the scale needs to be in order to fit the width/height you need. Something like newScaleX = oldWidth / newWidth and newScaleY = oldHeight / newHeight

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×