static ICurve GetRandomShape(Random random) { //we support rectangle, roundedRectangle, circle, ellipse, diamond, Octagon, triangle, star int index = random.Next(3); var center = new Microsoft.Msagl.Core.Geometry.Point(); switch (index) { case 0: return(CurveFactory.CreateRectangle(20 + random.Next(10), 10 + random.Next(10), center)); case 1: return(CurveFactory.CreateRectangleWithRoundedCorners(30 + random.Next(10), 20 + random.Next(10), 1 + random.Next(8), 1 + random.Next(8), center)); case 2: return(CurveFactory.CreateEllipse(26, 18, center)); } return(null); }
private static IEnumerable <DebugCurve> MarkPathVerts(Path path) { bool first = true; var p = new Point(); foreach (var p0 in path.PathPoints) { if (first) { yield return(new DebugCurve(200, 1, "violet", CurveFactory.CreateDiamond(5, 5, p0))); first = false; } else { yield return(new DebugCurve(100, 0.5, "brown", CurveFactory.CreateEllipse(1.5, 1.5, p0))); } p = p0; } yield return(new DebugCurve(200, 1, "green", CurveFactory.CreateDiamond(3, 3, p))); }
/// <summary> /// Controlling the draw because a need to control the size. /// /// Supporting these shapes : /// Box /// Ellipse /// Circle /// Plaintext /// Point /// </summary> /// <param name="node"></param> /// <param name="centerLocation"></param> /// <param name="width"></param> /// <param name="hight"></param> /// <returns></returns> ICurve DrawCurve(Microsoft.Msagl.Drawing.Node node) { ICurve shape = null; switch (node.Attr.Shape) { case Shape.Box: shape = CurveFactory.CreateRectangle(NodeWidth, NodeHeight, NodeCenter); break; case Shape.Ellipse: shape = CurveFactory.CreateEllipse(NodeWidth, NodeHeight, NodeCenter); break; case Shape.Circle: shape = CurveFactory.CreateCircle(NodeWidth, NodeCenter); break; case Shape.Point: shape = CurveFactory.CreateCircle(0.5, NodeCenter); break; case Shape.Diamond: shape = CurveFactory.CreateDiamond(NodeWidth, NodeHeight, NodeCenter); break; case Shape.Hexagon: shape = CurveFactory.CreateHexagon(NodeWidth, NodeHeight, NodeCenter); break; case Shape.Octagon: shape = CurveFactory.CreateOctagon(NodeWidth, NodeHeight, NodeCenter); break; } return(shape); }
static ICurve CreateEllipse() { return(CurveFactory.CreateEllipse(20, 10, new Point())); }
void ShowEdge(AxisEdge edge, Point point) { // ReSharper restore SuggestBaseTypeForParameter var dd = GetObstacleBoundaries("black"); var seg = new DebugCurve(1, "red", new LineSegment(edge.Source.Point, edge.Target.Point)); LayoutAlgorithmSettings.ShowDebugCurvesEnumeration(dd.Concat( new[] { seg, new DebugCurve("blue", CurveFactory.CreateEllipse(3, 3, point)) })); }
public static ICurve GetNodeBoundary(Microsoft.Msagl.Drawing.Node n) { double cell = s_random.Next(50, 80); double ecc = (((double)s_random.Next(20, 100) / 100.00) * cell); switch (n.Id.Split()[0]) { case "Rhombus": return(CurveFactory.CreateDiamond(cell / 2.0, ecc / 2.0, new Microsoft.Msagl.Core.Geometry.Point())); case "Circle": return(CurveFactory.CreateCircle(cell / 2.0, new Microsoft.Msagl.Core.Geometry.Point())); case "Ellipse": return(CurveFactory.CreateEllipse(cell / 2.0, ecc / 2.0, new Microsoft.Msagl.Core.Geometry.Point())); case "Rectangle": return(CurveFactory.CreateRectangle(cell, ecc, new Point())); case "Parallelogram": { ICurve baseRect = CurveFactory.CreateRectangle(cell, ecc, new Point()); return(baseRect.Transform(new PlaneTransformation(1, (double)s_random.Next(0, 100) / 100.00, 0, 0, 1, 0))); } case "CurvedRectangle": return(CurveFactory.CreateRectangleWithRoundedCorners(cell * 2, ecc, ecc / 4, ecc / 4, new Microsoft.Msagl.Core.Geometry.Point())); case "Process": { Curve curve = (Curve)CurveFactory.CreateRectangle(cell * 2, ecc, new Microsoft.Msagl.Core.Geometry.Point()); Curve curveInner = (Curve)CurveFactory.CreateRectangle(cell * 1.5, ecc, new Microsoft.Msagl.Core.Geometry.Point()); Curve.CloseCurve(curve); Curve.CloseCurve(curveInner); Curve.AddLineSegment(curve, curve.Start, curveInner.Start); curve.AddSegment(curveInner); return(curve); } case "ElongatedEllipse": { var curve = new Curve(); double x = cell; double y = ecc; double r = x / 2; curve.AddSegment(new Ellipse(1.5 * Math.PI, 2.5 * Math.PI, new Point(r, 0), new Point(0, y), new Point(x, 0))); curve.AddSegment(new LineSegment(curve.End, new Point(-1 * x, y))); curve.AddSegment(new Ellipse(0.5 * Math.PI, 1.5 * Math.PI, new Point(r, 0), new Point(0, y), new Point(-1 * x, 0))); Curve.CloseCurve(curve); return(curve); } case "Database": { var curve = new Curve(); double x = ecc; double y = cell; double r = y / 2; curve.AddSegment(new Ellipse(new Point(x, 0), new Point(0, r), new Point(0, 0))); curve.AddSegment(new Ellipse(0, Math.PI, new Point(x, 0), new Point(0, r), new Point(0, 0))); curve.AddSegment(new LineSegment(curve.End, new Point(-1 * x, -1 * y))); curve.AddSegment(new LineSegment(curve.End, new Point(x, -1 * y))); Curve.CloseCurve(curve); return(curve); } } throw new Exception("unrecognised shape type"); }