Java Reference
In-Depth Information
Figure 13-7.
Image anchor points
Advanced Image Rendering
The
Graphics
class also includes a
drawRegion()
method for rendering a region of an image and
possibly manipulating it at the same time. The method looks like this:
public void drawRegion(Image src,
int x_src, int y_src, int width, int height,
int transform, int x_dest, int y_dest, int anchor)
The
x_src
,
y_src
,
width
, and
height
parameters describe a rectangular region of the image
that will be rendered on the drawing surface of the
Graphics
. The region is drawn at
x_dest
and
y_dest
subject to the
anchor
, just as in the
drawImage()
method.
The
transform
parameter opens up a whole new world of possibilities. It may be any of the
transformations described by constants in the
Sprite
class, listed here. (
Sprite
is part of the
Game API and is described in the next chapter.)
•
TRANS_NONE
•
TRANS_ROT90
•
TRANS_ROT180
•
TRANS_ROT270
•
TRANS_MIRROR
•
TRANS_MIRROR_ROT90
Search WWH ::
Custom Search