GraphicImage Template
copyRectRotate()
Rotate a rectangular area of a source image into a destination image
Syntax
GraphicImage = rb.GraphicImage.copyRectRotate(src_image, angle, source_rect, centre)
Parameters
The 'copyRectRotate' method takes 4 parameters:
Name | Type/Value | Range/Length | Description | src_image | struct GraphicImage | see definition | Required.
Image from which the area should be copied. The source image is not changed by this operation
| angle | number | | | source_rect | struct Rectangle | see definition | Optional, default = whole image
Specifies the area of the source image to be copied. If this parameter is missing or null then the method will copy the whole of the source image
| centre | struct Point | see definition | Optional, default = Centre of rotation within the target image
Specifies the area in the destination image into which the source rectangle is to be copied.
If missing or null then the same rectangle as the source is used. If width and height are different
then the rectangle will be resized.
|
Results
The 'copyRectRotate' method returns GraphicImage:
Type/Value | Range/Length | Description |
GraphicImage |
  |
A reference to the source image
|
Remarks copyRectRotate allows applications to rotate areas of one image by an arbitrary number
of degrees into a target image. The source and destination image *can* be the same,
but the results if the copied region does not overlap the source. It is recommended that
a scratch image be created into which to rotate the source. The only mandatory parameter is the target image into which a rectangle from the source image is to be
copied. Defaults- angle
This defaults to zero degrees, although the default itself is not particularly useful! It
is recommended that the angle be specified. - source_rect
Defaults to the whole of the source image - centre
Defaults to the centre of the destination image
Example To rotate an image by 90 degrees :
var src = new GraphicImage;
src.make('/images/sample.gif','image/gif');
var image_rotated = new GraphicImage;
// Create a canvas in the destination that has the source width
// and height transposed.
image_rotated.create(src.height, src.width);
// Because we want the whole of the source image copied, rotated round the
// centre of the destination image the only parameters we need are the
// destination and the angle.
src.copyRectRotate(image_rotated, 90);
|