public override VectorPoint Copy() { ArcLinePoint point = new ArcLinePoint(X, Y); point.Length = Length; point.Length = Length; point.Radius = Radius; point.EndAngle = EndAngle; point.StartAngle = StartAngle; point.CircleCenterX = CircleCenterX; point.CircleCenterY = CircleCenterY; return(point); }
/// <summary>Creates an arc around the given circle center. Note that nothing will /// be seen until you call a fill or stroke method.</summary> public void Arc(float centerX, float centerY, float radius, float sAngle, float eAngle, bool counterClockwise) { VectorPoint previous = LatestPathNode; float x0; float y0; if (previous == null) { x0 = 0f; y0 = 0f; } else { x0 = previous.X; y0 = previous.Y; } // Clockwise eAngle > sAngle; counter clockwise otherwise. if (eAngle > sAngle) { if (counterClockwise) { // Get them both in range: eAngle = eAngle % TwoPI; sAngle = sAngle % TwoPI; // Reduce eAngle by a full rotation so it's smaller: eAngle -= TwoPI; } } else if (!counterClockwise) { // Get them both in range: eAngle = eAngle % TwoPI; sAngle = sAngle % TwoPI; // Reduce sAngle by a full rotation so it's smaller: sAngle -= TwoPI; } // First, figure out where the actual start is. // It's radius units to the right of center, then rotated through radius around center. // Thus we have a triangle with hyp length of 'radius' and an angle of sAngle: float startX = radius * (float)Math.Cos(sAngle); float startY = radius * (float)Math.Sin(sAngle); // Now find the end point, using exactly the same method: float endX = radius * (float)Math.Cos(eAngle); float endY = radius * (float)Math.Sin(eAngle); // We now have an arc from the current position to endX/endY. // The start and exit node angles are usefully just offset from the given ones. // This is because an sAngle of zero should create an arc which starts travelling downwards. // (Or upwards if it's counter clockwise): // Where does the arc start from? float arcStartX = centerX + startX; float arcStartY = centerY + startY; if (FirstPathNode == null) { // This occurs if the arc is the first thing we draw. No line is drawn to it. MoveTo(arcStartX, arcStartY); } else if (arcStartX != x0 || arcStartY != y0) { // Draw a line to this point: LineTo(arcStartX, arcStartY); } // Create the new arc node: ArcLinePoint arcNode = new ArcLinePoint(centerX + endX, centerY + endY); // Apply the radius: arcNode.Radius = radius; // Apply the angles: arcNode.StartAngle = sAngle; arcNode.EndAngle = eAngle; // Apply the center: arcNode.CircleCenterX = centerX; arcNode.CircleCenterY = centerY; // Add the other end: AddPathNode(arcNode); }
public override VectorPoint Copy(){ ArcLinePoint point=new ArcLinePoint(X,Y); point.Length=Length; point.NormalX=NormalX; point.NormalY=NormalY; point.Length=Length; point.Radius=Radius; point.EndAngle=EndAngle; point.StartAngle=StartAngle; point.CircleCenterX=CircleCenterX; point.CircleCenterY=CircleCenterY; return point; }
//--------------------------------------