public void InitializeModel(ArcMode mode) { m_IntersectPoint[0] = new CustomVertex.PositionOnly(); m_IntersectPoint[1] = new CustomVertex.PositionOnly(); m_Mode = mode; //Set up rotation handles m_Verts = new CustomVertex.PositionOnly[CircleVertCount + 1]; float dc = 2f * (float)Math.PI / (CircleVertCount - 2); float arc = 0; float a, b; m_Verts[CircleVertCount] = new CustomVertex.PositionOnly(0, 0, 0); for (int i = 0; i < CircleVertCount; i++) { b = (float)(RadiusScale * Math.Cos(arc)); a = (float)(RadiusScale * Math.Sin(arc)); switch (m_Mode) { case ArcMode.Pitch: m_Verts[i] = new CustomVertex.PositionOnly(0, b, a); break; case ArcMode.Roll: m_Verts[i] = new CustomVertex.PositionOnly(a, 0, b); break; case ArcMode.Yaw: m_Verts[i] = new CustomVertex.PositionOnly(b, a, 0); break; } arc += dc; } for (short i = 0; i < CircleVertCount - 1; i++) { m_Arc[i] = i; m_Pie[i * 3] = (short)CircleVertCount; m_Pie[i * 3 + 1] = i; m_Pie[i * 3 + 2] = (short)(i + 1); } m_VertexBuffer = new VertexBuffer(typeof(CustomVertex.PositionOnly), m_Verts.Length, MdxRender.Device, Usage.WriteOnly, CustomVertex.PositionOnly.Format, Microsoft.DirectX.Direct3D.Pool.Default); m_VertexBuffer.Created += new EventHandler(this.OnVertexBufferCreate); OnVertexBufferCreate(m_VertexBuffer, null); m_ArcIndexBuffer = new IndexBuffer(typeof(short), m_Arc.Length, MdxRender.Device, Usage.WriteOnly, Microsoft.DirectX.Direct3D.Pool.Default); m_ArcIndexBuffer.Created += new EventHandler(this.OnArcIndexBufferCreate); OnArcIndexBufferCreate(m_ArcIndexBuffer, null); m_PieIndexBuffer = new IndexBuffer(typeof(short), m_Pie.Length, MdxRender.Device, Usage.WriteOnly, Microsoft.DirectX.Direct3D.Pool.Default); m_PieIndexBuffer.Created += new EventHandler(this.OnPieIndexBufferCreate); OnPieIndexBufferCreate(m_PieIndexBuffer, null); }
/// <summary> /// Draws an arc to the screen. Arcs are drawn along the outer edge of an ellipse defined /// by the a, b, c, and d parameters. The origin of the arc's ellipse may be changed with /// the ellipseMode() function. Use the start and stop parameters to specify the angles /// (in radians) at which to draw the arc. The start/stop values must be in clockwise order. /// /// There are three ways to draw an arc; the rendering technique used is defined by the optional /// seventh parameter.The three options, depicted in the above examples, are PIE, OPEN, and /// CHORD. The default mode is the OPEN stroke with a PIE fill. /// /// In some cases, the arc() function isn't accurate enough for smooth drawing. For example, the /// shape may jitter on screen when rotating slowly. If you're having an issue with how arcs are /// rendered, you'll need to draw the arc yourself with beginShape()/endShape() or a PShape. /// </summary> /// <param name="a">float: x-coordinate of the arc's ellipse</param> /// <param name="b">float: y-coordinate of the arc's ellipse</param> /// <param name="c">float: width of the arc's ellipse by default</param> /// <param name="d">float: height of the arc's ellipse by default</param> /// <param name="start">float: angle to start the arc, specified in radians</param> /// <param name="stop">float: angle to stop the arc, specified in radians</param> /// <param name="mode">int: OPEN, CHORD or PIE</param> public void arc(float a, float b, float c, float d, float start, float stop, ArcMode mode = ArcMode.OPEN) { var(x, y, w, h) = _style.EllipseMode switch { ShapeMode.CENTER => (a - c / 2, b - d / 2, c, d), ShapeMode.RADIUS => (a + c, b + d, c * 2, d * 2), ShapeMode.CORNER => (a, b, c, d), ShapeMode.CORNERS => (a, b, c - a, d - b), _ => throw new ArgumentOutOfRangeException() }; var rx = w / 2; var ry = h / 2; var center = new Vector2(x + rx, y + ry); if (mode == ArcMode.OPEN) { if (_style.Fill.A != 0) { FillArc(center, rx, ry, start, stop, _style.Fill, true); } if (_style.Stroke.A != 0) { DrawArc(center, rx, ry, start, stop, _style.Stroke, _style.StrokeWidth); } } if (mode == ArcMode.CHORD) { if (_style.Fill.A != 0) { FillArc(center, rx, ry, start, stop, _style.Fill, true); } if (_style.Stroke.A != 0) { DrawArc(center, rx, ry, start, stop, _style.Stroke, _style.StrokeWidth, 1); } } if (mode == ArcMode.PIE) { if (_style.Fill.A != 0) { FillArc(center, rx, ry, start, stop, _style.Fill); } if (_style.Stroke.A != 0) { DrawArc(center, rx, ry, start, stop, _style.Stroke, _style.StrokeWidth, 2); } } }
public Arc( Vector2 position, Vector2 dimensions, float startAngle, float stopAngle, ArcMode mode = ArcMode.Pie, uint detail = DEFAULT_DETAIL ) { _dimensions = dimensions; _position = position; StartAngle = startAngle; StopAngle = stopAngle; Mode = mode; Detail = detail; }
public Arc( Vector2 position, Vector2 dimensions, double startAngle, double stopAngle, ArcMode mode = ArcMode.Pie, uint detail = 25 ) { _dimensions = dimensions; _position = position; StartAngle = startAngle; StopAngle = stopAngle; Mode = mode; Detail = detail; }
public void DrawArc( Vector2 position, Vector2 dimensions, double startAngle, double stopAngle, ArcMode mode = ArcMode.Pie, uint detail = 25 ) => DrawArc( position.X, position.Y, dimensions.X, dimensions.Y, startAngle, stopAngle, mode, detail );
public void DrawArc( Vector2 position, Vector2 dimensions, float startAngle, float stopAngle, ArcMode mode = ArcMode.Pie, uint detail = Arc.DEFAULT_DETAIL ) => DrawArc( position.X, position.Y, dimensions.X, dimensions.Y, startAngle, stopAngle, mode, detail );
public Arc( float x, float y, float width, float height, float startAngle, float stopAngle, ArcMode mode = ArcMode.Pie, uint detail = DEFAULT_DETAIL ) : this( new Vector2(x, y), new Vector2(width, height), startAngle, stopAngle, mode, detail ) { }
public Arc( double x, double y, double w, double h, double startAngle, double stopAngle, ArcMode mode = ArcMode.Pie, uint detail = 25 ) : this( new Vector2(x, y), new Vector2(w, h), startAngle, stopAngle, mode, detail ) { }
public void DrawArc( double x, double y, double w, double h, double startAngle, double stopAngle, ArcMode mode = ArcMode.Pie, uint detail = 25 ) { _jsRuntime.InvokeVoid( _p5InvokeFunction, "arc", x, y, w, h, startAngle, stopAngle, Arc.ToString(mode), detail ); }
public void DrawArc( float x, float y, float width, float height, float startAngle, float stopAngle, ArcMode mode = ArcMode.Pie, uint detail = Arc.DEFAULT_DETAIL ) { _jsRuntime.InvokeVoid( _p5InvokeFunction, "arc", x, y, width, height, startAngle, stopAngle, Arc.ArcModeToString(mode), detail ); }
public static extern Status XSetArcMode(IntPtr display, IntPtr gc, ArcMode arc_mode);
public void SetMode(ArcMode Mode) { m_Mode = Mode; }
protected void Arc(double x, double y, double w, double h, double start, double stop, ArcMode mode = ArcMode.Pie) { double startRadians = -start * Math.PI / 180.0; double sweepRadians = -(stop - start) * Math.PI / 180.0; double rx = w / 2; double ry = h / 2; double startX = x + rx + (Math.Cos(startRadians) * rx); double startY = y + ry + (Math.Sin(startRadians) * ry); double endX = x + rx + (Math.Cos(startRadians + sweepRadians) * rx); double endY = y + ry + (Math.Sin(startRadians + sweepRadians) * ry); var geometry = new StreamGeometry(); using (var ctx = geometry.Open()) { bool isLargeArc = Math.Abs(stop - start) > 180; var direction = sweepRadians < 0 ? SweepDirection.Counterclockwise : SweepDirection.Clockwise; ctx.BeginFigure(new System.Windows.Point(startX, startY), mode != ArcMode.Open, mode != ArcMode.Open); ctx.ArcTo(new System.Windows.Point(endX, endY), new System.Windows.Size(rx, ry), 0, isLargeArc, direction, ShouldStroke(), false); if (mode == ArcMode.Pie) { ctx.LineTo(new System.Windows.Point(x + rx, y + ry), ShouldStroke(), false); ctx.LineTo(new System.Windows.Point(startX, startY), ShouldStroke(), false); } } var drawing = new GeometryDrawing(); drawing.Geometry = geometry; drawing.Pen = ShouldStroke() ? pen : null; drawing.Brush = ShouldFill() ? fillBrush : null; context.DrawDrawing(drawing); }