private void CreateArrows(Path path, StreamGeometryContext gc) { double start; if (path.PathType == PathType.Convex) { start = GeometryHelper.GetAngleFromPoint(path.StartPoint, path.Origin); } else { start = GeometryHelper.GetAngleFromPoint(path.EndPoint, path.Origin); } for(int i= 0; i < 10; i++) { start += 8; var org = GeometryHelper.GetPointAtAngle(path.Origin, path.Radius, start); var pt1 = GeometryHelper.GetPointAtAngle(path.Origin, path.Radius + 10, start); var pt2 = GeometryHelper.GetPointAtAngle(path.Origin, path.Radius - 10, start); var pt3 = GeometryHelper.GetPointAtAngle(org, 20, start + 90); gc.BeginFigure(pt1, true, true); gc.LineTo(pt2, true, true); gc.LineTo(pt3, true, true); gc.LineTo(pt1, true, true); gc.BeginFigure(path.Origin, false, false); gc.LineTo(pt1, true, true); } }
public override void Draw(StreamGeometryContext context, Connection connection) { if (connection.SourceConnectionPoint == null || connection.TargetConnectionPoint == null) { context.BeginFigure(connection.StartPoint, true, false); context.LineTo(connection.EndPoint, true, true); } else if(connection.Source == connection.Target) { Point startPoint = connection.SourceEndPoint.EndPoint; Point midPoint = connection.SourceConnectionPoint.LineAwayFromThisTo(startPoint, 50); context.BeginFigure(startPoint, true, true); context.ArcTo(midPoint, new Size(50, 50), 180, false, SweepDirection.Clockwise, true, true); context.ArcTo(startPoint, new Size(50, 50), 180, false, SweepDirection.Clockwise, true, true); } else { Point startPoint = connection.SourceEndPoint.EndPoint; Point endPoint = connection.TargetEndPoint.EndPoint; context.BeginFigure(startPoint, true, false); context.LineTo(endPoint, true, true); } }
public static void DrawParallelLines(StreamGeometryContext context, Point startPoint, Point endPoint, int spacing) { Vector perpendicularLine = GetPerpendicularLine(startPoint, endPoint); // Draw 1->2 line context.BeginFigure(startPoint + (perpendicularLine * spacing), true, false); context.LineTo(endPoint + (perpendicularLine * spacing), true, true); // Draw 2->1 line context.BeginFigure(startPoint - (perpendicularLine * spacing), true, false); context.LineTo(endPoint - (perpendicularLine * spacing), true, true); }
public override void Draw(StreamGeometryContext context, Point startPoint, Point endPoint) { Vector line = endPoint - startPoint; Vector perpendicularLine = new Vector(line.Y, -line.X); perpendicularLine.Normalize(); double halfLength = line.Length/2; Point leftPoint = startPoint - (perpendicularLine*halfLength); Point rightPoint = startPoint + (perpendicularLine * halfLength); var norLine = new Vector(line.X, line.Y); norLine.Normalize(); Point shortEndPoint = endPoint - (norLine * 4); context.BeginFigure(startPoint, true, false); context.LineTo(shortEndPoint, true, false); context.LineTo(leftPoint, false, false); context.LineTo(shortEndPoint, true, false); context.LineTo(rightPoint, false, false); context.LineTo(shortEndPoint, true, false); context.LineTo(endPoint, true, false); }
static void Polygon(StreamGeometryContext ctx, Point point, double size, double startAngle, int steps) { var halfSize = size / 2; var xOffset = halfSize * Math.Sin(startAngle); var yOffset = halfSize * Math.Cos(startAngle); ctx.BeginFigure(new Point(point.X + xOffset, point.Y - yOffset), true, true); for (var angle = startAngle + (MoreMath.TwoPi / steps); angle < MoreMath.TwoPi; angle += MoreMath.TwoPi / steps) ctx.LineTo(new Point(point.X + (halfSize * Math.Sin(angle)), point.Y - (halfSize * Math.Cos(angle))), true, true); }
public void Draw(StreamGeometryContext context, Connection connection) { Point startPoint = connection.SourceEndPoint.EndPoint; Point endPoint = connection.TargetEndPoint.EndPoint; context.BeginFigure(startPoint, true, false); context.LineTo(endPoint, true, true); }
private static void AddCircleToGeometry(StreamGeometryContext streamGeometryContext, Point[] points, double pointSize) { foreach (Point point in points) { streamGeometryContext.BeginFigure(new Point(point.X - (pointSize / 2), point.Y - (pointSize / 2)), true, true); streamGeometryContext.ArcTo(new Point(point.X - (pointSize / 2) - 0.0001, point.Y - (pointSize / 2)), new Size(pointSize, pointSize), 360, true, SweepDirection.Clockwise, true, false); } }
///<summary> /// Adds a <see cref="PathFigure"/> representing a polygon ring /// having the given coordinate sequence to the supplied <see cref="StreamGeometryContext"/> ///</summary> ///<param name="sgc">The stream geometry context.</param> ///<param name="coordinates">A coordinate sequence</param> ///<param name="filled">Starting paramter for </param> ///<returns>The path for the coordinate sequence</returns> private static void AddRing(StreamGeometryContext sgc, Coordinate[] coordinates, bool filled) { if (coordinates.Length <= 0) return; sgc.BeginFigure(ToPoint(coordinates[0]), filled, true); if (coordinates.Length > 0) sgc.PolyLineTo(ToPoint(coordinates, 1), true, true); }
public static void DrawTriangle(StreamGeometryContext context, Vector mainLine, Vector mainPerpendicularLine, Point point1, int size, bool isFilled) { int halfSize = size / 2; context.BeginFigure(point1, isFilled, true); var point2 = point1 + (mainPerpendicularLine * halfSize) + (mainLine * size); var point3 = point1 - (mainPerpendicularLine * halfSize) + (mainLine * size); context.LineTo(point2, true, true); context.LineTo(point3, true, true); }
private void InternalDrawGeometry(StreamGeometryContext context) { generateGeometry(); context.BeginFigure(tips[0], true, true); for (int x = 1; x < points.Count(); x++) { context.LineTo(points[x], true, true); } }
static void OpenFigure(StreamGeometryContext ctx, Point point, double size, double startAngle, int steps) { var halfSize = size / 2; for (var angle = startAngle; angle <= Math.PI; angle += Math.PI / steps) { var xOffset = halfSize * Math.Sin(angle); var yOffset = halfSize * Math.Cos(angle); ctx.BeginFigure(new Point(point.X + xOffset, point.Y - yOffset), false, false); ctx.LineTo(new Point(point.X - xOffset, point.Y + yOffset), true, false); } }
public override void Draw(StreamGeometryContext context, Point startPoint, Point endPoint) { base.Draw(context, startPoint, endPoint); Vector line = endPoint - startPoint; Vector perpendicularLine = new Vector(line.Y, -line.X); perpendicularLine.Normalize(); double halfLength = line.Length / 2; Point leftPoint = endPoint - (perpendicularLine * halfLength); Point rightPoint = endPoint + (perpendicularLine * halfLength); context.BeginFigure(leftPoint, true, false); context.LineTo(rightPoint, true, false); }
private static void AddSegmentToGeometry(StreamGeometryContext streamGeometryContext, Point[] points, bool close) { for (int i = 0; i < points.Length; i++) { if (i == 0) { streamGeometryContext.BeginFigure(points[i], true, false); } else { streamGeometryContext.LineTo(points[i], true, true); } } if (close) { streamGeometryContext.LineTo(points[0], true, true); } }
private void InternalDrawArrowGeometry(StreamGeometryContext context) { var theta = Math.Atan2(Y1 - Y2, X1 - X2); var sint = Math.Sin(theta); var cost = Math.Cos(theta); var pt1 = new Point(X1, Y1); var pt2 = new Point(X2, Y2); var pt3 = new Point(X2 + (HeadWidth * cost - HeadHeight * sint), Y2 + (HeadWidth * sint + HeadHeight * cost)); var pt4 = new Point(X2 + (HeadWidth * cost + HeadHeight * sint), Y2 - (HeadHeight * cost - HeadWidth * sint)); context.BeginFigure(pt1, true, false); context.LineTo(pt2, true, true); context.LineTo(pt3, true, true); context.LineTo(pt2, true, true); context.LineTo(pt4, true, true); }
/// <summary> /// The actual method for drawing the arrow. /// </summary> /// <param name="StreamGeometryContext">Describes a geometry using drawing commands.</param> protected override void DrawArrowGeometry(StreamGeometryContext StreamGeometryContext) { var theta = Math.Atan2(Y1 - Y2, X1 - X2); var sint = Math.Sin(theta); var cost = Math.Cos(theta); var ArrowOrigin = new Point(X1, Y1); var ArrowTarget = new Point(X2, Y2); var pt3 = new Point(X2 + (HeadWidth * cost - HeadHeight * sint), Y2 + (HeadWidth * sint + HeadHeight * cost)); var pt4 = new Point(X2 + (HeadWidth * cost + HeadHeight * sint), Y2 - (HeadHeight * cost - HeadWidth * sint)); StreamGeometryContext.BeginFigure(ArrowOrigin, isFilled: true, isClosed: false); StreamGeometryContext.LineTo (ArrowTarget, isStroked: true, isSmoothJoin: true); StreamGeometryContext.LineTo (pt3, isStroked: true, isSmoothJoin: true); StreamGeometryContext.LineTo (ArrowTarget, isStroked: true, isSmoothJoin: true); StreamGeometryContext.LineTo (pt4, isStroked: true, isSmoothJoin: true); }
public static void AddArrow(StreamGeometryContext context,Point start,Point end, double thickness) { if(thickness > 1) { Point dir = end - start; Point h = dir; double dl = dir.Length; if(dl < 0.001) return; dir /= dl; var s = new Point(-dir.Y,dir.X); double w = 0.5 * thickness; Point s0 = w * s; s *= h.Length * HalfArrowAngleTan; s += s0; double rad = w / HalfArrowAngleCos; context.BeginFigure(Common.WpfPoint(start + s),true,true); context.LineTo(Common.WpfPoint(start - s),true,false); context.LineTo(Common.WpfPoint(end - s0),true,false); context.ArcTo(Common.WpfPoint(end + s0),new Size(rad,rad), Math.PI - ArrowAngle,false,SweepDirection.Clockwise,true,false); } else { Point dir = end - start; double dl = dir.Length; //take into account the widths double delta = Math.Min(dl / 2, thickness + thickness / 2); dir *= (dl - delta) / dl; end = start + dir; dir = dir.Rotate(Math.PI / 2); Point s = dir * HalfArrowAngleTan; context.BeginFigure(Common.WpfPoint(start + s),true,true); context.LineTo(Common.WpfPoint(end),true,true); context.LineTo(Common.WpfPoint(start - s),true,true); } }
static internal void FillContextForICurve(StreamGeometryContext context,ICurve iCurve) { context.BeginFigure(Common.WpfPoint(iCurve.Start),false,false); var c = iCurve as Curve; if(c != null) FillContexForCurve(context,c); else { var cubicBezierSeg = iCurve as CubicBezierSegment; if(cubicBezierSeg != null) context.BezierTo(Common.WpfPoint(cubicBezierSeg.B(1)),Common.WpfPoint(cubicBezierSeg.B(2)), Common.WpfPoint(cubicBezierSeg.B(3)),true,false); else { var ls = iCurve as LineSegment; if(ls != null) context.LineTo(Common.WpfPoint(ls.End),true,false); else { var rr = iCurve as RoundedRect; if(rr != null) FillContexForCurve(context,rr.Curve); else { var poly = iCurve as Polyline; if (poly != null) FillContexForPolyline(context, poly); else { var ellipse = iCurve as Ellipse; if (ellipse != null) { // context.LineTo(Common.WpfPoint(ellipse.End),true,false); double sweepAngle = EllipseSweepAngle(ellipse); bool largeArc = Math.Abs(sweepAngle) >= Math.PI; Rectangle box = ellipse.FullBox(); context.ArcTo(Common.WpfPoint(ellipse.End), new Size(box.Width/2, box.Height/2), sweepAngle, largeArc, sweepAngle < 0 ? SweepDirection.Counterclockwise : SweepDirection.Clockwise, true, true); } else { throw new NotImplementedException(); } } } } } } }
/// <summary> /// /// </summary> /// <param name="context"></param> protected void DrawGeometry(StreamGeometryContext context) { Point offset = new Point( (double.IsNaN(CenterX)) ? Width / 2.0 : CenterX, (double.IsNaN(CenterY)) ? Height / 2.0 : CenterY); double angleSpan = Math.Abs(EndAngle - StartAngle); Point thrustPoint = PolarToCartesian(StartAngle + angleSpan/2.0, RadiusThrust, offset); Point outerArcStartPoint = PolarToCartesian(StartAngle, OuterRadius, offset); Point outerArcEndPoint = PolarToCartesian(EndAngle, OuterRadius, offset); //using LERP, calculate the innerArc points, sadly we shall be short changing Point innerArcStartPoint = PolarToCartesian(StartAngle, InnerRadius - RadiusThrust, thrustPoint); Point innerArcEndPoint = PolarToCartesian(EndAngle, InnerRadius - RadiusThrust, thrustPoint); bool largeArc = angleSpan > 180.0; double innerArcDim = Math.Max(0.0, InnerRadius - RadiusThrust); Size outerArcSize = new Size(OuterRadius, OuterRadius); Size innerArcSize = new Size(innerArcDim, innerArcDim); context.BeginFigure(outerArcStartPoint, true, true); //context.LineTo(outerArcStartPoint, true, true); context.ArcTo(outerArcEndPoint, outerArcSize, 0, largeArc, SweepDirection.Clockwise, true, true); context.LineTo(innerArcEndPoint, true, true); context.ArcTo(innerArcStartPoint, innerArcSize, 0, largeArc, SweepDirection.Counterclockwise, true, true); }
/// <summary> /// Draws the pie piece /// </summary> private void DrawGeometry(StreamGeometryContext context) { var innerArcStartPoint = Utils.ComputeCartesianCoordinate(RotationAngle, InnerRadius); innerArcStartPoint.Offset(CentreX, CentreY); var innerArcEndPoint = Utils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle, InnerRadius); innerArcEndPoint.Offset(CentreX, CentreY); var outerArcStartPoint = Utils.ComputeCartesianCoordinate(RotationAngle, Radius); outerArcStartPoint.Offset(CentreX, CentreY); var outerArcEndPoint = Utils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle, Radius); outerArcEndPoint.Offset(CentreX, CentreY); var innerArcMidPoint = Utils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle * .5, InnerRadius); innerArcMidPoint.Offset(CentreX, CentreY); var outerArcMidPoint = Utils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle * .5, Radius); outerArcMidPoint.Offset(CentreX, CentreY); var largeArc = WedgeAngle > 180.0d; var requiresMidPoint = Math.Abs(WedgeAngle - 360) < .01; if (PushOut > 0 && !requiresMidPoint) { var offset = Utils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle / 2, PushOut); innerArcStartPoint.Offset(offset.X, offset.Y); innerArcEndPoint.Offset(offset.X, offset.Y); outerArcStartPoint.Offset(offset.X, offset.Y); outerArcEndPoint.Offset(offset.X, offset.Y); } var outerArcSize = new Size(Radius, Radius); var innerArcSize = new Size(InnerRadius, InnerRadius); if (requiresMidPoint) { context.BeginFigure(innerArcStartPoint, true, true); context.LineTo(outerArcStartPoint, true, true); context.ArcTo(outerArcMidPoint, outerArcSize, 0, false, SweepDirection.Clockwise, true, true); context.ArcTo(outerArcEndPoint, outerArcSize, 0, false, SweepDirection.Clockwise, true, true); context.LineTo(innerArcEndPoint, true, true); context.ArcTo(innerArcMidPoint, innerArcSize, 0, false, SweepDirection.Counterclockwise, true, true); context.ArcTo(innerArcStartPoint, innerArcSize, 0, false, SweepDirection.Counterclockwise, true, true); return; } context.BeginFigure(innerArcStartPoint, true, true); context.LineTo(outerArcStartPoint, true, true); context.ArcTo(outerArcEndPoint, outerArcSize, 0, largeArc, SweepDirection.Clockwise, true, true); context.LineTo(innerArcEndPoint, true, true); context.ArcTo(innerArcStartPoint, innerArcSize, 0, largeArc, SweepDirection.Counterclockwise, true, true); }
private void DrawFilledSquare(StreamGeometryContext ctx, Point centerPoint, float size) { Point p1 = new Point(centerPoint.X - size / 2.0f, centerPoint.Y - size/2.0f); Point p2 = new Point(centerPoint.X + size / 2.0f, centerPoint.Y - size / 2.0f); Point p3 = new Point(centerPoint.X + size / 2.0f, centerPoint.Y + size / 2.0f); Point p4 = new Point(centerPoint.X - size / 2.0f, centerPoint.Y + size / 2.0f); ctx.BeginFigure(p1, true, false); ctx.LineTo(p2, false, false); ctx.LineTo(p3, false, false); ctx.LineTo(p4, false, false); ctx.LineTo(p1, false, false); }
private void DrawGeometry(StreamGeometryContext context, Point centre, float RotationAngle, float WedgeAngle, float Radius, float InnerRadius) { var innerArcStartPoint = ComputeCartesianCoordinate(RotationAngle, InnerRadius); innerArcStartPoint.Offset(centre.X, centre.Y); var innerArcEndPoint = ComputeCartesianCoordinate(RotationAngle + WedgeAngle, InnerRadius); innerArcEndPoint.Offset(centre.X, centre.Y); var outerArcStartPoint = ComputeCartesianCoordinate(RotationAngle, Radius); outerArcStartPoint.Offset(centre.X, centre.Y); var outerArcEndPoint = ComputeCartesianCoordinate(RotationAngle + WedgeAngle, Radius); outerArcEndPoint.Offset(centre.X, centre.Y); var largeArc = WedgeAngle > 180.0; var outerArcSize = new Size(Radius, Radius); var innerArcSize = new Size(InnerRadius, InnerRadius); context.BeginFigure(innerArcStartPoint, true, true); context.LineTo(outerArcStartPoint, true, true); context.ArcTo(outerArcEndPoint, outerArcSize, 0, largeArc, SweepDirection.Clockwise, true, true); context.LineTo(innerArcEndPoint, true, true); context.ArcTo(innerArcStartPoint, innerArcSize, 0, largeArc, SweepDirection.Counterclockwise, true, true); }
public void displayRecord() { //Find maximum and minimum for this graphlet, in case needed for scaling double max = double.NegativeInfinity; double min = double.PositiveInfinity; foreach (int channel in channels) { Multigraph.displayChannel dc = mg.displayedChannels.Where(n => n.channel == channel).First(); max = Math.Max(dc.max, max); min = Math.Min(dc.min, min); } //Check to see if new Y-axis and grid needed if(mg.individual) if (mg.useAllYMax) drawYGrid(Math.Max(mg.allChanMax, -mg.allChanMin)); else if (!mg.fixedYMax) //then must be per graphlet max drawYGrid(Math.Max(max,-min)); if (mg.individual) // make sure this is the only one { foreach (Plot pl in plots) gCanvas.Children.Remove(pl.path); plots.Clear(); graphletMax = double.MinValue; graphletMin = double.MaxValue; } foreach (int channel in channels) { Multigraph.displayChannel dc = mg.displayedChannels.Where(n => n.channel == channel).First(); points = new StreamGeometry(); ctx = points.Open(); ctx.BeginFigure(new Point(0, offset - mg.gp.halfMargin - dc.buffer[0] * graphletYScale), false, false); double maxY = 10D * MainWindow.graphletSize; for (int x = 1; x < dc.buffer.GetLength(0); x++) { double y = offset - mg.gp.halfMargin - dc.buffer[x] * graphletYScale; if (y > maxY) y = maxY; //limit size of displayed point else if (y < -maxY) y = -maxY; ctx.LineTo(new Point((double)x * graphletXScale, y), true, true); } ctx.Close(); points.Freeze(); Path p = new Path(); p.Stroke = channel == mg.highlightedChannel ? Brushes.Red : Brushes.Black; p.StrokeThickness = channel == mg.highlightedChannel ? strokeThickness * 2D : strokeThickness; p.StrokeLineJoin = PenLineJoin.Round; p.SnapsToDevicePixels = false; //use anti-aliasing p.Data = points; gCanvas.Children.Add(p); //draw the plot onto graphlet Plot pl = new Plot(); pl.path = p; pl.channel = channel; pl.recNumber = mg.RecSet; pl.max = max; graphletMax = Math.Max(graphletMax, max); //for superimposed records pl.min = min; graphletMin = Math.Min(graphletMin, min); pl.gvList = mg.gvList; plots.Add(pl); } }
/// <summary> /// Parse a PathFigureCollection string /// </summary> internal void ParseToGeometryContext( StreamGeometryContext context, string pathString, int startIndex) { // [BreakingChange] Dev10 Bug #453199 // We really should throw an ArgumentNullException here for context and pathString. // From original code // This is only used in call to Double.Parse _formatProvider = System.Globalization.CultureInfo.InvariantCulture; _context = context; _pathString = pathString; _pathLength = pathString.Length; _curIndex = startIndex; _secondLastPoint = new Point(0, 0); _lastPoint = new Point(0, 0); _lastStart = new Point(0, 0); _figureStarted = false; bool first = true; char last_cmd = ' '; while (ReadToken()) // Empty path is allowed in XAML { char cmd = _token; if (first) { if ((cmd != 'M') && (cmd != 'm')) // Path starts with M|m { ThrowBadToken(); } first = false; } switch (cmd) { case 'm': case 'M': // XAML allows multiple points after M/m _lastPoint = ReadPoint(cmd, ! AllowComma); context.BeginFigure(_lastPoint, IsFilled, ! IsClosed); _figureStarted = true; _lastStart = _lastPoint; last_cmd = 'M'; while (IsNumber(AllowComma)) { _lastPoint = ReadPoint(cmd, ! AllowComma); context.LineTo(_lastPoint, IsStroked, ! IsSmoothJoin); last_cmd = 'L'; } break; case 'l': case 'L': case 'h': case 'H': case 'v': case 'V': EnsureFigure(); do { switch (cmd) { case 'l': _lastPoint = ReadPoint(cmd, ! AllowComma); break; case 'L': _lastPoint = ReadPoint(cmd, ! AllowComma); break; case 'h': _lastPoint.X += ReadNumber(! AllowComma); break; case 'H': _lastPoint.X = ReadNumber(! AllowComma); break; case 'v': _lastPoint.Y += ReadNumber(! AllowComma); break; case 'V': _lastPoint.Y = ReadNumber(! AllowComma); break; } context.LineTo(_lastPoint, IsStroked, ! IsSmoothJoin); } while (IsNumber(AllowComma)); last_cmd = 'L'; break; case 'c': case 'C': // cubic Bezier case 's': case 'S': // smooth cublic Bezier EnsureFigure(); do { Point p; if ((cmd == 's') || (cmd == 'S')) { if (last_cmd == 'C') { p = Reflect(); } else { p = _lastPoint; } _secondLastPoint = ReadPoint(cmd, ! AllowComma); } else { p = ReadPoint(cmd, ! AllowComma); _secondLastPoint = ReadPoint(cmd, AllowComma); } _lastPoint = ReadPoint(cmd, AllowComma); context.BezierTo(p, _secondLastPoint, _lastPoint, IsStroked, ! IsSmoothJoin); last_cmd = 'C'; } while (IsNumber(AllowComma)); break; case 'q': case 'Q': // quadratic Bezier case 't': case 'T': // smooth quadratic Bezier EnsureFigure(); do { if ((cmd == 't') || (cmd == 'T')) { if (last_cmd == 'Q') { _secondLastPoint = Reflect(); } else { _secondLastPoint = _lastPoint; } _lastPoint = ReadPoint(cmd, ! AllowComma); } else { _secondLastPoint = ReadPoint(cmd, ! AllowComma); _lastPoint = ReadPoint(cmd, AllowComma); } context.QuadraticBezierTo(_secondLastPoint, _lastPoint, IsStroked, ! IsSmoothJoin); last_cmd = 'Q'; } while (IsNumber(AllowComma)); break; case 'a': case 'A': EnsureFigure(); do { // A 3,4 5, 0, 0, 6,7 double w = ReadNumber(! AllowComma); double h = ReadNumber(AllowComma); double rotation = ReadNumber(AllowComma); bool large = ReadBool(); bool sweep = ReadBool(); _lastPoint = ReadPoint(cmd, AllowComma); context.ArcTo( _lastPoint, new Size(w, h), rotation, large, #if PBTCOMPILER sweep, #else sweep ? SweepDirection.Clockwise : SweepDirection.Counterclockwise, #endif IsStroked, ! IsSmoothJoin ); } while (IsNumber(AllowComma)); last_cmd = 'A'; break; case 'z': case 'Z': EnsureFigure(); context.SetClosedState(IsClosed); _figureStarted = false; last_cmd = 'Z'; _lastPoint = _lastStart; // Set reference point to be first point of current figure break; default: ThrowBadToken(); break; } } }
/// <summary> /// Draws the primitive geometric components of the wedge. /// </summary> /// <param name="context">The context.</param> public void InternalDrawGeometry(StreamGeometryContext context) { Point startPoint = center; Point innerArcStartPoint = ComputeCartesianCoordinate(rotationAngle, innerRadius); innerArcStartPoint.Offset(center.X, center.Y); Point innerArcEndPoint = ComputeCartesianCoordinate(rotationAngle + sweep, innerRadius); innerArcEndPoint.Offset(center.X, center.Y); Point outerArcStartPoint = ComputeCartesianCoordinate(rotationAngle, /*innerRadius +*/ outerRadius); outerArcStartPoint.Offset(center.X, center.Y); Point outerArcEndPoint = ComputeCartesianCoordinate(rotationAngle + sweep, /*innerRadius +*/ outerRadius); outerArcEndPoint.Offset(center.X, center.Y); bool largeArc = sweep > 180.0; /* Point offset = ComputeCartesianCoordinate(rotationAngle + sweep / 2, PushOut); innerArcStartPoint.Offset(offset.X, offset.Y); innerArcEndPoint.Offset(offset.X, offset.Y); outerArcStartPoint.Offset(offset.X, offset.Y); outerArcEndPoint.Offset(offset.X, offset.Y); */ Size outerArcSize = new Size(/*innerRadius +*/ outerRadius, /*innerRadius +*/ outerRadius); Size innerArcSize = new Size(innerRadius, innerRadius); context.BeginFigure(innerArcStartPoint, true, true); context.LineTo(outerArcStartPoint, true, true); context.ArcTo(outerArcEndPoint, outerArcSize, 0, largeArc, SweepDirection.Clockwise, true, true); context.LineTo(innerArcEndPoint, true, true); context.ArcTo(innerArcStartPoint, innerArcSize, 0, largeArc, SweepDirection.Counterclockwise, true, true); }
/// <summary> /// Draws the pie piece /// </summary> private void DrawGeometry(StreamGeometryContext context) { Point startPoint = new Point(CentreX, CentreY); Point innerArcStartPoint = Utils.ComputeCartesianCoordinate(RotationAngle, InnerRadius); innerArcStartPoint.Offset(CentreX, CentreY); Point innerArcEndPoint = Utils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle, InnerRadius); innerArcEndPoint.Offset(CentreX, CentreY); Point outerArcStartPoint = Utils.ComputeCartesianCoordinate(RotationAngle, Radius); outerArcStartPoint.Offset(CentreX, CentreY); Point outerArcEndPoint = Utils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle, Radius); outerArcEndPoint.Offset(CentreX, CentreY); bool largeArc = WedgeAngle>180.0; if (PushOut > 0) { Point offset = Utils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle / 2, PushOut); innerArcStartPoint.Offset(offset.X, offset.Y); innerArcEndPoint.Offset(offset.X, offset.Y); outerArcStartPoint.Offset(offset.X, offset.Y); outerArcEndPoint.Offset(offset.X, offset.Y); } Size outerArcSize = new Size(Radius, Radius); Size innerArcSize = new Size(InnerRadius, InnerRadius); Size endingsArcSize = new Size(5, 5); context.BeginFigure(innerArcStartPoint, true, true); // Use LineTo to draw a flat endings //context.LineTo(outerArcStartPoint, true, true); context.ArcTo(outerArcStartPoint, endingsArcSize, 0, false, SweepDirection.Counterclockwise, true, true); context.ArcTo(outerArcEndPoint, outerArcSize, 0, largeArc, SweepDirection.Clockwise, true, true); //context.LineTo(innerArcEndPoint, true, true); context.ArcTo(innerArcEndPoint, endingsArcSize, 0, false, SweepDirection.Counterclockwise, true, true); context.ArcTo(innerArcStartPoint, innerArcSize, 0, largeArc, SweepDirection.Counterclockwise, true, true); }
// draws a filled arrow at the head private void _drawFilledArrowHead(StreamGeometryContext c, Point p, Vector v, double length, double thickness) { var p0 = p - v * length; var h = _rotate90(v) * thickness; c.BeginFigure(p0 + h, true, true); c.LineTo(p, true, true); c.LineTo(p0 - h, true, true); }
/// <summary> /// Draws the pie piece /// </summary> private void DrawGeometry(StreamGeometryContext context) { if (AngleDelta <= 0) { return; } double outerStartAngle = StartAngle; double outerAngleDelta = AngleDelta; double innerStartAngle = StartAngle; double innerAngleDelta = AngleDelta; Point arcCenter = new Point(CenterX, CenterY); Size outerArcSize = new Size(OuterRadius, OuterRadius); Size innerArcSize = new Size(InnerRadius, InnerRadius); // If have to draw a full-circle, draws two semi-circles, because 'ArcTo()' can not draw a full-circle if (AngleDelta >= 360 && Padding <= 0) { Point outerArcTopPoint = ComputeCartesianCoordinate(arcCenter, outerStartAngle, OuterRadius + PushOut); Point outerArcBottomPoint = ComputeCartesianCoordinate(arcCenter, outerStartAngle + 180, OuterRadius + PushOut); Point innerArcTopPoint = ComputeCartesianCoordinate(arcCenter, innerStartAngle, InnerRadius + PushOut); Point innerArcBottomPoint = ComputeCartesianCoordinate(arcCenter, innerStartAngle + 180, InnerRadius + PushOut); context.BeginFigure(innerArcTopPoint, true, true); context.LineTo(outerArcTopPoint, true, true); context.ArcTo(outerArcBottomPoint, outerArcSize, 0, false, SweepDirection.Clockwise, true, true); context.ArcTo(outerArcTopPoint, outerArcSize, 0, false, SweepDirection.Clockwise, true, true); context.LineTo(innerArcTopPoint, true, true); context.ArcTo(innerArcBottomPoint, innerArcSize, 0, false, SweepDirection.Counterclockwise, true, true); context.ArcTo(innerArcTopPoint, innerArcSize, 0, false, SweepDirection.Counterclockwise, true, true); } // Else draws as always else { if (Padding > 0) { // Offsets the angle by the padding double outerAngleVariation = (180 * (Padding / OuterRadius)) / Math.PI; double innerAngleVariation = (180 * (Padding / InnerRadius)) / Math.PI; outerStartAngle += outerAngleVariation; outerAngleDelta -= outerAngleVariation * 2; innerStartAngle += innerAngleVariation; innerAngleDelta -= innerAngleVariation * 2; } Point outerArcStartPoint = ComputeCartesianCoordinate(arcCenter, outerStartAngle, OuterRadius + PushOut); Point outerArcEndPoint = ComputeCartesianCoordinate(arcCenter, outerStartAngle + outerAngleDelta, OuterRadius + PushOut); Point innerArcStartPoint = ComputeCartesianCoordinate(arcCenter, innerStartAngle, InnerRadius + PushOut); Point innerArcEndPoint = ComputeCartesianCoordinate(arcCenter, innerStartAngle + innerAngleDelta, InnerRadius + PushOut); bool largeArcOuter = outerAngleDelta > 180.0; bool largeArcInner = innerAngleDelta > 180.0; context.BeginFigure(innerArcStartPoint, true, true); context.LineTo(outerArcStartPoint, true, true); context.ArcTo(outerArcEndPoint, outerArcSize, 0, largeArcOuter, SweepDirection.Clockwise, true, true); context.LineTo(innerArcEndPoint, true, true); context.ArcTo(innerArcStartPoint, innerArcSize, 0, largeArcInner, SweepDirection.Counterclockwise, true, true); } }
// draws a circle at the tail private void _drawCircularTail(StreamGeometryContext c, Point p, Vector v, double r) { var p0 = p - v * 2 * r; c.BeginFigure(p, true, true); c.ArcTo(p0, new Size(r, r), 0, false, SweepDirection.Clockwise, true, false); c.ArcTo(p, new Size(r, r), 0, false, SweepDirection.Clockwise, true, false); }
private void method18(StreamGeometryContext streamGeometryContext) { Point point = new Point(method10(), method12()); Point point2 = Utils.ComputeCartesianCoordinate(method8(), method4()); point2.Offset(method10(), method12()); Point point3 = Utils.ComputeCartesianCoordinate(method8() + method6(), method4()); point3.Offset(method10(), method12()); Point point4 = Utils.ComputeCartesianCoordinate(method8(), method0()); point4.Offset(method10(), method12()); Point point5 = Utils.ComputeCartesianCoordinate(method8() + method6(), method0()); point5.Offset(method10(), method12()); bool isLargeArc = method6() > 180.0; if (method2() > 0.0) { Point point6 = Utils.ComputeCartesianCoordinate(method8() + method6() / 2.0, method2()); point2.Offset(point6.X, point6.Y); point3.Offset(point6.X, point6.Y); point4.Offset(point6.X, point6.Y); point5.Offset(point6.X, point6.Y); } Size size = new Size(method0(), method0()); Size size2 = new Size(method4(), method4()); streamGeometryContext.BeginFigure(point2, true, true); streamGeometryContext.LineTo(point4, true, true); streamGeometryContext.ArcTo(point5, size, 0.0, isLargeArc, SweepDirection.Clockwise, true, true); streamGeometryContext.LineTo(point3, true, true); streamGeometryContext.ArcTo(point2, size2, 0.0, isLargeArc, SweepDirection.Counterclockwise, true, true); }
// draws a triangle at the tail private void _drawTriangularTail(StreamGeometryContext c, Point p, Vector v) { var p0 = p - v * 17; var h = _rotate90(v) * 15; c.BeginFigure(p, true, true); c.LineTo(p0 + h, true, true); c.LineTo(p0 - h, true, true); }