Graphics Programs Reference
In-Depth Information
layers. Each element maintained its original position in the overall composition and
was surrounded by a transparent marquee (shown as a black outline here) that had
the same dimensions as the background layer.
To get the effect that we wanted, there were several problems that we had to solve.
The first was strictly two-dimensional and dealt with the general movement of the
image. We wanted the image to pan based on the position of the mouse on the Stage.
For example, if the mouse is at the position represented by the yellow dot in the top
half of Figure 11.35, then we want to move the image to its proportionally correspond-
ing point on the Stage, as shown in the lower half of Figure 11.35.
Figure 11.35 Proportional movement of the image
To get the corresponding point, we first have to calculate the scale factor involved in
scaling up from the Stage width to the image width. Since everything was centered
on the Stage, the target point in the image that corresponds to the x-position of the
mouse is given by
target = xo - scale * (_xmouse - xo)
where xo is the horizontal center of the Stage and
scale = background width/stage width
Search WWH ::




Custom Search