private Ellipse CreateEllipticalArc(ArcShape arc, double dx, double dy) { var a = new Spatial.Arc.GdiArc( Spatial.Point2.FromXY(arc.Point1.X, arc.Point1.Y), Spatial.Point2.FromXY(arc.Point2.X, arc.Point2.Y), Spatial.Point2.FromXY(arc.Point3.X, arc.Point3.Y), Spatial.Point2.FromXY(arc.Point4.X, arc.Point4.Y)); double _cx = ToDxfX(a.X + dx + a.Width / 2.0); double _cy = ToDxfY(a.Y + dy + a.Height / 2.0); double minor = Math.Min(a.Height, a.Width); double major = Math.Max(a.Height, a.Width); double startAngle = -a.EndAngle; double endAngle = -a.StartAngle; double rotation = 0; if (a.Height > a.Width) { startAngle += 90; endAngle += 90; rotation = -90; } return(new Ellipse() { Center = new Vector3(_cx, _cy, 0), MajorAxis = major, MinorAxis = minor, StartAngle = startAngle, EndAngle = endAngle, Rotation = rotation }); }
public void DrawArc(object dc, ArcShape arc, string styleId, double dx, double dy, double scale) { var geometry = new SKPath() { FillType = SKPathFillType.Winding }; SkiaHelper.AddArc(null, arc, dx, dy, geometry); _rootNodes[_currentRootNode].Children.Add(new ChildNode(arc, styleId, dx, dy, scale, geometry)); }
protected override bool BuildShapes() { Loops.Clear(); ArcShape circle = new ArcShape(); circle.Radius = Radius; AddShape(circle); return(true); }
private void CreateArcNeedle(INeedle needle) { ComplexShape needleShape = (ComplexShape)needle.Shape; needleShape.Collection.Clear(); ArcShape shape = new ArcShape(new RectangleF2D(new PointF(-10, 0), new SizeF(20, 10)), 180, -60); shape.Appearance.ContentBrush = new SolidBrushObject(Color.White); shape.Name = "arcNeedle"; needleShape.Add(shape); }
/// <inheritdoc/> public override void Draw(object dc, ArcShape arc, double dx, double dy, object db, object r) { var _gfx = dc as XGraphics; var a = new Spatial.Arc.GdiArc( Spatial.Point2.FromXY(arc.Point1.X, arc.Point1.Y), Spatial.Point2.FromXY(arc.Point2.X, arc.Point2.Y), Spatial.Point2.FromXY(arc.Point3.X, arc.Point3.Y), Spatial.Point2.FromXY(arc.Point4.X, arc.Point4.Y)); if (arc.IsFilled) { var path = new XGraphicsPath(); // NOTE: Not implemented in PdfSharp Core version. path.AddArc( _scaleToPage(a.X + dx), _scaleToPage(a.Y + dy), _scaleToPage(a.Width), _scaleToPage(a.Height), a.StartAngle, a.SweepAngle); if (arc.IsStroked) { _gfx.DrawPath( ToXPen(arc.Style, _scaleToPage, _sourceDpi, _targetDpi), ToXSolidBrush(arc.Style.Fill), path); } else { _gfx.DrawPath( ToXSolidBrush(arc.Style.Fill), path); } } else { if (arc.IsStroked) { _gfx.DrawArc( ToXPen(arc.Style, _scaleToPage, _sourceDpi, _targetDpi), _scaleToPage(a.X + dx), _scaleToPage(a.Y + dy), _scaleToPage(a.Width), _scaleToPage(a.Height), a.StartAngle, a.SweepAngle); } } }
/// <inheritdoc/> ArcShape IShapeFactory.Arc(PointShape point1, PointShape point2, PointShape point3, PointShape point4, bool isStroked, bool isFilled) { var style = _editor.Project.CurrentStyleLibrary.Selected; var arc = ArcShape.Create( point1, point2, point3, point4, _editor.Project.Options.CloneStyle ? style.Clone() : style, _editor.Project.Options.PointShape, isStroked, isFilled); _editor.Project.AddShape(_editor.Project.CurrentContainer.CurrentLayer, arc); return(arc); }
/// <inheritdoc/> ArcShape IShapeFactory.Arc(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, bool isStroked, bool isFilled) { var style = _editor.Project.CurrentStyleLibrary.Selected; var arc = ArcShape.Create( x1, y1, x2, y2, x3, y3, x4, y4, _editor.Project.Options.CloneStyle ? style.Clone() : style, _editor.Project.Options.PointShape, isStroked, isFilled); _editor.Project.AddShape(_editor.Project.CurrentContainer.CurrentLayer, arc); return(arc); }
protected override bool BuildShapes() { Loops.Clear(); LineShape line1 = new LineShape(); ArcShape arc1 = new ArcShape(); LineShape line2 = new LineShape(); ArcShape arc2 = new ArcShape(); AddShape(line1); AddShape(arc1); AddShape(line2); AddShape(arc2); return(true); }
/// <inheritdoc/> public override void Draw(object dc, ArcShape arc, double dx, double dy, object db, object r) { var a = new GdiArc( Point2.FromXY(arc.Point1.X, arc.Point1.Y), Point2.FromXY(arc.Point2.X, arc.Point2.Y), Point2.FromXY(arc.Point3.X, arc.Point3.Y), Point2.FromXY(arc.Point4.X, arc.Point4.Y)); if (a.Width <= 0.0 || a.Height <= 0.0) { return; } var _gfx = dc as Graphics; Brush brush = ToSolidBrush(arc.Style.Fill); Pen pen = ToPen(arc.Style, _scaleToPage); if (arc.IsFilled) { var path = new GraphicsPath(); path.AddArc( _scaleToPage(a.X + dx), _scaleToPage(a.Y + dy), _scaleToPage(a.Width), _scaleToPage(a.Height), (float)a.StartAngle, (float)a.SweepAngle); _gfx.FillPath(brush, path); } if (arc.IsStroked) { _gfx.DrawArc( pen, _scaleToPage(a.X + dx), _scaleToPage(a.Y + dy), _scaleToPage(a.Width), _scaleToPage(a.Height), (float)a.StartAngle, (float)a.SweepAngle); } brush.Dispose(); pen.Dispose(); }
/// <inheritdoc/> public override void Draw(object dc, ArcShape arc, double dx, double dy, object db, object r) { var dxf = dc as DxfDocument; var style = arc.Style; var dxfEllipse = CreateEllipticalArc(arc, dx, dy); if (arc.IsFilled) { var fill = ToColor(style.Fill); var fillTransparency = ToTransparency(style.Fill); // TODO: The netDxf does not create hatch for Ellipse with end angle equal to 360. var bounds = new List <HatchBoundaryPath> { new HatchBoundaryPath( new List <EntityObject> { (Ellipse)dxfEllipse.Clone() }) }; var hatch = new Hatch(HatchPattern.Solid, bounds, false); hatch.Layer = _currentLayer; hatch.Color = fill; hatch.Transparency.Value = fillTransparency; dxf.AddEntity(hatch); } if (arc.IsStroked) { var stroke = ToColor(style.Stroke); var strokeTansparency = ToTransparency(style.Stroke); var lineweight = ToLineweight(style.Thickness); dxfEllipse.Layer = _currentLayer; dxfEllipse.Color = stroke; dxfEllipse.Transparency.Value = strokeTansparency; dxfEllipse.Lineweight = lineweight; dxf.AddEntity(dxfEllipse); } }
public static Rect2 ArcBounds(ArcShape arc) { double x1 = arc.Point1.X; double y1 = arc.Point1.Y; double x2 = arc.Point2.X; double y2 = arc.Point2.Y; double x0 = (x1 + x2) / 2.0; double y0 = (y1 + y2) / 2.0; double r = Math.Sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)); double x = x0 - r; double y = y0 - r; double width = 2.0 * r; double height = 2.0 * r; return(new Rect2(x, y, width, height)); }
/// <inheritdoc/> public override void Draw(object dc, ArcShape arc, double dx, double dy, object db, object r) { if (!arc.IsFilled && !arc.IsStroked) { return; } var _dc = dc as AM.DrawingContext; AM.IBrush brush = ToBrush(arc.Style.Fill); AM.Pen pen = ToPen(arc.Style, _scaleToPage); var sg = new AM.StreamGeometry(); using (var sgc = sg.Open()) { var a = new WpfArc( Point2.FromXY(arc.Point1.X, arc.Point1.Y), Point2.FromXY(arc.Point2.X, arc.Point2.Y), Point2.FromXY(arc.Point3.X, arc.Point3.Y), Point2.FromXY(arc.Point4.X, arc.Point4.Y)); sgc.BeginFigure( new A.Point(a.Start.X + dx, a.Start.Y), arc.IsFilled); sgc.ArcTo( new A.Point(a.End.X + dx, a.End.Y + dy), new A.Size(a.Radius.Width, a.Radius.Height), 0.0, a.IsLargeArc, AM.SweepDirection.Clockwise); sgc.EndFigure(false); } _dc.DrawGeometry( arc.IsFilled ? brush : null, arc.IsStroked ? pen : null, sg); }
/// <inheritdoc/> public override void Draw(object dc, ArcShape arc, double dx, double dy, object db, object r) { var canvas = dc as SKCanvas; using (SKPaint brush = ToSKPaintBrush(arc.Style.Fill)) using (SKPaint pen = ToSKPaintPen(arc.Style, _scaleToPage, _sourceDpi, _targetDpi)) using (var path = new SKPath()) { var a = new GdiArc( Point2.FromXY(arc.Point1.X, arc.Point1.Y), Point2.FromXY(arc.Point2.X, arc.Point2.Y), Point2.FromXY(arc.Point3.X, arc.Point3.Y), Point2.FromXY(arc.Point4.X, arc.Point4.Y)); var rect = new SKRect( _scaleToPage(a.X + dx), _scaleToPage(a.Y + dy), _scaleToPage(a.X + dx + a.Width), _scaleToPage(a.Y + dy + a.Height)); path.AddArc(rect, (float)a.StartAngle, (float)a.SweepAngle); DrawPathInternal(canvas, brush, pen, arc.IsStroked, arc.IsFilled, path); } }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Point3d point = new Point3d(); DA.GetData(0, ref point); double size = 0; DA.GetData(1, ref size); double startAngle = 0; DA.GetData(2, ref startAngle); double sweepAngle = 0; DA.GetData(3, ref sweepAngle); Pen outline = null; DA.GetData(4, ref outline); Pen fill = null; DA.GetData(5, ref fill); Shape2D shape = new ArcShape(point, size, startAngle, sweepAngle, pie); if (outline != null) { shape.outline(outline); } if (fill != null) { shape.fill(fill); } DA.SetData(0, shape); }
/// <inheritdoc/> public override void Draw(object dc, ArcShape arc, double dx, double dy, object db, object r) { var _dc = dc as DrawingContext; var style = arc.Style; if (style == null) { return; } double thickness = style.Thickness / _state.ZoomX; double half = thickness / 2.0; Tuple <Brush, Pen> styleCached = _styleCache.Get(style); Brush fill; Pen stroke; if (styleCached != null) { fill = styleCached.Item1; stroke = styleCached.Item2; } else { fill = CreateBrush(style.Fill); stroke = CreatePen(style, thickness); _styleCache.Set(style, Tuple.Create(fill, stroke)); } var a = new WpfArc( Point2.FromXY(arc.Point1.X, arc.Point1.Y), Point2.FromXY(arc.Point2.X, arc.Point2.Y), Point2.FromXY(arc.Point3.X, arc.Point3.Y), Point2.FromXY(arc.Point4.X, arc.Point4.Y)); System.Windows.Media.PathGeometry pg = _arcCache.Get(arc); if (pg != null) { var pf = pg.Figures[0]; pf.StartPoint = new Point(a.Start.X + dx, a.Start.Y + dy); pf.IsFilled = arc.IsFilled; var segment = pf.Segments[0] as ArcSegment; segment.Point = new Point(a.End.X + dx, a.End.Y + dy); segment.Size = new Size(a.Radius.Width, a.Radius.Height); segment.IsLargeArc = a.IsLargeArc; segment.IsStroked = arc.IsStroked; } else { var pf = new System.Windows.Media.PathFigure() { StartPoint = new Point(a.Start.X, a.Start.Y), IsFilled = arc.IsFilled }; var segment = new ArcSegment( new Point(a.End.X, a.End.Y), new Size(a.Radius.Width, a.Radius.Height), 0.0, a.IsLargeArc, System.Windows.Media.SweepDirection.Clockwise, arc.IsStroked); //segment.Freeze(); pf.Segments.Add(segment); //pf.Freeze(); pg = new System.Windows.Media.PathGeometry(); pg.Figures.Add(pf); //pg.Freeze(); _arcCache.Set(arc, pg); } DrawPathGeometryInternal(_dc, half, fill, stroke, arc.IsStroked, arc.IsFilled, pg); }
public void Inherits_From_BaseShape() { var target = new ArcShape(); Assert.True(target is BaseShape); }
/// <summary> /// Initializes static designer context. /// </summary> /// <param name="serviceProvider">The service provider.</param> public static void InitializeContext(IServiceProvider serviceProvider) { // Editor Editor = serviceProvider.GetService <ProjectEditor>(); // Recent Projects Editor.RecentProjects = Editor.RecentProjects.Add(RecentFile.Create("Test1", "Test1.project")); Editor.RecentProjects = Editor.RecentProjects.Add(RecentFile.Create("Test2", "Test2.project")); // New Project Editor.OnNewProject(); // Transform Transform = MatrixObject.Identity; // Data var db = Database.Create("Db"); var fields = new string[] { "Column0", "Column1" }; var columns = ImmutableArray.CreateRange(fields.Select(c => Column.Create(db, c))); db.Columns = columns; var values = Enumerable.Repeat("<empty>", db.Columns.Length).Select(c => Value.Create(c)); var record = Record.Create( db, ImmutableArray.CreateRange(values)); db.Records = db.Records.Add(record); db.CurrentRecord = record; Database = db; Data = Context.Create(record); Record = record; // Project IProjectFactory factory = new ProjectFactory(); Project = factory.GetProject(); Template = PageContainer.CreateTemplate(); Page = PageContainer.CreatePage(); var layer = Page.Layers.FirstOrDefault(); layer.Shapes = layer.Shapes.Add(LineShape.Create(0, 0, null, null)); Page.CurrentLayer = layer; Page.CurrentShape = layer.Shapes.FirstOrDefault(); Page.Template = Template; Document = DocumentContainer.Create(); Layer = LayerContainer.Create(); Options = Options.Create(); // State State = ShapeState.Create(); // Style ArgbColor = ArgbColor.Create(128, 255, 0, 0); ArrowStyle = ArrowStyle.Create(); FontStyle = FontStyle.Create(); LineFixedLength = LineFixedLength.Create(); LineStyle = LineStyle.Create(); Style = ShapeStyle.Create("Default"); TextStyle = TextStyle.Create(); // Shapes Arc = ArcShape.Create(0, 0, Style, null); CubicBezier = CubicBezierShape.Create(0, 0, Style, null); Ellipse = EllipseShape.Create(0, 0, Style, null); Group = GroupShape.Create(Constants.DefaulGroupName); Image = ImageShape.Create(0, 0, Style, null, "key"); Line = LineShape.Create(0, 0, Style, null); Path = PathShape.Create(Style, null); Point = PointShape.Create(); QuadraticBezier = QuadraticBezierShape.Create(0, 0, Style, null); Rectangle = RectangleShape.Create(0, 0, Style, null); Text = TextShape.Create(0, 0, Style, null, "Text"); // Path ArcSegment = ArcSegment.Create(PointShape.Create(), PathSize.Create(), 180, true, SweepDirection.Clockwise, true, true); CubicBezierSegment = CubicBezierSegment.Create(PointShape.Create(), PointShape.Create(), PointShape.Create(), true, true); LineSegment = LineSegment.Create(PointShape.Create(), true, true); PathFigure = PathFigure.Create(PointShape.Create(), false, true); PathGeometry = PathGeometry.Create(ImmutableArray.Create <PathFigure>(), FillRule.EvenOdd); PathSize = PathSize.Create(); PolyCubicBezierSegment = PolyCubicBezierSegment.Create(ImmutableArray.Create <PointShape>(), true, true); PolyLineSegment = PolyLineSegment.Create(ImmutableArray.Create <PointShape>(), true, true); PolyQuadraticBezierSegment = PolyQuadraticBezierSegment.Create(ImmutableArray.Create <PointShape>(), true, true); QuadraticBezierSegment = QuadraticBezierSegment.Create(PointShape.Create(), PointShape.Create(), true, true); }
public void Draw(object dc, IShapeRenderer renderer, ArcShape arcShape, double dx, double dy, double scale) { var distance = arcShape.StartPoint.DistanceTo(arcShape.Point); DrawRectangle(dc, renderer, arcShape.StartPoint.X, arcShape.StartPoint.Y, distance, dx, dy, scale); }