//----- public void RoundedRect(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 p5, Vector2 p6, Vector2 p7, Vector2 p8, float r1, float r2, float angle, float width) { if ((int) width == 1) { RoundedRect(p1, p2, p3, p4, p5, p6, p7, p8, r1, r2, angle); return; } Line(p1, p2, width); Line(p3, p4, width); Line(p5, p6, width); Line(p7, p8, width); Vector2 _p1 = Vector2.zero; Vector2 _p2 = Vector2.zero; Vector2 _p3 = Vector2.zero; Vector2 _p4 = Vector2.zero; _graphics.GetThickLine(p1, p2, width, ref _p1, ref _p2, ref _p3, ref _p4); Vector2 _p5 = Vector2.zero; Vector2 _p6 = Vector2.zero; Vector2 _p7 = Vector2.zero; Vector2 _p8 = Vector2.zero; //------- _graphics.GetThickLine(p3, p4, width, ref _p5, ref _p6, ref _p7, ref _p8); SVGGraphicsPath _graphicsPath = new SVGGraphicsPath(); _graphicsPath.AddMoveTo(_p4); _graphicsPath.AddArcTo(r1 + (width/2f), r2 + (width/2f), angle, false, true, _p6); _graphicsPath.AddLineTo(_p5); _graphicsPath.AddArcTo(r1 - (width/2f), r2 - (width/2f), angle, false, false, _p3); _graphicsPath.AddLineTo(_p4); _graphics.FillPath(_graphicsPath); //------- _graphics.GetThickLine(p5, p6, width, ref _p1, ref _p2, ref _p3, ref _p4); _graphicsPath.Reset(); _graphicsPath.AddMoveTo(_p8); _graphicsPath.AddArcTo(r1 + (width/2f), r2 + (width/2f), angle, false, true, _p2); _graphicsPath.AddLineTo(_p1); _graphicsPath.AddArcTo(r1 - (width/2f), r2 - (width/2f), angle, false, false, _p7); _graphicsPath.AddLineTo(_p8); _graphics.FillPath(_graphicsPath); //---------- _graphics.GetThickLine(p7, p8, width, ref _p5, ref _p6, ref _p7, ref _p8); _graphicsPath.Reset(); _graphicsPath.AddMoveTo(_p4); _graphicsPath.AddArcTo(r1 + (width/2f), r2 + (width/2f), angle, false, true, _p6); _graphicsPath.AddLineTo(_p5); _graphicsPath.AddArcTo(r1 - (width/2f), r2 - (width/2f), angle, false, false, _p3); _graphicsPath.AddLineTo(_p4); _graphics.FillPath(_graphicsPath); //------- _graphics.GetThickLine(p1, p2, width, ref _p1, ref _p2, ref _p3, ref _p4); _graphicsPath.Reset(); _graphicsPath.AddMoveTo(_p8); _graphicsPath.AddArcTo(r1 + (width/2f), r2 + (width/2f), angle, false, true, _p2); _graphicsPath.AddLineTo(_p1); _graphicsPath.AddArcTo(r1 - (width/2f), r2 - (width/2f), angle, false, false, _p7); _graphicsPath.AddLineTo(_p8); _graphics.FillPath(_graphicsPath); }
public void RoundedRect(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 p5, Vector2 p6, Vector2 p7, Vector2 p8, float r1, float r2, float angle, float width) { if ((int)width == 1) { RoundedRect(p1, p2, p3, p4, p5, p6, p7, p8, r1, r2, angle); return; } Line(p1, p2, width); Line(p3, p4, width); Line(p5, p6, width); Line(p7, p8, width); // TODO: IIRC, `Vector2.zero` is a p/invoke. Would it be safe to chain assignments here? Would it be more // TODO: performant? What about just calling `new Vector2(0f, 0f)`? Vector2 _p1 = Vector2.zero; Vector2 _p2 = Vector2.zero; Vector2 _p3 = Vector2.zero; Vector2 _p4 = Vector2.zero; _graphics.GetThickLine(p1, p2, width, ref _p1, ref _p2, ref _p3, ref _p4); Vector2 _p5 = Vector2.zero; Vector2 _p6 = Vector2.zero; Vector2 _p7 = Vector2.zero; Vector2 _p8 = Vector2.zero; //------- _graphics.GetThickLine(p3, p4, width, ref _p5, ref _p6, ref _p7, ref _p8); SVGGraphicsPath _graphicsPath = new SVGGraphicsPath(); _graphicsPath.AddMoveTo(_p4); _graphicsPath.AddArcTo(r1 + (width / 2f), r2 + (width / 2f), angle, false, true, _p6); _graphicsPath.AddLineTo(_p5); _graphicsPath.AddArcTo(r1 - (width / 2f), r2 - (width / 2f), angle, false, false, _p3); _graphicsPath.AddLineTo(_p4); _graphics.FillPath(_graphicsPath); //------- _graphics.GetThickLine(p5, p6, width, ref _p1, ref _p2, ref _p3, ref _p4); _graphicsPath.Reset(); _graphicsPath.AddMoveTo(_p8); _graphicsPath.AddArcTo(r1 + (width / 2f), r2 + (width / 2f), angle, false, true, _p2); _graphicsPath.AddLineTo(_p1); _graphicsPath.AddArcTo(r1 - (width / 2f), r2 - (width / 2f), angle, false, false, _p7); _graphicsPath.AddLineTo(_p8); _graphics.FillPath(_graphicsPath); //---------- _graphics.GetThickLine(p7, p8, width, ref _p5, ref _p6, ref _p7, ref _p8); _graphicsPath.Reset(); _graphicsPath.AddMoveTo(_p4); _graphicsPath.AddArcTo(r1 + (width / 2f), r2 + (width / 2f), angle, false, true, _p6); _graphicsPath.AddLineTo(_p5); _graphicsPath.AddArcTo(r1 - (width / 2f), r2 - (width / 2f), angle, false, false, _p3); _graphicsPath.AddLineTo(_p4); _graphics.FillPath(_graphicsPath); //------- _graphics.GetThickLine(p1, p2, width, ref _p1, ref _p2, ref _p3, ref _p4); _graphicsPath.Reset(); _graphicsPath.AddMoveTo(_p8); _graphicsPath.AddArcTo(r1 + (width / 2f), r2 + (width / 2f), angle, false, true, _p2); _graphicsPath.AddLineTo(_p1); _graphicsPath.AddArcTo(r1 - (width / 2f), r2 - (width / 2f), angle, false, false, _p7); _graphicsPath.AddLineTo(_p8); _graphics.FillPath(_graphicsPath); }
//----- public void RoundedRect(SVGPoint p1, SVGPoint p2, SVGPoint p3, SVGPoint p4, SVGPoint p5, SVGPoint p6, SVGPoint p7, SVGPoint p8, float r1, float r2, float angle, float width) { if((int)width == 1) { RoundedRect(p1, p2, p3, p4, p5, p6, p7, p8, r1, r2, angle); return; } Line(p1, p2, width); Line(p3, p4, width); Line(p5, p6, width); Line(p7, p8, width); SVGPoint _p1 = new SVGPoint(0f, 0f); SVGPoint _p2 = new SVGPoint(0f, 0f); SVGPoint _p3 = new SVGPoint(0f, 0f); SVGPoint _p4 = new SVGPoint(0f, 0f); this._graphics.GetThickLine(p1, p2, width, ref _p1, ref _p2, ref _p3, ref _p4); SVGPoint _p5 = new SVGPoint(0f, 0f); SVGPoint _p6 = new SVGPoint(0f, 0f); SVGPoint _p7 = new SVGPoint(0f, 0f); SVGPoint _p8 = new SVGPoint(0f, 0f); //------- this._graphics.GetThickLine(p3, p4, width, ref _p5, ref _p6, ref _p7, ref _p8); SVGGraphicsPath _graphicsPath = new SVGGraphicsPath(); _graphicsPath.AddMoveTo(_p4); _graphicsPath.AddArcTo(r1 + (width / 2f), r2 + (width / 2f), angle, false, true, _p6); _graphicsPath.AddLineTo(_p5); _graphicsPath.AddArcTo(r1 - (width / 2f), r2 - (width / 2f), angle, false, false, _p3); _graphicsPath.AddLineTo(_p4); this._graphics.FillPath(_graphicsPath); //------- this._graphics.GetThickLine(p5, p6, width, ref _p1, ref _p2, ref _p3, ref _p4); _graphicsPath.Reset(); _graphicsPath.AddMoveTo(_p8); _graphicsPath.AddArcTo(r1 + (width / 2f), r2 + (width / 2f), angle, false, true, _p2); _graphicsPath.AddLineTo(_p1); _graphicsPath.AddArcTo(r1 - (width / 2f), r2 - (width / 2f), angle, false, false, _p7); _graphicsPath.AddLineTo(_p8); this._graphics.FillPath(_graphicsPath); //---------- this._graphics.GetThickLine(p7, p8, width, ref _p5, ref _p6, ref _p7, ref _p8); _graphicsPath.Reset(); _graphicsPath.AddMoveTo(_p4); _graphicsPath.AddArcTo(r1 + (width / 2f), r2 + (width / 2f), angle, false, true, _p6); _graphicsPath.AddLineTo(_p5); _graphicsPath.AddArcTo(r1 - (width / 2f), r2 - (width / 2f), angle, false, false, _p3); _graphicsPath.AddLineTo(_p4); this._graphics.FillPath(_graphicsPath); //------- this._graphics.GetThickLine(p1, p2, width, ref _p1, ref _p2, ref _p3, ref _p4); _graphicsPath.Reset(); _graphicsPath.AddMoveTo(_p8); _graphicsPath.AddArcTo(r1 + (width / 2f), r2 + (width / 2f), angle, false, true, _p2); _graphicsPath.AddLineTo(_p1); _graphicsPath.AddArcTo(r1 - (width / 2f), r2 - (width / 2f), angle, false, false, _p7); _graphicsPath.AddLineTo(_p8); this._graphics.FillPath(_graphicsPath); }
//----- public void RoundedRect(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 p5, Vector2 p6, Vector2 p7, Vector2 p8, float r1, float r2, float angle, float width) { if ((int)width == 1) { RoundedRect(p1, p2, p3, p4, p5, p6, p7, p8, r1, r2, angle); return; } Line(p1, p2, width); Line(p3, p4, width); Line(p5, p6, width); Line(p7, p8, width); Vector2 _p1 = new Vector2(0f, 0f); Vector2 _p2 = new Vector2(0f, 0f); Vector2 _p3 = new Vector2(0f, 0f); Vector2 _p4 = new Vector2(0f, 0f); this._graphics.GetThickLine(p1, p2, width, ref _p1, ref _p2, ref _p3, ref _p4); Vector2 _p5 = new Vector2(0f, 0f); Vector2 _p6 = new Vector2(0f, 0f); Vector2 _p7 = new Vector2(0f, 0f); Vector2 _p8 = new Vector2(0f, 0f); //------- this._graphics.GetThickLine(p3, p4, width, ref _p5, ref _p6, ref _p7, ref _p8); SVGGraphicsPath _graphicsPath = new SVGGraphicsPath(); _graphicsPath.AddMoveTo(_p4); _graphicsPath.AddArcTo(r1 + (width / 2f), r2 + (width / 2f), angle, false, true, _p6); _graphicsPath.AddLineTo(_p5); _graphicsPath.AddArcTo(r1 - (width / 2f), r2 - (width / 2f), angle, false, false, _p3); _graphicsPath.AddLineTo(_p4); this._graphics.FillPath(_graphicsPath); //------- this._graphics.GetThickLine(p5, p6, width, ref _p1, ref _p2, ref _p3, ref _p4); _graphicsPath.Reset(); _graphicsPath.AddMoveTo(_p8); _graphicsPath.AddArcTo(r1 + (width / 2f), r2 + (width / 2f), angle, false, true, _p2); _graphicsPath.AddLineTo(_p1); _graphicsPath.AddArcTo(r1 - (width / 2f), r2 - (width / 2f), angle, false, false, _p7); _graphicsPath.AddLineTo(_p8); this._graphics.FillPath(_graphicsPath); //---------- this._graphics.GetThickLine(p7, p8, width, ref _p5, ref _p6, ref _p7, ref _p8); _graphicsPath.Reset(); _graphicsPath.AddMoveTo(_p4); _graphicsPath.AddArcTo(r1 + (width / 2f), r2 + (width / 2f), angle, false, true, _p6); _graphicsPath.AddLineTo(_p5); _graphicsPath.AddArcTo(r1 - (width / 2f), r2 - (width / 2f), angle, false, false, _p3); _graphicsPath.AddLineTo(_p4); this._graphics.FillPath(_graphicsPath); //------- this._graphics.GetThickLine(p1, p2, width, ref _p1, ref _p2, ref _p3, ref _p4); _graphicsPath.Reset(); _graphicsPath.AddMoveTo(_p8); _graphicsPath.AddArcTo(r1 + (width / 2f), r2 + (width / 2f), angle, false, true, _p2); _graphicsPath.AddLineTo(_p1); _graphicsPath.AddArcTo(r1 - (width / 2f), r2 - (width / 2f), angle, false, false, _p7); _graphicsPath.AddLineTo(_p8); this._graphics.FillPath(_graphicsPath); }
public void RoundedRect(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 p5, Vector2 p6, Vector2 p7, Vector2 p8, float r1, float r2, float angle, float width) { if((int)width == 1) { RoundedRect(p1, p2, p3, p4, p5, p6, p7, p8, r1, r2, angle); return; } Line(p1, p2, width); Line(p3, p4, width); Line(p5, p6, width); Line(p7, p8, width); // TODO: IIRC, `Vector2.zero` is a p/invoke. Would it be safe to chain assignments here? Would it be more // TODO: performant? What about just calling `new Vector2(0f, 0f)`? Vector2 _p1 = Vector2.zero; Vector2 _p2 = Vector2.zero; Vector2 _p3 = Vector2.zero; Vector2 _p4 = Vector2.zero; _graphics.GetThickLine(p1, p2, width, ref _p1, ref _p2, ref _p3, ref _p4); Vector2 _p5 = Vector2.zero; Vector2 _p6 = Vector2.zero; Vector2 _p7 = Vector2.zero; Vector2 _p8 = Vector2.zero; //------- _graphics.GetThickLine(p3, p4, width, ref _p5, ref _p6, ref _p7, ref _p8); SVGGraphicsPath _graphicsPath = new SVGGraphicsPath(); _graphicsPath.AddMoveTo(_p4); _graphicsPath.AddArcTo(r1 + (width / 2f), r2 + (width / 2f), angle, false, true, _p6); _graphicsPath.AddLineTo(_p5); _graphicsPath.AddArcTo(r1 - (width / 2f), r2 - (width / 2f), angle, false, false, _p3); _graphicsPath.AddLineTo(_p4); _graphics.FillPath(_graphicsPath); //------- _graphics.GetThickLine(p5, p6, width, ref _p1, ref _p2, ref _p3, ref _p4); _graphicsPath.Reset(); _graphicsPath.AddMoveTo(_p8); _graphicsPath.AddArcTo(r1 + (width / 2f), r2 + (width / 2f), angle, false, true, _p2); _graphicsPath.AddLineTo(_p1); _graphicsPath.AddArcTo(r1 - (width / 2f), r2 - (width / 2f), angle, false, false, _p7); _graphicsPath.AddLineTo(_p8); _graphics.FillPath(_graphicsPath); //---------- _graphics.GetThickLine(p7, p8, width, ref _p5, ref _p6, ref _p7, ref _p8); _graphicsPath.Reset(); _graphicsPath.AddMoveTo(_p4); _graphicsPath.AddArcTo(r1 + (width / 2f), r2 + (width / 2f), angle, false, true, _p6); _graphicsPath.AddLineTo(_p5); _graphicsPath.AddArcTo(r1 - (width / 2f), r2 - (width / 2f), angle, false, false, _p3); _graphicsPath.AddLineTo(_p4); _graphics.FillPath(_graphicsPath); //------- _graphics.GetThickLine(p1, p2, width, ref _p1, ref _p2, ref _p3, ref _p4); _graphicsPath.Reset(); _graphicsPath.AddMoveTo(_p8); _graphicsPath.AddArcTo(r1 + (width / 2f), r2 + (width / 2f), angle, false, true, _p2); _graphicsPath.AddLineTo(_p1); _graphicsPath.AddArcTo(r1 - (width / 2f), r2 - (width / 2f), angle, false, false, _p7); _graphicsPath.AddLineTo(_p8); _graphics.FillPath(_graphicsPath); }