public static ShxArc FromArcCommand(ShxGlyphCommandArc a, ref ShxPoint lastPoint) { var offset = new ShxPoint(a.XDisplacement, a.YDisplacement); var chordLength = offset.Length; var perpendicularHeight = Math.Abs(a.Bulge) * chordLength / 254.0; var isCounterClockwise = a.Bulge >= 0.0; var perpendicularVector = offset.Perpendicular.Normalized * perpendicularHeight; var startPoint = lastPoint; var midPoint = startPoint + offset.MidPoint + perpendicularVector; var endPoint = startPoint + offset; lastPoint = endPoint; var radius = (perpendicularHeight / 2.0) + (chordLength * chordLength / (8.0 * perpendicularHeight)); var center = midPoint - (perpendicularVector.Normalized * radius); var arcAngle = 2.0 * Math.Asin(chordLength / (2.0 * radius)); if (!isCounterClockwise) { var temp = startPoint; startPoint = endPoint; endPoint = temp; } var startPointVector = startPoint - center; var startAngle = Math.Atan2(startPointVector.Y, startPointVector.X); var endPointVector = endPoint - center; var endAngle = Math.Atan2(endPointVector.Y, endPointVector.X); var arc = new ShxArc(center, radius, startAngle, endAngle); return(arc); }
public void PopPoint() { if (_pointStack.Count > 0) { // TODO: some fonts contain a single pop instruction for the character '\r' _lastPoint = _pointStack.Pop(); } }
public void ProcessNewPosition(ShxPoint delta) { var nextPoint = _lastPoint + (delta * _vectorScale); if (_isDrawing) { Paths.Add(new ShxLine(_lastPoint, nextPoint)); } _lastPoint = nextPoint; }
public static ShxArc FromArcCommand(ShxGlyphCommandOctantArc a, ref ShxPoint lastPoint) { var octantCount = a.OctantCount; if (octantCount == 0) { // 0 means full circle octantCount = 8; } var endingOctant = a.IsCounterClockwise ? a.StartingOctant + octantCount : a.StartingOctant - octantCount; while (endingOctant < 0) { endingOctant += 8; } var startVector = OctantArcVectors[a.StartingOctant % 8] * a.Radius; var endVector = OctantArcVectors[endingOctant % 8] * a.Radius; if (a.OctantCount < 0) { var temp = startVector; startVector = endVector; endVector = temp; } var center = lastPoint - startVector; lastPoint = center + endVector; var startAngle = Math.Atan2(startVector.Y, startVector.X); var endAngle = Math.Atan2(endVector.Y, endVector.X); if (!a.IsCounterClockwise) { var temp = startAngle; startAngle = endAngle; endAngle = temp; } while (endAngle <= startAngle) { endAngle += Math.PI * 2.0; } return(new ShxArc(center, a.Radius, startAngle, endAngle)); }
public static ShxArc FromArcCommand(ShxGlyphCommandFractionalArc a, ref ShxPoint lastPoint) { var radius = a.HighRadius * 256.0 + a.Radius; var startOctantAngle = a.StartingOctant * 45.0; var endOctantAngle = (a.StartingOctant + a.OctantCount - 1) * 45.0; var startAngleDegrees = (45.0 * a.StartOffset / 256.0) + startOctantAngle; var startAngleRadians = startAngleDegrees * Math.PI / 180.0; var endAngleDegrees = (45.0 * a.EndOffset / 256.0) + endOctantAngle; var endAngleRadians = endAngleDegrees * Math.PI / 180.0; var startVector = ShxPoint.FromAngleRadians(startAngleRadians) * radius; var endVector = ShxPoint.FromAngleRadians(endAngleRadians) * radius; var center = lastPoint - startVector; lastPoint = center + endVector; var arc = new ShxArc(center, radius, startAngleRadians, endAngleRadians); return(arc); }