### Manipulating IMGraphic Objects

This sections provides tasks for manipulating IMGraphic objects.

### Transforming IMGraphic Objects

IMGraphic::transformBy is a pure virtual function that transforms a graphic through the given IGrafMatrix.

> virtual void transformBy(const IGrafMatrix& matrix) = 0

All concrete subclasses of IMGraphic must define this member function. You can create a local matrix or directly transform the geometry.

Subclasses that own an IGrafMatrix for manipulation must post multiply the parameter matrix with the local matrix for proper effect.

### Moving IMGraphic Objects

IMGraphic::translateBy moves the graphic by the amount specified in x and y coordinates relative to its current position (added to each point in the geometry). This is the default implementation. Your subclasses should override the default implementation to optimize for specific geometry and usage. You can use this method with baseAlignmentPoint() to move the geometry's base alignment point and the geometry.

> virtual void translateBy(const IGPoint2D&);

The figure displays a star moved by the value of amount:

### Rotating IMGraphic Objects

IMGraphic::rotateBy rotates the graphic clockwise around a center of rotation by the specified angle where:

- angle is the amount of the rotation in degrees. Positive values rotate in a clockwise direction.

- centerOfRotation determines the point around which the graphic is rotated. A center of rotation other than the center of the graphic can rotate the graphic beyond the visible area of the view. The default center of rotation is IGPoint::kOrigin (the upper-left corner of the view).

The following is an example of a call to rotateBy:

> virtual void rotateBy(
> const GDegrees,
> const IGPoint2D& centerOfRotation = IGPoint2D::kOrigin);

The result of a call to rotateBy() is the same as creating a rotation IGrafMatrix and passing it to transformBy(). This is the default implementation. Your subclasses should override the default implementation to optimize for specific geometry and usage.

The figure shows the results of rotating the star about different center of rotations:

### Scaling IMGraphic Objects

IMGraphic::scaleBy changes the size of a graphic by multiplying the graphic's coordinates by a constant value. It scales the graphic about the centerOfScale by a factor, where:

- factor determines the amount of scaling in the x and y directions for uniform (the x and y values are the same) and non-uniform (the x and y values are different) scaling.

- centerOfScale determines the point around which the graphic is scaled. A center of scale other than the center of the graphic can scale the graphic beyond the visible area of the view.

Similar to rotateBy() and translateBy(), the result of this call is the same as creating a scaling matrix and passing it to transformBy(). This is the default implementation. Your subclasses should override this default implementation to optimize for specific geometry and usage.

> virtual void scaleBy(
> const IGPoint2D& factor,
> const IGPoint2D& centerOfScale = IGPoint2D::kOrigin);

In the figure, the X coordinate of the parameter amount is (new x/ old x) and the Y coordinate is (new y/ old y). In case of uniform scaling both the X and the Y coordinate are the same. The figure also shows scaling about different centers of scale;

The effect of negative scale factors is the same as mirroring. Scaling by -1.0 in the x direction is similar to mirroring about the y-axis.A negative scale factor in the y direction is similar to mirroring about the x-axis. The figure shows the effects of scaling an asymmetric star by (-1.0, 1.0).

NOTE: Do not scale by 0.0. Scaling by 0.0 (in either X or Y) shrinks the graphic to zero and cannot be undone.