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 DrawPie(PenX pen, float x, float y, float width, float height, float startAngle, float sweepAngle) { lock (this) { double a1 = startAngle * Math.PI / 180; double a2 = (startAngle + sweepAngle) * Math.PI / 180; graphics.Pen = PenX.ToPenFP(pen); bool positive = sweepAngle >= 0; float endAngle = startAngle + sweepAngle; startAngle = (float)TransformAngle(startAngle, width, height); sweepAngle = (float)TransformAngle(endAngle, width, height) - startAngle; if (positive && sweepAngle < 0) { sweepAngle += 360; } else if (!positive && sweepAngle >= 0) { sweepAngle -= 360; } graphics.Matrix = matrix == null ? null : matrix.matrix; graphics.DrawPie( SingleFP.FromFloat(x), SingleFP.FromFloat(y), SingleFP.FromFloat(x + width), SingleFP.FromFloat(y + height), MathFP.ToRadians(SingleFP.FromFloat(startAngle)), MathFP.ToRadians(SingleFP.FromFloat(sweepAngle))); } }
public void FillPie(BrushX brush, float x, float y, float width, float height, float startAngle, float sweepAngle) { lock (this) { graphics.Brush = brush.WrappedBrush; bool positive = sweepAngle >= 0; float endAngle = startAngle + sweepAngle; startAngle = (float)TransformAngle(startAngle, width, height); sweepAngle = (float)TransformAngle(endAngle, width, height) - startAngle; if (positive && sweepAngle < 0) { sweepAngle += 360; } else if (!positive && sweepAngle >= 0) { sweepAngle -= 360; } graphics.Matrix = matrix == null ? null : matrix.matrix; graphics.FillPie( SingleFP.FromFloat(x), SingleFP.FromFloat(y), SingleFP.FromFloat(x + width), SingleFP.FromFloat(y + height), MathFP.ToRadians(SingleFP.FromFloat(startAngle)), MathFP.ToRadians(SingleFP.FromFloat(sweepAngle))); } }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Scale operation. * @param ff_sx * @param ff_sy * @return */ public MatrixFP Scale(int ffSx, int ffSy) { Reset(MathFP.Mul(ffSx, ScaleX), MathFP.Mul(ffSy, ScaleY), MathFP.Mul(ffSy, RotateX), MathFP.Mul(ffSx, RotateY), MathFP.Mul(ffSx, TranslateX), MathFP.Mul(ffSy, TranslateY)); return(this); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * rotate operation. * @param ff_ang * @return */ public MatrixFP Rotate(int ffAng) { var ffSin = MathFP.Sin(ffAng); var ffCos = MathFP.Cos(ffAng); return(Multiply(new MatrixFP(ffCos, ffCos, ffSin, -ffSin, 0, 0))); }
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(); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Reset the rectangle. * @param ff_xmin * @param ff_ymin * @param ff_xmax * @param ff_ymax * @return */ public RectangleFP Reset(int ffXmin, int ffYmin, int ffXmax, int ffYmax) { _ffXmin = MathFP.Min(ffXmin, ffXmax); _ffXmax = MathFP.Max(ffXmin, ffXmax); _ffYmin = MathFP.Min(ffYmin, ffYmax); _ffYmax = MathFP.Max(ffYmin, ffYmax); return(this); }
public virtual RectangleFP Union(PointFP p) { if (!IsEmpty()) { Reset(MathFP.Min(ff_xmin, p.X), MathFP.Max(ff_xmax, p.X), MathFP.Min(ff_ymin, p.Y), MathFP.Max(ff_ymax, p.Y)); } return(this); }
public virtual RectangleFP Reset(int ff_xmin, int ff_ymin, int ff_xmax, int ff_ymax) { this.ff_xmin = MathFP.Min(ff_xmin, ff_xmax); this.ff_xmax = MathFP.Max(ff_xmin, ff_xmax); this.ff_ymin = MathFP.Min(ff_ymin, ff_ymax); this.ff_ymax = MathFP.Max(ff_ymin, ff_ymax); return(this); }
public LineFP GetHeadOutline(int ff_rad) { PointFP p = new PointFP(P1.X - P2.X, P1.Y - P2.Y); int len = Length; p.Reset(MathFP.Div(-p.Y, len), MathFP.Div(p.X, len)); p.Reset(MathFP.Mul(p.X, ff_rad), MathFP.Mul(p.Y, ff_rad)); return(new LineFP(P1.X - p.X, P1.Y - p.Y, P1.X + p.X, P1.Y + p.Y)); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Get the head outline. * @param ff_rad * @return */ public LineFP GetHeadOutline(int ffRad) { var p = new PointFP(Pt1.X - Pt2.X, Pt1.Y - Pt2.Y); var len = GetLength(); p.Reset(MathFP.Div(-p.Y, len), MathFP.Div(p.X, len)); p.Reset(MathFP.Mul(p.X, ffRad), MathFP.Mul(p.Y, ffRad)); return(new LineFP(Pt1.X - p.X, Pt1.Y - p.Y, Pt1.X + p.X, Pt1.Y + p.Y)); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * return the union of the rectangle and the given point. * @param p * @return */ public RectangleFP Union(PointFP p) { if (!IsEmpty()) { Reset(MathFP.Min(_ffXmin, p.X), MathFP.Max(_ffXmax, p.X), MathFP.Min(_ffYmin, p.Y), MathFP.Max(_ffYmax, p.Y)); } return(this); }
private void OnDrawGizmosSelected() { Gizmos.color = Color.blue; Gizmos.DrawWireSphere(transform.position, m_Threshold.AsFloat()); if (m_RespawnPoints != null) { for (int respawnPointIndex = 0; respawnPointIndex < m_RespawnPoints.Length; ++respawnPointIndex) { RespawnPoint respawnPoint = m_RespawnPoints[respawnPointIndex]; if (respawnPoint == null) { continue; } TSVector2 normalizedDir = respawnPoint.forceDirection.normalized; // Draw main direction. if (respawnPoint.transform != null) { Gizmos.color = Color.yellow; Vector3 from = respawnPoint.transform.position.ToVector(); Vector3 to = from + new Vector3(normalizedDir.x.AsFloat(), normalizedDir.y.AsFloat(), 0f); Gizmos.DrawLine(from, to); } if (MathFP.Abs(respawnPoint.errorAngle) > FP.Zero) { // Draw error range. { Gizmos.color = Color.red; TSVector2 normalizedDirLeft = normalizedDir.Rotate(-respawnPoint.errorAngle); Vector3 from = respawnPoint.transform.position.ToVector(); Vector3 to = from + new Vector3(normalizedDirLeft.x.AsFloat(), normalizedDirLeft.y.AsFloat(), 0f); Gizmos.DrawLine(from, to); } { Gizmos.color = Color.red; TSVector2 normalizedDirRight = normalizedDir.Rotate(respawnPoint.errorAngle); Vector3 from = respawnPoint.transform.position.ToVector(); Vector3 to = from + new Vector3(normalizedDirRight.x.AsFloat(), normalizedDirRight.y.AsFloat(), 0f); Gizmos.DrawLine(from, to); } } } } }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- 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); }
// TrueSyncBehaviour's INTERFACE public override void OnPreSyncedUpdate() { base.OnPreSyncedUpdate(); if (m_AutoRecovery) { FP deltaTime = TrueSyncManager.deltaTimeMain; m_Energy = MathFP.Clamp01(m_Energy + m_RecoveryRate * deltaTime); } m_ConsumedThisFrame = FP.Zero; }
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))); } }
public virtual RectangleFP Union(RectangleFP r) { if (!r.IsEmpty()) { if (IsEmpty()) { Reset(r); } else { Reset(MathFP.Min(ff_xmin, r.ff_xmin), MathFP.Max(ff_xmax, r.ff_xmax), MathFP.Min(ff_ymin, r.ff_ymin), MathFP.Max(ff_ymax, r.ff_ymax)); } } return(this); }
public LineFP GetTailOutline(int ff_rad) { PointFP c = Center; PointFP p = new PointFP(P2.X - c.X, P2.Y - c.Y); p.Reset(p.Y, -p.X); int dis = PointFP.Distance(PointFP.Origin, p); if (dis == 0) { dis = 1; } p.Reset(MathFP.Div(MathFP.Mul(p.X, ff_rad), dis), MathFP.Div(MathFP.Mul(p.Y, ff_rad), dis)); return(new LineFP(P2.X - p.X, P2.Y - p.Y, P2.X + p.X, P2.Y + p.Y)); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * get the tail outline. * @param ff_rad * @return */ public LineFP GetTailOutline(int ffRad) { var c = GetCenter(); var p = new PointFP(Pt2.X - c.X, Pt2.Y - c.Y); p.Reset(p.Y, -p.X); var dis = PointFP.Distance(PointFP.Origin, p); if (dis == 0) { dis = 1; } p.Reset(MathFP.Div(MathFP.Mul(p.X, ffRad), dis), MathFP.Div(MathFP.Mul(p.Y, ffRad), dis)); return(new LineFP(Pt2.X - p.X, Pt2.Y - p.Y, Pt2.X + p.X, Pt2.Y + p.Y)); }
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)); } }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Calculate the union of the two rectangle. * @param r * @return */ public RectangleFP Union(RectangleFP r) { if (!r.IsEmpty()) { if (IsEmpty()) { Reset(r); } else { Reset(MathFP.Min(_ffXmin, r._ffXmin), MathFP.Max(_ffXmax, r._ffXmax), MathFP.Min(_ffYmin, r._ffYmin), MathFP.Max(_ffYmax, r._ffYmax)); } } return(this); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * * @param distance * @return */ internal PointFP GetPointAtDistance(int distance) { var lineLength = GetLength(); if (distance > lineLength) { return(null); } if (distance == lineLength) { return(new PointFP(Pt2)); } var scale = MathFP.Div(distance, lineLength); var pointFP = new PointFP(); pointFP.Reset(Pt1.X + MathFP.Mul(Pt2.X - Pt1.X, scale), Pt1.Y + MathFP.Mul(Pt2.Y - Pt1.Y, scale)); return(pointFP); }
public static GraphicsPathFP CreateRoundRect(int ff_xmin, int ff_ymin, int ff_xmax, int ff_ymax, int ff_rx, int ff_ry) { int ff_rmax; int FF_PI = MathFP.PI; GraphicsPathFP path = new GraphicsPathFP(); path.AddMoveTo(new PointFP(ff_xmin + ff_rx, ff_ymin)); path.AddLineTo(new PointFP(ff_xmax - ff_rx, ff_ymin)); ff_rmax = MathFP.Min(ff_xmax - ff_xmin, ff_ymax - ff_ymin) / 2; if (ff_rx > ff_rmax) { ff_rx = ff_rmax; } if (ff_ry > ff_rmax) { ff_ry = ff_rmax; } if (ff_rx != 0 && ff_ry != 0) { path.AddPath(GraphicsPathFP.CreateArc(ff_xmax - ff_rx * 2, ff_ymin, ff_xmax, ff_ymin + ff_ry * 2, (-FF_PI) / 2, 0, false, false)); } path.AddLineTo(new PointFP(ff_xmax, ff_ymin + ff_ry)); path.AddLineTo(new PointFP(ff_xmax, ff_ymax - ff_ry)); if (ff_rx != 0 && ff_ry != 0) { path.AddPath(GraphicsPathFP.CreateArc(ff_xmax - ff_rx * 2, ff_ymax - ff_ry * 2, ff_xmax, ff_ymax, 0, FF_PI / 2, false, false)); } path.AddLineTo(new PointFP(ff_xmax - ff_rx, ff_ymax)); path.AddLineTo(new PointFP(ff_xmin + ff_rx, ff_ymax)); if (ff_rx != 0 && ff_ry != 0) { path.AddPath(GraphicsPathFP.CreateArc(ff_xmin, ff_ymax - ff_ry * 2, ff_xmin + ff_rx * 2, ff_ymax, FF_PI / 2, FF_PI, false, false)); } path.AddLineTo(new PointFP(ff_xmin, ff_ymax - ff_ry)); path.AddLineTo(new PointFP(ff_xmin, ff_ymin + ff_ry)); if (ff_rx != 0 && ff_ry != 0) { path.AddPath(GraphicsPathFP.CreateArc(ff_xmin, ff_ymin, ff_xmin + ff_rx * 2, ff_ymin + ff_ry * 2, -FF_PI, (-FF_PI) / 2, false, false)); } path.AddClose(); return(path); }
static public int Distance(int dx, int dy) { dx = MathFP.Abs(dx); dy = MathFP.Abs(dy); if (dx == 0) { return(dy); } else if (dy == 0) { return(dx); } long len = (((long)dx * dx) >> SingleFP.DecimalBits) + (((long)dy * dy) >> SingleFP.DecimalBits); long s = (dx + dy) - (MathFP.Min(dx, dy) >> 1); s = (s + ((len << SingleFP.DecimalBits) / s)) >> 1; s = (s + ((len << SingleFP.DecimalBits) / s)) >> 1; return((int)s); }
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)))); }
public override void LineTo(PointFP point) { //PointFP a = new PointFP(CurrentPoint); PointFP pntTemp = new PointFP(point); ff_xmin = MathFP.Min(ff_xmin, CurrentPoint.X); ff_xmax = MathFP.Max(ff_xmax, point.X); ff_ymin = MathFP.Min(ff_ymin, CurrentPoint.Y); ff_ymax = MathFP.Max(ff_ymax, point.Y); if (transformMatrix != null) { pntTemp.Transform(transformMatrix); //b.Transform(transformMatrix); } Scanline(transformedPoint.X, transformedPoint.Y, pntTemp.X, pntTemp.Y); transformedPoint = pntTemp; base.LineTo(point); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * calculate the distance. * @param dx * @param dy * @return */ static public int Distance(int dx, int dy) { dx = MathFP.Abs(dx); dy = MathFP.Abs(dy); if (dx == 0) { return(dy); } if (dy == 0) { return(dx); } var len = (((long)dx * dx) >> SingleFP.DECIMAL_BITS) + (((long)dy * dy) >> SingleFP.DECIMAL_BITS); long s = (dx + dy) - (MathFP.Min(dx, dy) >> 1); s = (s + ((len << SingleFP.DECIMAL_BITS) / s)) >> 1; s = (s + ((len << SingleFP.DECIMAL_BITS) / s)) >> 1; return((int)s); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * invert the matrix. * @return */ public MatrixFP Invert() { int ffDet = Determinant(); if (ffDet == 0) { Reset(); } else { var ffSxNew = MathFP.Div(ScaleY, ffDet); var ffSyNew = MathFP.Div(ScaleX, ffDet); var ffRxNew = -MathFP.Div(RotateX, ffDet); var ffRyNew = -MathFP.Div(RotateY, ffDet); var ffTxNew = MathFP.Div(MathFP.Mul(TranslateY, RotateY) - MathFP.Mul(TranslateX, ScaleY), ffDet); var ffTyNew = -MathFP.Div(MathFP.Mul(TranslateY, ScaleX) - MathFP.Mul(TranslateX, RotateX), ffDet); Reset(ffSxNew, ffSyNew, ffRxNew, ffRyNew, ffTxNew, ffTyNew); } return(this); }
public static GraphicsPathFP CreateArc(int ff_xmin, int ff_ymin, int ff_xmax, int ff_ymax, int ff_startangle, int ff_sweepangle, bool closed, bool standalone) { if (ff_sweepangle < 0) { ff_startangle += ff_sweepangle; ff_sweepangle = -ff_sweepangle; } int segments = MathFP.Round(MathFP.Div(4 * MathFP.Abs(ff_sweepangle), MathFP.PI)) >> SingleFP.DecimalBits; if (segments == 0) { segments = 1; } GraphicsPathFP path = new GraphicsPathFP(); int ff_darg = ff_sweepangle / segments; int ff_arg = ff_startangle; int ff_lastcos = MathFP.Cos(ff_startangle); int ff_lastsin = MathFP.Sin(ff_startangle); int ff_xc = (ff_xmin + ff_xmax) / 2; int ff_yc = (ff_ymin + ff_ymax) / 2; int ff_rx = (ff_xmax - ff_xmin) / 2; int ff_ry = (ff_ymax - ff_ymin) / 2; int ff_RXBETA = MathFP.Mul(17381, ff_rx); int ff_RYBETA = MathFP.Mul(17381, ff_ry); int ff_currcos, ff_currsin, ff_x1, ff_y1, ff_x2, ff_y2; if (closed) { path.AddMoveTo(new PointFP(ff_xc, ff_yc)); } for (int i = 1; i <= segments; i++) { ff_arg = i == segments?ff_startangle + ff_sweepangle:ff_arg + ff_darg; ff_currcos = MathFP.Cos(ff_arg); ff_currsin = MathFP.Sin(ff_arg); ff_x1 = ff_xc + MathFP.Mul(ff_rx, ff_lastcos); ff_y1 = ff_yc + MathFP.Mul(ff_ry, ff_lastsin); ff_x2 = ff_xc + MathFP.Mul(ff_rx, ff_currcos); ff_y2 = ff_yc + MathFP.Mul(ff_ry, ff_currsin); if (i == 1) { if (closed) { path.AddLineTo(new PointFP(ff_x1, ff_y1)); } else if (standalone) { path.AddMoveTo(new PointFP(ff_x1, ff_y1)); } } path.AddCurveTo( new PointFP(ff_x1 - MathFP.Mul(ff_RXBETA, ff_lastsin), ff_y1 + MathFP.Mul(ff_RYBETA, ff_lastcos)), new PointFP(ff_x2 + MathFP.Mul(ff_RXBETA, ff_currsin), ff_y2 - MathFP.Mul(ff_RYBETA, ff_currcos)), new PointFP(ff_x2, ff_y2)); ff_lastcos = ff_currcos; ff_lastsin = ff_currsin; } if (closed) { path.AddClose(); } return(path); }
public static PointFP CalcControlPoint(PointFP p1, PointFP p2, PointFP p3, int ff_factor) { PointFP ps = new PointFP(p2.X + MathFP.Mul(p2.X - p1.X, ff_factor), p2.Y + MathFP.Mul(p2.Y - p1.Y, ff_factor)); return(new LineFP(new LineFP(p2, ps).Center, new LineFP(p2, p3).Center).Center); }