public GraphicsPath Add_Estribos(double EscalaX, double EscalaY, float rec, float Dx, float Dy) { GraphicsPath path = new GraphicsPath(); CCirculo circulo1, circulo2; double r1 = (radio - rec) * 100; double r2 = (r1 + FunctionsProject.Find_Diametro(Estribo.NoEstribo)); double[] pCentro = new double[] { Centro[0] + Dx, Centro[1] + Dy }; MAT_CONCRETE material = new MAT_CONCRETE { FC = 4220, Name = "FY4220" }; circulo1 = new CCirculo("Refuerzo", r1, pCentro, material, TipodeSeccion.Circle, pCoord: null); circulo1.Set_puntos(50, r1 * EscalaX); circulo2 = new CCirculo("Refuerzo", r2, pCentro, material, TipodeSeccion.Circle, pCoord: null); circulo2.Set_puntos(50, r2 * EscalaX); path.AddClosedCurve(circulo1.Puntos.ToArray()); path.AddClosedCurve(circulo2.Puntos.ToArray()); return(path); }
public void ReadVirtualCoilsSetting(string filepath, PublicVariate publicVariate) { StreamReader sr = new StreamReader(filepath, Encoding.UTF8); _ = sr.ReadLine(); string line; while ((line = sr.ReadLine()) != null) { string[] lines = line.Split(PublicVariate.Separator); PublicVariate.VirtualCoil virtualCoil = new PublicVariate.VirtualCoil { CrossName = lines[0], LaneID = lines[1], LaneType = lines[2], Approach = lines[3] }; if (lines.Length < 10 | (lines.Length - 4) / 2 != 0) { string message = string.Format("不能形成成闭合区域!\r\n{0}", line); MessageBox.Show(message, "系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); return; } GraphicsPath myGraphicsPath = new GraphicsPath(); PointF[] pointF = new PointF[2]; for (int i = 4; i < lines.Length; i += 2) { pointF[i] = new PointF(float.Parse(lines[i]), float.Parse(lines[i + 1])); } myGraphicsPath.AddClosedCurve(pointF, 1); publicVariate.VirtualCoils.Add(virtualCoil); } }
/// <summary> /// See <see cref="GraphicsPath.AddClosedCurve(PointF[])">GraphicsPath.AddClosedCurve</see>. /// </summary> public virtual void AddClosedCurve(PointF[] points) { path.AddClosedCurve(points); FirePropertyChangedEvent(PROPERTY_KEY_PATH, PROPERTY_CODE_PATH, null, path); UpdateBoundsFromPath(); InvalidatePaint(); }
//return the lens GraphicsPath public override GraphicsPath GetPath() { GraphicsPath path = new GraphicsPath(); path.AddClosedCurve(this.GetPoints()); return(path); }
public void FillBeizer(Graphics gr, Rectangle re, int stroke, Color incolor, Color basecolor) { Rectangle _re = new Rectangle(stroke, stroke, re.Width - 2 * stroke - regionoffset, re.Height - 2 * stroke - regionoffset); GraphicsPath path = new GraphicsPath(); Point[] points = new Point[4]; points[0] = new Point(re.Width / 2, 1); points[1] = new Point(2, re.Height / 2); points[2] = new Point(re.Width / 2, (int)(re.Height / 2 * 0.9)); points[3] = new Point(re.Width - 2, re.Height / 2); path.AddClosedCurve(points, 1.16F); PathGradientBrush brush = new PathGradientBrush(path); brush.CenterPoint = new PointF(this.Width / 2, this.Height); float[] pos = new float[4]; pos[0] = 0.0F; pos[1] = 0.018F; pos[2] = 0.15F; pos[3] = 1.0F; Color[] colors = new Color[4]; colors[0] = Color.FromArgb(10, incolor); colors[1] = Color.FromArgb(200, incolor); colors[2] = Color.FromArgb(30, incolor); colors[3] = Color.FromArgb(10, incolor); ColorBlend mix = new ColorBlend(); mix.Colors = colors; mix.Positions = pos; brush.InterpolationColors = mix; gr.CompositingQuality = CompositingQuality.HighQuality; gr.FillPath(brush, path); brush.Dispose(); }
private void Test_A() { List <Point> points = new List <Point>(); points.Add(new Point(50, 50)); points.Add(new Point(60, 65)); points.Add(new Point(40, 70)); points.Add(new Point(50, 90)); points.Add(new Point(30, 95)); points.Add(new Point(20, 60)); points.Add(new Point(40, 55)); _TestPoly = points; using (GraphicsPath gp = new GraphicsPath()) { gp.AddClosedCurve(points.ToArray()); //panel1.Region = new Region(gp); } //int minX = points.Select(x => x.X).Min(); //int minY = points.Select(x => x.Y).Min(); //panel1.Location = new Point(minX, minY); //toolTip.SetToolTip(panel1, "Working?"); }
/// <summary> /// See <see cref="GraphicsPath.AddClosedCurve">GraphicsPath.AddClosedCurve</see>. /// </summary> public virtual void AddClosedCurve(PointF[] points) { path.AddClosedCurve(points); UpdateBoundsFromPath(); InvalidatePaint(); InvalidateVertices(); }
private void Type(Control sender, int p_1, double p_2) { GraphicsPath oPath = new GraphicsPath(); oPath.AddClosedCurve(new Point[] { new Point(0, sender.Height / p_1), new Point(sender.Width / p_1, 0), new Point(sender.Width - sender.Width / p_1, 0), new Point(sender.Width, sender.Height / p_1), new Point(sender.Width, sender.Height - sender.Height / p_1), new Point(sender.Width - sender.Width / p_1, sender.Height), new Point(sender.Width / p_1, sender.Height), new Point(0, sender.Height - sender.Height / p_1) }, (float)p_2); sender.Region = new Region(oPath); }
/// <summary> /// Performs a hit test on the <see cref="Graphic"/> at a given point. /// </summary> /// <param name="point">The mouse position in destination coordinates.</param> /// <returns> /// <b>True</b> if <paramref name="point"/> "hits" the <see cref="Graphic"/>, /// <b>false</b> otherwise. /// </returns> public override bool HitTest(Point point) { base.CoordinateSystem = CoordinateSystem.Destination; try { using (var gp = new GraphicsPath()) using (var pen = new Pen(Color.Black, HitTestDistance)) { PointF[] pathPoints = GetCurvePoints(_points); if (_points.IsClosed) { gp.AddClosedCurve(pathPoints); } else { gp.AddCurve(pathPoints); } return(gp.IsOutlineVisible(point, pen)); } } finally { base.ResetCoordinateSystem(); } }
public void Dibujo_SeccionVecina(Graphics g, double EscalaX, double EscalaY, float Dx, float Dy) { SolidBrush br = new SolidBrush(Color.FromArgb(150, Color.Gray)); Pen P1; List <PointF> pPuntos = new List <PointF>(); Seccion_path = new GraphicsPath(); P1 = new Pen(Color.Black, 3f) { Brush = Brushes.DarkGray, Color = Color.DarkBlue, DashStyle = DashStyle.Dash, LineJoin = LineJoin.Round, Alignment = PenAlignment.Center }; Set_puntos(50, radio * 100 * EscalaX); PointF pi = new PointF(); foreach (PointF punto in Puntos) { pi.X = Convert.ToSingle(punto.X) + Dx; pi.Y = Convert.ToSingle(punto.Y) + Dy; pPuntos.Add(pi); } g.DrawClosedCurve(P1, pPuntos.ToArray()); g.FillClosedCurve(br, pPuntos.ToArray()); Seccion_path.AddClosedCurve(pPuntos.ToArray()); }
public override void PreDraw(PhysicsObject obj, Graphics g) { //Reset Matrix Matrix.Reset(); //Apply Matrix Path.Reset(); // calculate stretch and rotation var stretchFactor = Math.Max(1, obj.Velocity.Length / 50); Rotation = ((float)Math.Atan2(obj.Velocity.Y, obj.Velocity.X)).RadiansToDegrees(); // Transform identity mtx to position Matrix.Translate(obj.Center.X, obj.Center.Y); Matrix.Rotate((float)Rotation); Matrix.Scale(stretchFactor, 1); //Apply mtx to path Path.AddClosedCurve(Points); Path.Transform(Matrix); //Draw Path if (obj.LastCollision == null) { g.FillPath(BrushLightBlue, Path); } else { g.FillPath(BrushBlue, Path); } }
public override bool HitTest(Control owner, int x, int y) { Form page = (Form)owner; x -= page.AutoScrollPosition.X; y -= page.AutoScrollPosition.Y; if (pts != null && pts.Length > 2) { GraphicsPath areaPath; Pen areaPen; Region areaRegion; // Create path which contains ClosedCurve areaPath = new GraphicsPath(); areaPath.AddClosedCurve(pts, tension); if (!fill) { areaPen = new Pen(Color.Black, width); areaPath.Widen(areaPen); } // Create region from the path areaRegion = new Region(areaPath); return(areaRegion.IsVisible(new Point(x, y))); } return(false); }
static private GraphicsPath ClosedCurve() { GraphicsPath path = new GraphicsPath(); path.AddClosedCurve(new Point[4] { new Point(20, 100), new Point(70, 10), new Point(130, 200), new Point(180, 100) }); return(path); }
/// <summary> /// /// </summary> /// <param name="pts"></param> /// <returns></returns> protected override System.Drawing.Drawing2D.GraphicsPath CreateGraphicsPath(PointF[] pts) { GraphicsPath grfxPath = null; if (pts.Length > 0) { grfxPath = new GraphicsPath(); grfxPath.AddClosedCurve(pts); } return(grfxPath); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); //自定义绘制过程 //获取画布 g = e.Graphics; //设置画布 SetGraphics(); //绘制过程 using (LinearGradientBrush brush = new LinearGradientBrush(new PointF(0, 0), new PointF(0, this.headHeight), this.headBackColor1, this.headBackColor2)) { g.FillRectangle(brush, new RectangleF(0, 0, this.Width, this.headHeight)); } //绘制标题名称 StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; using (SolidBrush sb = new SolidBrush(this.headForeColor)) { g.DrawString(this.headText, this.Font, sb, new RectangleF(0, 0, this.Width, this.headHeight), sf); } ////绘制边框 //using (Pen p = new Pen(this.headBackColor1)) //{ // g.DrawRectangle(p, 0, 0, this.Width - 1, this.Height - 1); //} //绘制圆角 GraphicsPath oPath = new GraphicsPath(); oPath.AddClosedCurve( new Point[] { new Point(0, this.Height / 20), new Point(this.Width / 20, 0), new Point(this.Width - this.Width / 20, 0), new Point(this.Width, this.Height / 20), new Point(this.Width, this.Height - this.Height / 20), new Point(this.Width - this.Width / 20, this.Height), new Point(this.Width / 20, this.Height), new Point(0, this.Height - this.Height / 20) }, (float)0.1); this.Region = new Region(oPath); }
private GraphicsPath InternalGetPath(PointD2D offset) { var gp = new GraphicsPath(); var pt = new PointF[_curvePoints.Count]; for (int i = 0; i < _curvePoints.Count; i++) { pt[i] = new PointF((float)(_curvePoints[i].X + offset.X), (float)(_curvePoints[i].Y + offset.Y)); } gp.AddClosedCurve(pt, (float)_tension); return(gp); }
private void AddFilledCupHandle(GraphicsPath graphicsPath) { PointF[] points = new PointF[] { new PointF(175, 295), new PointF(171, 278), new PointF(140, 283), new PointF(170, 290), new PointF(128, 323), }; graphicsPath.AddClosedCurve(points, 1); }
public void Start() { _pen = new Pen(Color, PenWidth); _path = new GraphicsPath(); if (Polygon) { _path.AddPolygon(_points); } else { _path.AddClosedCurve(_points); } }
protected override void UpdatePath() { if (this.Points == null || this.Points.Length == 0) { return; } InternalPath = new GraphicsPath(); InternalPath.AddClosedCurve(this.Points); Matrix mtx = new Matrix(); mtx.RotateAt(this.Rotation, InternalRotationBasePoint); InternalPath.Transform(mtx); }
public void Draw(Graphics gr) { var angle = Math.PI * _angle / 180; var scale = (float)(1 + Math.Sin(5 * angle) / 5); try { gr.TranslateTransform(_xCenter, _yCenter); gr.RotateTransform(_angle); gr.ScaleTransform(scale, scale); using (var path = new GraphicsPath()) { if (Polygon) { path.AddPolygon(_points); } else { if (_closedCurve) { path.AddClosedCurve(_points); } else { path.AddCurve(_points); } } if (Fill) { using (var brush = new SolidBrush(_brushColor)) gr.FillPath(brush, path); } else { using (var pen = new Pen(PenColor, PenWidth)) gr.DrawPath(pen, path); } } } finally { gr.ScaleTransform(1f / scale, 1f / scale); gr.RotateTransform(-_angle); gr.TranslateTransform(-_xCenter, -_yCenter); } }
void CreateGround() { ground = new GraphicsPath(); float[] X = { 0, 0, (float)(Width * 0.2), (float)(Width * 0.45), (float)(Width * 0.58), (float)(Width * 0.79), (float)(Width * 0.95), Width, Width }; float[] Y = { Height, Height *(float)0.75, Height *(float)0.95, Height *(float)0.85, Height *(float)0.9, Height - 10, Height *(float)0.9, Height *(float)0.75, Height }; PointF[] curvePoints = new PointF[Y.Length]; for (int i = 0; i < curvePoints.Length; i++) { PointF point = new PointF(X[i], Y[i]); curvePoints[i] = point; } ground.AddClosedCurve(curvePoints); ground.CloseAllFigures(); }
private void SetWindowRegion(Control sender, int length, float tension) { GraphicsPath path = new GraphicsPath(); path.AddClosedCurve(new Point[] { new Point(0, sender.Height / length), new Point(sender.Width / length, 0), new Point(sender.Width - sender.Width / length, 0), new Point(sender.Width, sender.Height / length), new Point(sender.Width, sender.Height - sender.Height / length), new Point(sender.Width - sender.Width / length, sender.Height), new Point(sender.Width / length, sender.Height), new Point(0, sender.Height - sender.Height / length) }, tension); sender.Region = new Region(path); }
private void DefinirZone() { GraphicsPath Dessin = new GraphicsPath(); Point[] Pts = new Point[] { new Point(0, 0), new Point(0, Size.Height), new Point(Size.Width / 4, 4 * Size.Height / 5), new Point(Size.Width / 2, Size.Height), new Point(3 * Size.Width / 4, 4 * Size.Height / 5), new Point(Size.Width, Size.Height), new Point(Size.Width, 0) }; Dessin.AddClosedCurve(Pts); Region = new Region(Dessin); //Défini ce qui est affiché }
private void DefinirZone() { GraphicsPath dessin = new GraphicsPath(); Point[] points = new Point[] // On définit les points du masque { new Point(0, 0), new Point(0, Size.Height), new Point(Size.Width / 4, 4 * Size.Height / 5), new Point(Size.Width / 2, Size.Height), new Point(3 * Size.Width / 4, 4 * Size.Height / 5), new Point(Size.Width, Size.Height), new Point(Size.Width, 0) }; dessin.AddClosedCurve(points); // On dessine le contour du masque Region = new Region(dessin); }
public void Dibujo_Seccion(Graphics g, double EscalaX, double EscalaY, bool seleccion, float Dx, float Dy) { SolidBrush br = new SolidBrush(Color.FromArgb(150, Color.Gray)); Pen P1; List <PointF> pPuntos = new List <PointF>(); Seccion_path = new GraphicsPath(); if (seleccion == false) { P1 = new Pen(Color.Black, 2.5f) { Brush = Brushes.Gray, Color = Color.Black, DashStyle = DashStyle.Solid, LineJoin = LineJoin.MiterClipped, Alignment = System.Drawing.Drawing2D.PenAlignment.Center }; } else { P1 = new Pen(Color.Black, 3f) { Brush = Brushes.DarkRed, Color = Color.DarkRed, DashStyle = DashStyle.Dash, LineJoin = LineJoin.Round, Alignment = PenAlignment.Center }; } Set_puntos(50, radio * 100 * EscalaX); PointF pi = new PointF(); foreach (PointF punto in Puntos) { pi.X = Convert.ToSingle(punto.X) + Dx; pi.Y = Convert.ToSingle(punto.Y) + Dy; pPuntos.Add(pi); } g.DrawClosedCurve(P1, pPuntos.ToArray()); g.FillClosedCurve(br, pPuntos.ToArray()); Seccion_path.AddClosedCurve(pPuntos.ToArray()); }
private void DefinirZone() { GraphicsPath dessin = new GraphicsPath(); Point[] points = new Point[] { new Point(0, 0), new Point(0, Size.Height), new Point(Size.Width / 4, 4 * Size.Height / 5), new Point(Size.Width / 2, Size.Height), new Point(3 * Size.Width / 4, 4 * Size.Height / 5), new Point(Size.Width, Size.Height), new Point(Size.Width, 0) }; dessin.AddClosedCurve(points); dessin.CloseAllFigures(); Region = new Region(dessin); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); //自定义绘制过程 //获取画布 g = e.Graphics; //设置画布 SetGraphics(); //绘制过程 //绘制圆角 GraphicsPath oPath = new GraphicsPath(); oPath.AddClosedCurve( new Point[] { new Point(0, this.Height / 20), new Point(this.Width / 20, 0), new Point(this.Width - this.Width / 20, 0), new Point(this.Width, this.Height / 20), new Point(this.Width, this.Height - this.Height / 20), new Point(this.Width - this.Width / 20, this.Height), new Point(this.Width / 20, this.Height), new Point(0, this.Height - this.Height / 20) }, (float)0.1); this.Region = new Region(oPath); //绘制名称 StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; using (SolidBrush sb = new SolidBrush(this.headForeColor)) { g.DrawString(this.textX, this.Font, sb, new RectangleF(0, 0, this.Width, this.Height), sf); } }
public void Add_Ref_graph(double EscalaX, double EscalaY, double EscalaR, float Dx, float Dy) { GraphicsPath path; double r = 0; double[] pcentro; double xc, yc; CCirculo circulo; if (Shapes_ref != null) { Shapes_ref.Clear(); } else { Shapes_ref = new List <GraphicsPath>(); } foreach (CRefuerzo refuerzoi in Refuerzos) { path = new GraphicsPath(); r = FunctionsProject.Find_Diametro(Convert.ToInt32(refuerzoi.Diametro.Substring(1))) / 2; r = r * EscalaR; xc = Dx + refuerzoi.Coord[0] * EscalaX; yc = Dy - refuerzoi.Coord[1] * EscalaY; pcentro = new double[] { xc, yc }; MAT_CONCRETE material = new MAT_CONCRETE { FC = 4220, Name = "FY4220" }; circulo = new CCirculo("Refuerzo", r, pcentro, material, TipodeSeccion.Circle, pCoord: null); circulo.Set_puntos(10, r); path.AddClosedCurve(circulo.Puntos.ToArray()); Shapes_ref.Add(path); } }
/// <inheritdoc/> public override void FillOneRange( GraphicsPath gp, Processed2DPlotData pdata, IPlotRange range, IPlotArea layer, CSPlaneID fillDirection, bool ignoreMissingDataPoints, bool connectCircular, PointF[] allLinePointsShiftedAlready, double logicalShiftX, double logicalShiftY ) { var subLinePoints = new PointF[range.Length]; Array.Copy(allLinePointsShiftedAlready, range.LowerBound, subLinePoints, 0, range.Length); // Extract if (connectCircular) { gp.AddClosedCurve(subLinePoints); gp.CloseFigure(); } else { Logical3D r0 = layer.GetLogical3D(pdata, range.OriginalFirstPoint); r0.RX += logicalShiftX; r0.RY += logicalShiftY; layer.CoordinateSystem.GetIsolineFromPlaneToPoint(gp, fillDirection, r0); gp.AddCurve(subLinePoints); Logical3D r1 = layer.GetLogical3D(pdata, range.OriginalLastPoint); r1.RX += logicalShiftX; r1.RY += logicalShiftY; layer.CoordinateSystem.GetIsolineFromPointToPlane(gp, r1, fillDirection); layer.CoordinateSystem.GetIsolineOnPlane(gp, fillDirection, r1, r0); gp.CloseFigure(); } }
public Sailer(ContentManager m, float X, float Y) : base(m) { boat = new Vector(X, Y); this.m = m; m.KeyDown += onKeyDown; boatPath = new GraphicsPath(); boatPath.AddClosedCurve(new PointF[] { new PointF(-backIndent, -backWidth), new PointF(-backBulgeIndent, -hWidth), new PointF(0, -frontBulgeIndent), new PointF(fronIndent, 0), new PointF(0, frontBulgeIndent), new PointF(-backBulgeIndent, hWidth), new PointF(-backIndent, backWidth), new PointF(-backBulge, 0) }); sailPath = new GraphicsPath(); sailPath.AddClosedCurve(new PointF[] { new PointF(0, 0), new PointF(sailWidth * 0.75f, sailLength * 0.15f), new PointF(sailWidth, sailLength / 2), new PointF(sailWidth * 0.75f, sailLength * 0.85f), new PointF(0, sailLength) }); arrowPath = new GraphicsPath(); arrowPath.AddLines(new PointF[] { new PointF(-4 * arrowSize, 0), new PointF(4 * arrowSize, 0), new PointF(2 * arrowSize, -arrowSize), new PointF(4 * arrowSize, 0), new PointF(2 * arrowSize, arrowSize), new PointF(4 * arrowSize, 0) }); boatDirection = new Vector(0, -1); boatDirection.calcAngle(); prevBoatDirection = boatDirection.angle; Random r = new Random(); wind.length = 1; wind.angle = r.NextDouble() * 2 * Math.PI; sail = new Vector(1, 0); rudder = new Vector(-rudderLength, 0); rudder.calcLength(); rudder.calcAngle(); }