private void AddLineCap(PointFP p1, PointFP p2, int lineCap) { if (lineCap == PenFP.LINECAP_BUTT || p1.Equals(p2)) { return; } var dx = p2.X - p1.X; var dy = p2.Y - p1.Y; var len = PointFP.Distance(dx, dy); var cap = lineCap == PenFP.LINECAP_ROUND ? GraphicsPathFP.ROUNDCAP : GraphicsPathFP.SQUARECAP; dx = MathFP.Mul(_ffRad, MathFP.Div(dx, len)); dy = MathFP.Mul(_ffRad, MathFP.Div(dy, len)); var m = new MatrixFP(dx, dx, dy, -dy, p2.X, p2.Y); _outline.AddMoveTo(new PointFP(0, GraphicsPathFP.ONE).Transform(m)); for (var i = 0; i < cap.Length; i++) { _outline.AddLineTo(new PointFP(cap[i]).Transform(m)); } _outline.AddLineTo(new PointFP(0, -GraphicsPathFP.ONE).Transform(m)); _outline.AddClose(); }
private void AddLineCap(PointFP p1, PointFP p2, int lineCap) { if (lineCap == PenFP.LINECAP_BUTT || p1.Equals(p2)) { return; } int dx = p2.X - p1.X; int dy = p2.Y - p1.Y; int len = PointFP.Distance(dx, dy); PointFP[] cap = lineCap == PenFP.LINECAP_ROUND?GraphicsPathFP.roundCap:GraphicsPathFP.squareCap; dx = MathFP.Mul(ff_rad, MathFP.Div(dx, len)); dy = MathFP.Mul(ff_rad, MathFP.Div(dy, len)); MatrixFP m = new MatrixFP(dx, dx, dy, -dy, p2.X, p2.Y); outline.AddMoveTo(new PointFP(0, GraphicsPathFP.One).Transform(m)); for (int i = 0; i < cap.Length; i++) { outline.AddLineTo(new PointFP(cap[i]).Transform(m)); } outline.AddLineTo(new PointFP(0, -GraphicsPathFP.One).Transform(m)); outline.AddClose(); }
public void ScanPath(GraphicsPathFP path, MatrixFP matrix, int mode) { scanIndex = 0; drawMode = mode; transformMatrix = matrix; path.Visit(this); transformMatrix = null; RadixSort(scanbuf, scanbuf_tmp, scanIndex); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Set the graphics matrix. * @param Value the graphics matrix. */ internal void SetGraphicsMatrix(MatrixFP value) { _graphicsMatrix = new MatrixFP(value); _graphicsMatrix.Invert(); _finalMatrix = new MatrixFP(_graphicsMatrix); if (_matrix != null) { _finalMatrix.Multiply(_matrix); } }
public MatrixX(float m11, float m12, float m21, float m22, float dx, float dy) { matrix = new MatrixFP( SingleFP.FromFloat(m11), SingleFP.FromFloat(m22), SingleFP.FromFloat(m12), SingleFP.FromFloat(m21), SingleFP.FromFloat(dx), SingleFP.FromFloat(dy)); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * multipy with another matrix. * @param m * @return */ public MatrixFP Multiply(MatrixFP m) { Reset(MathFP.Mul(m.ScaleX, ScaleX) + MathFP.Mul(m.RotateY, RotateX), MathFP.Mul(m.RotateX, RotateY) + MathFP.Mul(m.ScaleY, ScaleY), MathFP.Mul(m.RotateX, ScaleX) + MathFP.Mul(m.ScaleY, RotateX), MathFP.Mul(m.ScaleX, RotateY) + MathFP.Mul(m.RotateY, ScaleY), MathFP.Mul(m.ScaleX, TranslateX) + MathFP.Mul(m.RotateY, TranslateY) + m.TranslateX, MathFP.Mul(m.RotateX, TranslateX) + MathFP.Mul(m.ScaleY, TranslateY) + m.TranslateY); return(this); }
public void Multiply(MatrixX m, MatrixOrderX order) { if (order == MatrixOrderX.Prepend) { MatrixFP m1 = new MatrixFP(m.matrix); m1.Multiply(matrix); matrix = m1; } else { matrix.Multiply(m.matrix); } }
public void Shear(float shearX, float shearY, MatrixOrderX order) { if (order == MatrixOrderX.Prepend) { MatrixFP m = MatrixFP.Identity(); m.RotateSkew(SingleFP.FromFloat(shearX), SingleFP.FromFloat(shearY)); m.Multiply(matrix); matrix = m; } else { matrix.RotateSkew(SingleFP.FromFloat(shearX), SingleFP.FromFloat(shearY)); } }
public void Scale(float scaleX, float scaleY, MatrixOrderX order) { if (order == MatrixOrderX.Prepend) { MatrixFP m = MatrixFP.Identity(); m.Scale(SingleFP.FromFloat(scaleX), SingleFP.FromFloat(scaleY)); m.Multiply(matrix); matrix = m; } else { matrix.Scale(SingleFP.FromFloat(scaleX), SingleFP.FromFloat(scaleY)); } }
public void Rotate(float angle, MatrixOrderX order) { if (order == MatrixOrderX.Prepend) { MatrixFP m = MatrixFP.Identity(); m.Rotate(MathFP.ToRadians(SingleFP.FromFloat(angle))); m.Multiply(matrix); matrix = m; } else { matrix.Rotate(MathFP.ToRadians(SingleFP.FromFloat(angle))); } }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Transform with a new matrix. * @param m1 a new matrix. */ public void Transform(MatrixFP m1) { var m = new MatrixFP(m1); m.Invert(); if (_matrix == null) { _matrix = m; } else { _matrix.Multiply(m); } }
public void Translate(float offsetX, float offsetY, MatrixOrderX order) { if (order == MatrixOrderX.Prepend) { MatrixFP m = MatrixFP.Identity(); m.Translate(SingleFP.FromFloat(offsetX), SingleFP.FromFloat(offsetY)); m.Multiply(matrix); matrix = m; } else { matrix.Translate(SingleFP.FromFloat(offsetX), SingleFP.FromFloat(offsetY)); } }
public void RotateAt(float angle, PointF point, MatrixOrderX order) { if (order == MatrixOrderX.Prepend) { MatrixFP m = MatrixFP.Identity(); m.Translate(SingleFP.FromFloat(-point.X), SingleFP.FromFloat(-point.Y)); m.Rotate(MathFP.ToRadians(SingleFP.FromFloat(angle))); m.Multiply(matrix); m.Translate(SingleFP.FromFloat(point.X), SingleFP.FromFloat(point.Y)); matrix = m; } else { matrix.Translate(SingleFP.FromFloat(-point.X), SingleFP.FromFloat(-point.Y)); matrix.Rotate(MathFP.ToRadians(SingleFP.FromFloat(angle))); matrix.Translate(SingleFP.FromFloat(point.X), SingleFP.FromFloat(point.Y)); } }
internal static AffineTransform ToMatrix(MatrixFP matrixFP) { if (matrixFP == null) { return(null); } if (matrixFP.IsIdentity()) { return(new AffineTransform()); } AffineTransform matrix = new AffineTransform(SingleFP.ToDouble(matrixFP.ScaleX), SingleFP.ToDouble(matrixFP.RotateX), SingleFP.ToDouble(matrixFP.RotateY), SingleFP.ToDouble(matrixFP.ScaleY), SingleFP.ToDouble(matrixFP.TranslateX), SingleFP.ToDouble(matrixFP.TranslateY)); return(matrix); }
public GradientBrushFP(int ff_xmin, int ff_ymin, int ff_xmax, int ff_ymax, int ff_angle, int type) { bounds.Reset(ff_xmin, ff_ymin, ff_xmax == ff_xmin ? ff_xmin + 1 : ff_xmax, ff_ymax == ff_ymin ? ff_ymin + 1 : ff_ymax); matrix = new MatrixFP(); matrix.Translate(-(ff_xmin + ff_xmax) / 2, -(ff_ymin + ff_ymax) / 2); matrix.Rotate(-ff_angle); this.type = type; if (type == RADIAL_GRADIENT) { matrix.Scale(MathFP.Div(SingleFP.One, bounds.Width), MathFP.Div(SingleFP.One, bounds.Height)); } int ff_ang = MathFP.Atan(MathFP.Div(bounds.Height, bounds.Width == 0 ? 1 : bounds.Width)); int ff_len = PointFP.Distance(bounds.Height, bounds.Width); ff_length = MathFP.Mul(ff_len, MathFP.Max( MathFP.Abs(MathFP.Cos(ff_angle - ff_ang)), MathFP.Abs(MathFP.Cos(ff_angle + ff_ang)))); }
internal static MatrixFP ToMatrixFP(AffineTransform matrix) { if (matrix == null) { return(null); } if (matrix.IsIdentity()) { return(MatrixFP.Identity); } MatrixFP matrixFP = new MatrixFP(SingleFP.FromDouble(matrix.GetScaleX()), SingleFP.FromDouble(matrix.GetScaleY()), SingleFP.FromDouble(matrix.GetShearX()), SingleFP.FromDouble(matrix.GetShearY()), SingleFP.FromDouble(matrix.GetTranslateX()), SingleFP.FromDouble(matrix.GetTranslateY())); return(matrixFP); }
public MatrixX() { matrix = MatrixFP.Identity(); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Set the graphics matrix. * @param Value the new matrix. */ public void SetMatrix(MatrixFP value) { _matrix = value == null ? null : new MatrixFP(value); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Set the matrix for this brush. * @param Value a new matrix. */ public void SetMatrix(MatrixFP value) { _matrix = new MatrixFP(value); _matrix.Invert(); }
public void DrawPath(GraphicsPathFP path, MatrixFP matrix, BrushFP fillStyle, int mode) { transformMatrix = matrix; DrawPath(path, fillStyle, mode); transformMatrix = null; }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Transform with a new matrix. * @param m1 a new matrix. */ public void Transform(MatrixFP m1) { var m = new MatrixFP(m1); m.Invert(); if (_matrix == null) { _matrix = m; } else { _matrix.Multiply(m); } }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Set the graphics matrix. * @param Value the graphics matrix. */ internal void SetGraphicsMatrix(MatrixFP value) { _graphicsMatrix = new MatrixFP(value); _graphicsMatrix.Invert(); _finalMatrix = new MatrixFP(_graphicsMatrix); if (_matrix != null) { _finalMatrix.Multiply(_matrix); } }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * transform the point with give matrix. * @param m * @return */ public PointFP Transform(MatrixFP m) { Reset(MathFP.Mul(X, m.ScaleX) + MathFP.Mul(Y, m.RotateY) + m.TranslateX, MathFP.Mul(Y, m.ScaleY) + MathFP.Mul(X, m.RotateX) + m.TranslateY); return this; }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Set the matrix for this brush. * @param Value a new matrix. */ public void SetMatrix(MatrixFP value) { _matrix = new MatrixFP(value); _matrix.Invert(); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Set the graphics matrix. * @param Value the new matrix. */ public void SetMatrix(MatrixFP value) { _matrix = value == null ? null : new MatrixFP(value); }
public virtual PointFP Transform(MatrixFP m) { Reset(MathFP.Mul(X, m.Sx) + MathFP.Mul(Y, m.Ry) + m.Tx, MathFP.Mul(Y, m.Sy) + MathFP.Mul(X, m.Rx) + m.Ty); return(this); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Copy constructor. * @param m */ public MatrixFP(MatrixFP m) { Reset(m.ScaleX, m.ScaleY, m.RotateX, m.RotateY, m.TranslateX, m.TranslateY); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Copy constructor. * @param m */ public MatrixFP(MatrixFP m) { Reset(m.ScaleX, m.ScaleY, m.RotateX, m.RotateY, m.TranslateX, m.TranslateY); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * multipy with another matrix. * @param m * @return */ public MatrixFP Multiply(MatrixFP m) { Reset(MathFP.Mul(m.ScaleX, ScaleX) + MathFP.Mul(m.RotateY, RotateX), MathFP.Mul(m.RotateX, RotateY) + MathFP.Mul(m.ScaleY, ScaleY), MathFP.Mul(m.RotateX, ScaleX) + MathFP.Mul(m.ScaleY, RotateX), MathFP.Mul(m.ScaleX, RotateY) + MathFP.Mul(m.RotateY, ScaleY), MathFP.Mul(m.ScaleX, TranslateX) + MathFP.Mul(m.RotateY, TranslateY) + m.TranslateX, MathFP.Mul(m.RotateX, TranslateX) + MathFP.Mul(m.ScaleY, TranslateY) + m.TranslateY); return this; }
public void Reset() { matrix = MatrixFP.Identity(); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * transform the point with give matrix. * @param m * @return */ public PointFP Transform(MatrixFP m) { Reset(MathFP.Mul(X, m.ScaleX) + MathFP.Mul(Y, m.RotateY) + m.TranslateX, MathFP.Mul(Y, m.ScaleY) + MathFP.Mul(X, m.RotateX) + m.TranslateY); return(this); }
private void AddLineCap(PointFP p1, PointFP p2, int lineCap) { if (lineCap == PenFP.LINECAP_BUTT || p1.Equals(p2)) { return; } var dx = p2.X - p1.X; var dy = p2.Y - p1.Y; var len = PointFP.Distance(dx, dy); var cap = lineCap == PenFP.LINECAP_ROUND ? GraphicsPathFP.ROUNDCAP : GraphicsPathFP.SQUARECAP; dx = MathFP.Mul(_ffRad, MathFP.Div(dx, len)); dy = MathFP.Mul(_ffRad, MathFP.Div(dy, len)); var m = new MatrixFP(dx, dx, dy, -dy, p2.X, p2.Y); _outline.AddMoveTo(new PointFP(0, GraphicsPathFP.ONE).Transform(m)); for (var i = 0; i < cap.Length; i++) { _outline.AddLineTo(new PointFP(cap[i]).Transform(m)); } _outline.AddLineTo(new PointFP(0, -GraphicsPathFP.ONE).Transform(m)); _outline.AddClose(); }
internal MatrixX(MatrixFP m) { matrix = m == null?MatrixFP.Identity() : new MatrixFP(m); }