/// <summary> /// Applies a clockwise rotation of the specified angle about the /// origin to this <see cref="SvgTransformF"/>, and in the order specified /// in the order parameter. /// </summary> /// <param name="angle"> /// The angle (extent) of the rotation, in degrees. /// </param> /// <param name="order"> /// A <see cref="TransformOrder"/> that specifies the order (append or /// prepend) in which the rotation is applied to this /// <see cref="SvgTransformF"/>. /// </param> public void Rotate(float angle, SvgTransformOrder order) { double radians = (angle * (Math.PI / 180.0)); float cos = (float)(Math.Cos(radians)); float sin = (float)(Math.Sin(radians)); if (order == SvgTransformOrder.Prepend) { float nm11 = cos * this.m11 + sin * this.m21; float nm12 = cos * this.m12 + sin * this.m22; float nm21 = cos * this.m21 - sin * this.m11; float nm22 = cos * this.m22 - sin * this.m12; this.m11 = nm11; this.m12 = nm12; this.m21 = nm21; this.m22 = nm22; } else { float nm11 = this.m11 * cos - this.m12 * sin; float nm12 = this.m11 * sin + this.m12 * cos; float nm21 = this.m21 * cos - this.m22 * sin; float nm22 = this.m21 * sin + this.m22 * cos; float ndx = this.dx * cos - this.dy * sin; float ndy = this.dx * sin + this.dy * cos; this.m11 = nm11; this.m12 = nm12; this.m21 = nm21; this.m22 = nm22; this.dx = ndx; this.dy = ndy; } }
/// <summary> /// Applies a clockwise rotation about the specified point to this /// <see cref="SvgTransformF"/> in the specified order. /// </summary> /// <param name="angle"> /// The angle (extent) of the rotation, in degrees. /// </param> /// <param name="point"> /// A <see cref="SvgPointF"/> that represents the center of the rotation. /// </param> /// <param name="order"> /// A <see cref="TransformOrder"/> that specifies the order (append or /// prepend) in which the rotation is applied. /// </param> public void RotateAt(float angle, SvgPointF point, SvgTransformOrder order) { if (order == SvgTransformOrder.Prepend) { Translate(point.X, point.Y); Rotate(angle); Translate(-point.X, -point.Y); } else { Translate(-point.X, -point.Y); Rotate(angle, SvgTransformOrder.Append); Translate(point.X, point.Y); } }
/// <summary> /// Multiplies this <see cref="SvgTransformF"/> by the matrix specified in /// the matrix parameter, and in the order specified in the order parameter. /// </summary> /// <param name="matrix"> /// The <see cref="SvgTransformF"/> by which this <see cref="SvgTransformF"/> /// is to be multiplied. /// </param> /// <param name="order"> /// The <see cref="TransformOrder"/> that represents the order of the /// multiplication. /// </param> public void Multiply(SvgTransformF matrix, SvgTransformOrder order) { if (matrix == null) { throw new ArgumentNullException("matrix"); } if (order == SvgTransformOrder.Prepend) { Multiply((SvgTransformF)matrix, this); } else { Multiply(this, (SvgTransformF)matrix); } }
/// <summary> /// Applies the specified scale vector to this <see cref="SvgTransformF"/> /// using the specified order. /// </summary> /// <param name="scaleX"> /// The value by which to scale this <see cref="SvgTransformF"/> in the /// x-axis direction. /// </param> /// <param name="scaleY"> /// The value by which to scale this <see cref="SvgTransformF"/> in the /// y-axis direction. /// </param> /// <param name="order"> /// A <see cref="TransformOrder"/> that specifies the order (append or /// prepend) in which the scale vector is applied to this /// <see cref="SvgTransformF"/>. /// </param> public void Scale(float scaleX, float scaleY, SvgTransformOrder order) { if (order == SvgTransformOrder.Prepend) { m11 *= scaleX; m12 *= scaleX; m21 *= scaleY; m22 *= scaleY; } else { m11 *= scaleX; m12 *= scaleY; m21 *= scaleX; m22 *= scaleY; dx *= scaleX; dy *= scaleY; } }
/// <summary> /// Applies the specified translation vector to this <see cref="SvgTransformF"/> /// in the specified order. /// </summary> /// <param name="offsetX"> /// The <c>x</c> value by which to translate this <see cref="SvgTransformF"/>. /// </param> /// <param name="offsetY"> /// The <c>y</c> value by which to translate this <see cref="SvgTransformF"/>. /// </param> /// <param name="order"> /// A <see cref="TransformOrder"/> that specifies the order (append or /// prepend) in which the translation is applied to this <see cref="SvgTransformF"/>. /// </param> public void Translate(float offsetX, float offsetY, SvgTransformOrder order) { if (order == SvgTransformOrder.Prepend) { dx += offsetX * m11 + offsetY * m21; dy += offsetX * m12 + offsetY * m22; } else { dx += offsetX; dy += offsetY; } }
/// <summary> /// Applies the specified shear vector to this <see cref="SvgTransformF"/> in /// the specified order. /// </summary> /// <param name="shearX"> /// The horizontal shear factor. /// </param> /// <param name="shearY"> /// The vertical shear factor. /// </param> /// <param name="order"> /// A <see cref="TransformOrder"/> that specifies the order (append or /// prepend) in which the shear is applied. /// </param> public void Shear(float shearX, float shearY, SvgTransformOrder order) { if (order == SvgTransformOrder.Prepend) { float nm11 = this.m11 + this.m21 * shearY; float nm12 = this.m12 + this.m22 * shearY; float nm21 = this.m11 * shearX + this.m21; float nm22 = this.m12 * shearX + this.m22; this.m11 = nm11; this.m12 = nm12; this.m21 = nm21; this.m22 = nm22; } else { float nm11 = this.m11 + this.m12 * shearX; float nm12 = this.m11 * shearY + this.m12; float nm21 = this.m21 + this.m22 * shearX; float nm22 = this.m21 * shearY + this.m22; float ndx = this.dx + this.dy * shearX; float ndy = this.dx * shearY + this.dy; this.m11 = nm11; this.m12 = nm12; this.m21 = nm21; this.m22 = nm22; this.dx = ndx; this.dy = ndy; } }