Graphics class provides drawing and fill operations
that can be used to paint the content of a
Graphics object for
Canvas is passed to its
paint() method and is
valid only within that method. A
Graphics object for an
Image can be obtained from its
method and remains valid as long as the
Image is referenced.
All operations on a
Graphics object use a coordinate reference
system measured in pixels, in which the origin is initially at the top-left hand
corner of the
Image. Values of the
x coordinate increase when moving to the right, while
value increase downwards. The coordinate origin may be moved by calling the
translate() method, supplying the coordinates of the new origin
relative to the current origin. Negative coordinate values are valid and, depending on
the location of the origin, may or may not correspond to points on the drawing surface.
It is permissible to move the origin to a location that is outside the drawing area.
Graphics object has an associated
which bounds the area within which graphics operations will be performed. The clipping rectangle
Image is initially set to cover the entire image, while that for
Canvas is set by the platform to cover the part of the
that needs to be repainted. Operations performed on a
Graphics object will not change pixels that lie outside clipping rectangle, even if their scope would include those pixels. Thus, setting ...