/// <summary> /// Modifies the current transformation matrix. /// </summary> public void MultiplyTransform(XMatrix matrix, XMatrixOrder order) { if (!matrix.IsIdentity) { this.MustRealizeCtm = true; this.unrealizedCtm.Multiply(matrix, order); } }
///// <summary> ///// The world transform in PDF world space. ///// </summary> //public XMatrix EffectiveCtm //{ // get // { // //if (MustRealizeCtm) // if (!UnrealizedCtm.IsIdentity) // { // XMatrix matrix = RealizedCtm; // matrix.Prepend(UnrealizedCtm); // return matrix; // } // return RealizedCtm; // } // //set // //{ // // XMatrix matrix = realizedCtm; // // matrix.Invert(); // // matrix.Prepend(value); // // unrealizedCtm = matrix; // // MustRealizeCtm = !unrealizedCtm.IsIdentity; // //} //} public void AddTransform(XMatrix value, XMatrixOrder matrixOrder) { // TODO: User matrixOrder //#if DEBUG // if (matrixOrder == XMatrixOrder.Append) // throw new NotImplementedException("XMatrixOrder.Append"); //#endif XMatrix transform = value; if (_renderer.Gfx.PageDirection == XPageDirection.Downwards) { // Take chirality into account and // invert the direction of rotation. transform.M12 = -value.M12; transform.M21 = -value.M21; } UnrealizedCtm.Prepend(transform); WorldTransform.Prepend(value); }
/// <summary> /// Applies the specified shearing operation to the transformation matrix of this object /// in the specified order. /// </summary> public void ShearTransform(double shearX, double shearY, XMatrixOrder order) { XMatrix matrix = new XMatrix(); //XMatrix.Identity; matrix.ShearPrepend(shearX, shearY); AddTransform(matrix, order); }
/// <summary> /// Applies the specified rotation operation to the transformation matrix of this object /// in the specified order. The angle unit of measure is degree. /// </summary> public void RotateTransform(double angle, XMatrixOrder order) { //XMatrix matrix = this.transform; //matrix.Rotate(angle, order); //Transform = matrix; XMatrix matrix = new XMatrix(); //XMatrix.Identity; matrix.RotatePrepend(angle); AddTransform(matrix, order); }
/// <summary> /// Applies the specified translation operation to the transformation matrix of this object /// in the specified order. /// </summary> public void TranslateTransform(double dx, double dy, XMatrixOrder order) { //XMatrix matrix = this.transform; //matrix.Translate(dx, dy, order); //Transform = matrix; XMatrix matrix = new XMatrix(); //XMatrix.Identity; matrix.TranslatePrepend(dx, dy); AddTransform(matrix, order); }
/// <summary> /// Rotates the matrix with the specified angle at the specified point. /// </summary> public void RotateAt(double angle, XPoint point, XMatrixOrder order) { if (order == XMatrixOrder.Append) { angle = angle % 360.0; this *= CreateRotationRadians(angle * 0.017453292519943295, point.x, point.y); //this.Translate(point.X, point.Y, order); //this.Rotate(angle, order); //this.Translate(-point.X, -point.Y, order); } else { angle = angle % 360.0; this = CreateRotationRadians(angle * 0.017453292519943295, point.x, point.y) * this; } DeriveMatrixType(); }
/// <summary> /// Scales the matrix with the specified scalar. /// </summary> public void Scale(double scaleXY, XMatrixOrder order) { Scale(scaleXY, scaleXY, order); }
/// <summary> /// Translates the matrix with the specified offsets. /// </summary> public void Translate(double offsetX, double offsetY, XMatrixOrder order) { // HACK in Translate if (this.type == XMatrixTypes.Identity) InitIdentity(); if (order == XMatrixOrder.Append) { this.offsetX += offsetX; this.offsetY += offsetY; } else { this.offsetX += offsetX * this.m11 + offsetY * this.m21; this.offsetY += offsetX * this.m12 + offsetY * this.m22; } DeriveMatrixType(); }
/// <summary> /// Multiply the brush transformation matrix with the specified matrix. /// </summary> public void MultiplyTransform(XMatrix matrix, XMatrixOrder order) { _matrix.Multiply(matrix, order); }
/// <summary> /// Scales the brush with the specified scalars. /// </summary> public void ScaleTransform(double sx, double sy, XMatrixOrder order) { this.matrix.Scale(sx, sy, order); }
/// <summary> /// Translates the brush with the specified offset. /// </summary> public void TranslateTransform(double dx, double dy, XMatrixOrder order) { this.matrix.Translate(dx, dy, order); }
/// <summary> /// Shears the matrix with the specified scalars. /// </summary> public void Shear(double shearX, double shearY, XMatrixOrder order) { double t11 = this.m11; double t12 = this.m12; double t21 = this.m21; double t22 = this.m22; double tdx = this.offsetX; double tdy = this.offsetY; if (order == XMatrixOrder.Append) { this.m11 += shearX * t12; this.m12 += shearY * t11; this.m21 += shearX * t22; this.m22 += shearY * t21; this.offsetX += shearX * tdy; this.offsetY += shearY * tdx; } else { this.m11 += shearY * t21; this.m12 += shearY * t22; this.m21 += shearX * t11; this.m22 += shearX * t12; } DeriveMatrixType(); }
/// <summary> /// Scales the matrix with the specified scalars. /// </summary> public void Scale(double scaleX, double scaleY, XMatrixOrder order) { if (order == XMatrixOrder.Append) { this.m11 *= scaleX; this.m12 *= scaleY; this.m21 *= scaleX; this.m22 *= scaleY; this.offsetX *= scaleX; this.offsetY *= scaleY; } else { this.m11 *= scaleX; this.m12 *= scaleX; this.m21 *= scaleY; this.m22 *= scaleY; } DeriveMatrixType(); }
/// <summary> /// Translates the matrix with the specified offsets. /// </summary> public void Translate(double offsetX, double offsetY, XMatrixOrder order) { if (order == XMatrixOrder.Append) { this.offsetX += offsetX; this.offsetY += offsetY; } else { this.offsetX += offsetX * this.m11 + offsetY * this.m21; this.offsetY += offsetX * this.m12 + offsetY * this.m22; } DeriveMatrixType(); }
/// <summary> /// Gets or sets the transformation matrix. /// </summary> void AddTransform(XMatrix transform, XMatrixOrder order) { //if (!this.transform.Equals(value)) { XMatrix matrix = this.transform; matrix.Multiply(transform, order); this.transform = matrix; matrix = this.defaultViewMatrix; matrix.Multiply(this.transform, XMatrixOrder.Prepend); #if GDI if (this.targetContext == XGraphicTargetContext.GDI) { #if DEBUG System.Drawing.Drawing2D.Matrix m = (System.Drawing.Drawing2D.Matrix)matrix; this.gfx.Transform = m; #else this.gfx.Transform = (System.Drawing.Drawing2D.Matrix)matrix; #endif } #endif #if WPF if (this.targetContext == XGraphicTargetContext.WPF) { #if !SILVERLIGHT MatrixTransform mt = new MatrixTransform(transform.ToWpfMatrix()); #else MatrixTransform mt = new MatrixTransform(); mt.Matrix = transform.ToWpfMatrix(); #endif if (order == XMatrixOrder.Append) mt = (MatrixTransform)mt.Inverse; this.gsStack.Current.SetTransform(mt); } #endif if (this.renderer != null) this.renderer.Transform = this.transform; } }
/// <summary> /// Scales the brush with the specified scalars. /// </summary> public void ScaleTransform(double sx, double sy, XMatrixOrder order) { _matrix.Scale(sx, sy, order); }
/// <summary> /// Rotates the brush with the specified angle. /// </summary> public void RotateTransform(double angle, XMatrixOrder order) { this.matrix.Rotate(angle, order); }
/// <summary> /// Multiply the brush transformation matrix with the specified matrix. /// </summary> public void MultiplyTransform(XMatrix matrix, XMatrixOrder order) { this.matrix.Multiply(matrix, order); }
public void AddTransform(XMatrix value, XMatrixOrder matrixOrder) { _gfxState.AddTransform(value, matrixOrder); }
/// <summary> /// Scales the matrix with the specified scalars. /// </summary> public void Scale(double scaleX, double scaleY, XMatrixOrder order) { // HACK in Scale if (this.type == XMatrixTypes.Identity) InitIdentity(); if (order == XMatrixOrder.Append) { this.m11 *= scaleX; this.m12 *= scaleY; this.m21 *= scaleX; this.m22 *= scaleY; this.offsetX *= scaleX; this.offsetY *= scaleY; } else { this.m11 *= scaleX; this.m12 *= scaleX; this.m21 *= scaleY; this.m22 *= scaleY; } DeriveMatrixType(); }
/// <summary> /// Multiplies this matrix with the specified matrix. /// </summary> public void Multiply(XMatrix matrix, XMatrixOrder order) { if (_type == XMatrixTypes.Identity) this = CreateIdentity(); // Must use properties, the fields can be invalid if the matrix is identity matrix. double t11 = M11; double t12 = M12; double t21 = M21; double t22 = M22; double tdx = OffsetX; double tdy = OffsetY; if (order == XMatrixOrder.Append) { _m11 = t11 * matrix.M11 + t12 * matrix.M21; _m12 = t11 * matrix.M12 + t12 * matrix.M22; _m21 = t21 * matrix.M11 + t22 * matrix.M21; _m22 = t21 * matrix.M12 + t22 * matrix.M22; _offsetX = tdx * matrix.M11 + tdy * matrix.M21 + matrix.OffsetX; _offsetY = tdx * matrix.M12 + tdy * matrix.M22 + matrix.OffsetY; } else { _m11 = t11 * matrix.M11 + t21 * matrix.M12; _m12 = t12 * matrix.M11 + t22 * matrix.M12; _m21 = t11 * matrix.M21 + t21 * matrix.M22; _m22 = t12 * matrix.M21 + t22 * matrix.M22; _offsetX = t11 * matrix.OffsetX + t21 * matrix.OffsetY + tdx; _offsetY = t12 * matrix.OffsetX + t22 * matrix.OffsetY + tdy; } DeriveMatrixType(); }
/// <summary> /// Rotates the matrix with the specified angle. /// </summary> public void Rotate(double angle, XMatrixOrder order) { // HACK in Rotate if (this.type == XMatrixTypes.Identity) InitIdentity(); angle = angle * Calc.Deg2Rad; double cos = Math.Cos(angle); double sin = Math.Sin(angle); if (order == XMatrixOrder.Append) { double t11 = this.m11; double t12 = this.m12; double t21 = this.m21; double t22 = this.m22; double tdx = this.offsetX; double tdy = this.offsetY; this.m11 = t11 * cos - t12 * sin; this.m12 = t11 * sin + t12 * cos; this.m21 = t21 * cos - t22 * sin; this.m22 = t21 * sin + t22 * cos; this.offsetX = tdx * cos - tdy * sin; this.offsetY = tdx * sin + tdy * cos; } else { double t11 = this.m11; double t12 = this.m12; double t21 = this.m21; double t22 = this.m22; this.m11 = t11 * cos + t21 * sin; this.m12 = t12 * cos + t22 * sin; this.m21 = -t11 * sin + t21 * cos; this.m22 = -t12 * sin + t22 * cos; } DeriveMatrixType(); }
/// <summary> /// Translates the matrix with the specified offsets. /// </summary> public void Translate(double offsetX, double offsetY, XMatrixOrder order) { if (_type == XMatrixTypes.Identity) this = CreateIdentity(); if (order == XMatrixOrder.Append) { _offsetX += offsetX; _offsetY += offsetY; } else { _offsetX += offsetX * _m11 + offsetY * _m21; _offsetY += offsetX * _m12 + offsetY * _m22; } DeriveMatrixType(); }
/// <summary> /// Shears the matrix with the specified scalars. /// </summary> public void Shear(double shearX, double shearY, XMatrixOrder order) { // HACK in Shear if (this.type == XMatrixTypes.Identity) InitIdentity(); double t11 = this.m11; double t12 = this.m12; double t21 = this.m21; double t22 = this.m22; double tdx = this.offsetX; double tdy = this.offsetY; if (order == XMatrixOrder.Append) { this.m11 += shearX * t12; this.m12 += shearY * t11; this.m21 += shearX * t22; this.m22 += shearY * t21; this.offsetX += shearX * tdy; this.offsetY += shearY * tdx; } else { this.m11 += shearY * t21; this.m12 += shearY * t22; this.m21 += shearX * t11; this.m22 += shearX * t12; } DeriveMatrixType(); }
/// <summary> /// Scales the matrix with the specified scalars. /// </summary> public void Scale(double scaleX, double scaleY, XMatrixOrder order) { if (_type == XMatrixTypes.Identity) this = CreateIdentity(); if (order == XMatrixOrder.Append) { _m11 *= scaleX; _m12 *= scaleY; _m21 *= scaleX; _m22 *= scaleY; _offsetX *= scaleX; _offsetY *= scaleY; } else { _m11 *= scaleX; _m12 *= scaleX; _m21 *= scaleY; _m22 *= scaleY; } DeriveMatrixType(); }
/// <summary> /// Applies the specified scaling operation to the transformation matrix of this object /// in the specified order. /// </summary> public void ScaleTransform(double scaleXY, XMatrixOrder order) { //XMatrix matrix = this.transform; //matrix.Scale(scaleXY, scaleXY, order); //Transform = matrix; XMatrix matrix = new XMatrix(); //XMatrix.Identity; matrix.ScalePrepend(scaleXY, scaleXY); AddTransform(matrix, order); }
/// <summary> /// Scales the matrix with the specified scalar. /// </summary> // ReSharper disable InconsistentNaming public void Scale(double scaleXY, XMatrixOrder order) // ReSharper restore InconsistentNaming { Scale(scaleXY, scaleXY, order); }
/// <summary> /// Applies the specified rotation operation to the transformation matrix of this object by /// prepending it to the object's transformation matrix. /// </summary> public void RotateAtTransform(double angle, XPoint point, XMatrixOrder order) { //XMatrix matrix = this.transform; //matrix.RotateAt(angle, point, order); //Transform = matrix; XMatrix matrix = new XMatrix(); //XMatrix.Identity; matrix.RotateAtPrepend(angle, point); AddTransform(matrix, order); }
/// <summary> /// Rotates the matrix with the specified angle. /// </summary> public void Rotate(double angle, XMatrixOrder order) { if (_type == XMatrixTypes.Identity) this = CreateIdentity(); angle = angle * Const.Deg2Rad; double cos = Math.Cos(angle); double sin = Math.Sin(angle); if (order == XMatrixOrder.Append) { double t11 = _m11; double t12 = _m12; double t21 = _m21; double t22 = _m22; double tdx = _offsetX; double tdy = _offsetY; _m11 = t11 * cos - t12 * sin; _m12 = t11 * sin + t12 * cos; _m21 = t21 * cos - t22 * sin; _m22 = t21 * sin + t22 * cos; _offsetX = tdx * cos - tdy * sin; _offsetY = tdx * sin + tdy * cos; } else { double t11 = _m11; double t12 = _m12; double t21 = _m21; double t22 = _m22; _m11 = t11 * cos + t21 * sin; _m12 = t12 * cos + t22 * sin; _m21 = -t11 * sin + t21 * cos; _m22 = -t12 * sin + t22 * cos; } DeriveMatrixType(); }
/// <summary> /// Multiplies the transformation matrix of this object and specified matrix in the specified order. /// </summary> public void MultiplyTransform(XMatrix matrix, XMatrixOrder order) { //XMatrix matrix2 = this.transform; //matrix2.Multiply(matrix, order); //Transform = matrix2; XMatrix matrix2 = new XMatrix(); //XMatrix.Identity; matrix2.Prepend(matrix); AddTransform(matrix2, order); }
/// <summary> /// Rotates the matrix with the specified angle at the specified point. /// </summary> public void RotateAt(double angle, XPoint point, XMatrixOrder order) { if (order == XMatrixOrder.Append) { angle = angle % 360.0; this *= CreateRotationRadians(angle * Const.Deg2Rad, point.X, point.Y); //Translate(point.X, point.Y, order); //Rotate(angle, order); //Translate(-point.X, -point.Y, order); } else { angle = angle % 360.0; this = CreateRotationRadians(angle * Const.Deg2Rad, point.X, point.Y) * this; } DeriveMatrixType(); }
/// <summary> /// Shears the matrix with the specified scalars. /// </summary> public void Shear(double shearX, double shearY, XMatrixOrder order) { if (_type == XMatrixTypes.Identity) this = CreateIdentity(); double t11 = _m11; double t12 = _m12; double t21 = _m21; double t22 = _m22; double tdx = _offsetX; double tdy = _offsetY; if (order == XMatrixOrder.Append) { _m11 += shearX * t12; _m12 += shearY * t11; _m21 += shearX * t22; _m22 += shearY * t21; _offsetX += shearX * tdy; _offsetY += shearY * tdx; } else { _m11 += shearY * t21; _m12 += shearY * t22; _m21 += shearX * t11; _m22 += shearX * t12; } DeriveMatrixType(); }
/// <summary> /// Rotates the brush with the specified angle. /// </summary> public void RotateTransform(double angle, XMatrixOrder order) { _matrix.Rotate(angle, order); }
/// <summary> /// Multiplies this matrix with the specified matrix. /// </summary> public void Multiply(XMatrix matrix, XMatrixOrder order) { // HACK in Multiply if (this.type == XMatrixTypes.Identity) InitIdentity(); // Must use properties, the fields can be invalid if the matrix is identity matrix. double t11 = M11; double t12 = M12; double t21 = M21; double t22 = M22; double tdx = OffsetX; double tdy = OffsetY; if (order == XMatrixOrder.Append) { this.m11 = t11 * matrix.M11 + t12 * matrix.M21; this.m12 = t11 * matrix.M12 + t12 * matrix.M22; this.m21 = t21 * matrix.M11 + t22 * matrix.M21; this.m22 = t21 * matrix.M12 + t22 * matrix.M22; this.offsetX = tdx * matrix.M11 + tdy * matrix.M21 + matrix.OffsetX; this.offsetY = tdx * matrix.M12 + tdy * matrix.M22 + matrix.OffsetY; } else { this.m11 = t11 * matrix.M11 + t21 * matrix.M12; this.m12 = t12 * matrix.M11 + t22 * matrix.M12; this.m21 = t11 * matrix.M21 + t21 * matrix.M22; this.m22 = t12 * matrix.M21 + t22 * matrix.M22; this.offsetX = t11 * matrix.OffsetX + t21 * matrix.OffsetY + tdx; this.offsetY = t12 * matrix.OffsetX + t22 * matrix.OffsetY + tdy; } DeriveMatrixType(); }
/// <summary> /// Translates the brush with the specified offset. /// </summary> public void TranslateTransform(double dx, double dy, XMatrixOrder order) { _matrix.Translate(dx, dy, order); }
public void AddTransform(XMatrix transform, XMatrixOrder matrixOrder) { }