This is a tough one. I have a square that could be placed at any position on screen and its sides need to scale to the sides of the screen. Something like that
that doesn’t sound like “a tough one”, but it does sound like it could be better specified (and after which it might be more obvious how to approach solving it)
are you attempting to do an aspect-correct stretch (that is, you square remains a true square)? if so, then the new dimension is simply the smaller of available screen width/height, then center.
or is it: preserve the center, and scale such that the first edge, as measured from the placement center, to touch it’s corresponding screen edge is the limiting factor for all edges. that is, in your example image, it might be constrained by first hitting the right and bottom edges? (top and left edges would NOT reach screen edges) if so, similar as before - just measure all four and take the smallest.
if you need it as a scale factor (instead of an absolute dimension) then just divide desired_size by current_size.
hth
ok i get that and that does help but i dont want it to maintain its aspect ratio. i just want each edge to scale to the corresponding edge on the screen using multiple or maybe a single transition.to() function.
oh an assumption based on calling it a “square” (as it WON’T be a square if scaled non-uniformly to fit the screen)
in that case, even simpler, just transition such that x/y end up at screen center, and width/height end up display width/height. done.
beyond that, say if it’s in-between positions are not as desired *during* the transition, then you’d again want to consider and specify exactly what effect you’re after. it’s often the case that once you can exactly state the problem, then you’ve nearly already solved it! :)
oh, dont i feel silly, thanks a lot
that doesn’t sound like “a tough one”, but it does sound like it could be better specified (and after which it might be more obvious how to approach solving it)
are you attempting to do an aspect-correct stretch (that is, you square remains a true square)? if so, then the new dimension is simply the smaller of available screen width/height, then center.
or is it: preserve the center, and scale such that the first edge, as measured from the placement center, to touch it’s corresponding screen edge is the limiting factor for all edges. that is, in your example image, it might be constrained by first hitting the right and bottom edges? (top and left edges would NOT reach screen edges) if so, similar as before - just measure all four and take the smallest.
if you need it as a scale factor (instead of an absolute dimension) then just divide desired_size by current_size.
hth
ok i get that and that does help but i dont want it to maintain its aspect ratio. i just want each edge to scale to the corresponding edge on the screen using multiple or maybe a single transition.to() function.
oh an assumption based on calling it a “square” (as it WON’T be a square if scaled non-uniformly to fit the screen)
in that case, even simpler, just transition such that x/y end up at screen center, and width/height end up display width/height. done.
beyond that, say if it’s in-between positions are not as desired *during* the transition, then you’d again want to consider and specify exactly what effect you’re after. it’s often the case that once you can exactly state the problem, then you’ve nearly already solved it! :)
oh, dont i feel silly, thanks a lot