Questions about ScaleAnimation (float fromX, float toX, float fromY, float toY, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue) how to set parameters
I have a small figure anywhere in the screen, assuming that the position of the four points are (l, t, r, b), width w, height h
The screen width is SW, height SH, w SW of between about 1/5 ~ 1/3, h / SH is also the approximate ratio.
When performing amplification, hope, based on the size of the original, and slowly fill the entire screen, so this parameter settings:
fromX = 1.0f
fromY = 1.0f
toX = SW / w
toY = SH / h
pivotYType = Animation.RELATIVE_TO_SELF
pivotYType = Animation.RELATIVE_TO_SELF
The key is how pivotXValue and pivotYValue should calculate it?
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
pivotXValue center coordinates and pivotYValue not it?
If your pivotYType = Animation.RELATIVE_TO_SELF then pass it
0.5F

Reply:
Pass the center should not be very appropriate, I assume that the picture is in the upper left corner, just want to see the bottom right corner downward expansion, the upper left corner remains unchanged.
Reply:
Then pass 0 chant
Reply:
Is actually a simple math problem
Scaling center is absolutely unchanged before and after scaling scaling is constant
So the following equation holds
xx / w = (l + xx) / SW = pivotXValue
Solve for xx = (l * w) / (SW - w)
pivotXValue = l / (SW - w)
Similarly
pivotYValue = t / (SH - w)
Reply:
Correct pivotYValue = t / (SH - h)
Reply:
Upstairs computing comrade answered questions, in fact, also taking into account the vast majority of small images on the screen of the window of the situation to see whether the algorithm is generic?
No comments:
Post a Comment