public void DrawPath(Graphics g, Pen p) { if (m_points != null) { g.DrawLines(p, m_points); } }
private void button1_Click(object sender, EventArgs e) { //HERMITE'A pictureBox1.Refresh(); PointF P1 = new PointF(100, 100); PointF P4 = new PointF(300, 100); PointF R1 = new PointF(100, 100); PointF R4 = new PointF(100, 100); int amount = 100; float dt = (float)1 / (float)amount; PointF[] points = new PointF[amount]; float t = 0; for (int i = 0; i < amount; i++) { points[i].X = ((2 * t * t * t) - (3 * t * t) + 1) * P1.X + ((-2 * t * t * t) + (3 * t * t)) * P4.X + ((t * t * t) - (2 * t * t) + t) * R1.X + ((t * t * t) - (t * t)) * R4.X; points[i].Y = ((2 * t * t * t) - (3 * t * t) + 1) * P1.Y + ((-2 * t * t * t) + (3 * t * t)) * P4.Y + ((t * t * t) - (2 * t * t) + t) * R1.Y + ((t * t * t) - (t * t)) * R4.Y; t += dt; } g.DrawLines(pen, points); g.DrawLine(pen1, P1.X, P1.Y, P1.X + R1.X, P1.Y + R1.Y); g.DrawLine(pen1, P4.X, P4.Y, P4.X + R4.X, P4.Y + R4.Y); }
public static void Frame3D(Graphics graphics, Rectangle rc, Color topColor, Color bottomColor, int width) { if(graphics == null) throw new ArgumentNullException("graphics"); Pen pen = new Pen(topColor, 1); pen.Width = 1; while(width > 0) { width--; pen.Color = topColor; Point[] top_pnts = { new Point(rc.Left, rc.Bottom), new Point(rc.Left, rc.Top), new Point(rc.Right, rc.Top) }; graphics.DrawLines(pen, top_pnts); pen.Color = bottomColor; Point[] bottom_pnts = { new Point(rc.Right, rc.Top), new Point(rc.Right, rc.Bottom), new Point(rc.Left, rc.Bottom) }; graphics.DrawLines(pen, bottom_pnts); rc.Inflate(-1, -1); } pen.Dispose(); }
public override void Draw(System.Drawing.Graphics g) { g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; //phải xét lại để trong quá trình MouseMove int width = Math.Abs(endPoint.X - startPoint.X); int height = Math.Abs(endPoint.Y - startPoint.Y); int spX = Math.Min(startPoint.X, endPoint.X); int spY = Math.Min(startPoint.Y, endPoint.Y); //mRec = new Rectangle(spX, spY, Math.Min(width, height),Math.Max(width, height)); mRec = new Rectangle(spX, spY, width, height); List <Point> l = getPointParabola(true); //right if (l.Count > 0) { g.DrawLines(p, l.ToArray()); } l.Clear(); l = getPointParabola(false); //left if (l.Count > 0) { g.DrawLines(p, l.ToArray()); } //show control point if (this.isSelect) { this.getListControlPoint(); this.showControlPoint(g); } }
private void DrawHouse(Graphics g, int mouseX, int mouseY) { Point topLeft = new Point(mouseX, mouseY); Point topRight = new Point(mouseX + size, mouseY); Point bottomLeft = new Point(mouseX, mouseY + size); Point bottomRight = new Point(mouseX + size, mouseY + size); Point top = new Point(mouseX + (size / 2), mouseY - (int)(size * 0.5)); Point doorBottomLeft = new Point(bottomLeft.X + (int)(size * 0.2), bottomLeft.Y); Point doorBottomRight = new Point(bottomLeft.X + (int)(size * 0.5), bottomLeft.Y); Point doorTopLeft = new Point(doorBottomLeft.X, doorBottomLeft.Y - (int)(size * 0.6)); Point doorTopRight = new Point(doorBottomRight.X, doorBottomRight.Y - (int)(size * 0.6)); Point window1TopLeft = new Point(doorTopLeft.X, bottomLeft.Y - (int)(size * 0.9)); Point window2TopLeft = new Point(bottomLeft.X + (int)(size * 0.6), window1TopLeft.Y); Point sunOrigin = new Point(topRight.X + (int)(size * 0.3), topRight.Y - (int)(size * 0.5)); Size windowSize = new Size((int)(size * 0.3), (int)(size * 0.2)); Size sunSize = new Size((int)(size * 0.4), (int)(size * 0.4)); Rectangle window1 = new Rectangle(window1TopLeft, windowSize); Rectangle window2 = new Rectangle(window2TopLeft, windowSize); Rectangle sun = new Rectangle(sunOrigin, sunSize); Point[] square = new Point[] { topLeft, topRight, bottomRight, bottomLeft, topLeft, top, topRight }; Point[] door = new Point[] { doorBottomLeft, doorTopLeft, doorTopRight, doorBottomRight }; g.DrawLines(myPen, square); g.DrawLines(myPen, door); g.DrawRectangle(myPen, window1); g.DrawRectangle(myPen, window2); g.FillRectangle(myBrush, window1); g.FillRectangle(myBrush, window2); g.DrawEllipse(myPen, sun); g.FillEllipse(yellow, sun); }
private void drow_edge_lines(System.Drawing.Graphics g, Pen _p, Point[] lines) { Pen black_pen = new Pen(Color.Black, _p.Width + 2); // lineを描画 g.DrawLines(black_pen, lines); g.DrawLines(_p, lines); }
public void Draw(Graphics graphics, int width, int height) { const int pixelsPerSample = 2; var samplesLeft = GetSamplesToDraw(_left, width / pixelsPerSample).ToArray(); var samplesRight = GetSamplesToDraw(_right, width / pixelsPerSample).ToArray(); //left channel: graphics.DrawLines(new Pen(Color.DeepSkyBlue, 1), GetPoints(samplesLeft, pixelsPerSample, width, height).ToArray()); //right channel: graphics.DrawLines(new Pen(Color.FromArgb(150, Color.Red), 0.5f), GetPoints(samplesRight, pixelsPerSample, width, height).ToArray()); }
/// <summary> /// Draw self, including pathing line when tracking the Hero /// </summary> /// <param name="g"></param> public override void DrawSelf( Graphics g ) { if( pathToHero.Count >= 2 ) g.DrawLines( Pens.Green, (PointF[])(pathToHero.ToArray( typeof( PointF ) )) ); base.DrawSelf( g ); }
public void Draw(Graphics graphics) { Point[] allPoints = GetDrawPoints(); Pen pen = new Pen(lineColour, lineThickness); graphics.DrawLines(pen, allPoints); }
private void DrawCell(Graphics g, byte[,] cells, int row, int column, Rectangle bounds) { Rectangle area = new Rectangle(bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1); g.DrawLines(Pens.LightGray, new Point[] { new Point(area.Left, area.Bottom), new Point(area.Right, area.Bottom), new Point(area.Right, area.Top)}); if (currentCell.X == column && currentCell.Y == row) { g.FillRectangle(Brushes.Silver, bounds); } if (selectedCell.X == column && selectedCell.Y == row) { g.DrawRectangle(Pens.Black, area); } if (breakpoints.ContainsKey(new Point(column, row))) { g.FillEllipse(Brushes.Red, area); } char ch = (char)cells[row, column]; g.DrawString(ch.ToString(), baseFont, Brushes.Black, bounds.X + CellPadding, bounds.Y + CellPadding); }
public override void Nacrtaj(System.Drawing.Graphics g) { using (Pen pero = new Pen(Color.Green)) { g.DrawLines(pero, new PointF[] { new PointF(x1, y1), new PointF(x2, y2), new PointF(x3, y3) } ); } }
internal static void Transform(drawing.Graphics graphics, Geometry original, sb.Point location, drawing.Pen pen, drawing.Brush brush) { var geometry = original.GetFlattenedPathGeometry(); foreach (var figure in geometry.Figures) { Point firstLocalPoint = ((PolyLineSegment)figure.Segments[0]).Points[0]; var firstPoint = new System.Drawing.PointF((float)(firstLocalPoint.X + location.X), (float)(firstLocalPoint.Y + location.Y)); foreach (var segment in figure.Segments) { if (segment is PolyLineSegment) { var points = ((PolyLineSegment)segment).Points.Select(i => new System.Drawing.PointF((float)(i.X + location.X), (float)(i.Y + location.Y))).ToList(); points.Add(firstPoint); graphics.DrawLines(pen, points.ToArray()); } else if (segment is LineSegment) { var x2 = (float)(((LineSegment)segment).Point.X + location.X); var y2 = (float)(((LineSegment)segment).Point.Y + location.Y); graphics.DrawLine(pen, firstPoint.X, firstPoint.Y, x2, y2); } else { throw new NotImplementedException(); } } } }
public void Refresh() { CanvasRoot.Children.Clear(); if (dlx == 0 || dly == 0) { return; } if (ChartDataSeries.Any()) { var points = new List <PointF>(); ChartDataSeries.ToList().ForEach( p => { points.Add(Normalize(p)); } ); if (points.Count() <= 1) { return; } WriteableBitmap bitmap = new WriteableBitmap ( (int)this.RenderSize.Width, (int)this.RenderSize.Height, 96, 96, PixelFormats.Bgra32, null ); Image figure = new Image { Source = bitmap }; bitmap.Lock(); using (System.Drawing.Bitmap buff = new System.Drawing.Bitmap( (int)bitmap.Width, (int)bitmap.Height, bitmap.BackBufferStride, System.Drawing.Imaging.PixelFormat.Format32bppArgb, bitmap.BackBuffer)) { // GDI+ Drawing using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(buff)) { Color color = (Foreground as SolidColorBrush).Color; var brush = System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B); var pen = new System.Drawing.Pen(brush, 1); //1 is minimum, bigger thickness could effect performance graphics.DrawLines(pen, points.ToArray()); graphics.Flush(); } } bitmap.AddDirtyRect(new Int32Rect(0, 0, (int)bitmap.Width, (int)bitmap.Height)); bitmap.Unlock(); CanvasRoot.Children.Add(figure); } }
private void button4_Click(object sender, EventArgs e) { //przynależność do wielokąta pictureBox1.Refresh(); punkty = new PointF[4]; PointF xy = new PointF(150, 225); punkty[0].X = 100; punkty[0].Y = 100; punkty[1].X = 300; punkty[1].Y = 100; punkty[2].X = 100; punkty[2].Y = 300; punkty[3].X = 100; punkty[3].Y = 100; g.DrawLines(pen1, punkty); g.DrawEllipse(pen, xy.X, xy.Y, 5, 5); if (czyWSrodku(punkty, xy) == 1) { MessageBox.Show("W srodku"); } else { MessageBox.Show("Na zewnatrz"); } }
public override void DrawSelf(Graphics gfx, Pen pen) { base.DrawSelf(gfx, pen); PointF a = new PointF(Center.X + Width / 2, Center.Y); PointF b = new PointF(Center.X - Width / 2, Center.Y + Height / 2); PointF c = new PointF(Center.X - Width / 2, Center.Y - Height / 2); PointF a1 = Calc.RotatePoint(Center, a, Angle); PointF b1 = Calc.RotatePoint(Center, b, Angle); PointF c1 = Calc.RotatePoint(Center, c, Angle); gfx.DrawLines(pen, new PointF[4] { a1, b1, c1, a1 }); if (!Dummy) { Pen penn = new Pen(Color.Gainsboro, 1); gfx.DrawEllipse(penn, Center.X - Range, Center.Y - Range, Range * 2, Range * 2); } if (Dummy) { gfx.DrawString((1000 / FireDelayMilis * TeslaBullet.DamageDefault).ToString(), new Font("Arial", 7), Brushes.Black, Center.X - (Width / 2), Center.Y - 15); } }
public override void Draw(Graphics g) { if (this.lineComponent.IsSelected) { g.DrawLine(ViewFactory.BoundingBoxPen, this.lineComponent.StartPoint.X, this.lineComponent.StartPoint.Y, this.lineComponent.ControlPoint1.X, this.lineComponent.ControlPoint1.Y); g.DrawLine(ViewFactory.BoundingBoxPen, this.lineComponent.EndPoint.X, this.lineComponent.EndPoint.Y, this.lineComponent.ControlPoint2.X, this.lineComponent.ControlPoint2.Y); } if (this.lineComponent.ParentMoving) { g.DrawBezier(ViewFactory.LinePen, this.lineComponent.StartPoint.MakePointF(), this.lineComponent.ControlPoint1.MakePointF(), this.lineComponent.ControlPoint2.MakePointF(), this.lineComponent.EndPoint.MakePointF()); } else { g.DrawLines(ViewFactory.LinePen, this.lineComponent.points.ToArray()); /*DrawPoint(g, new FlowChartPoint(points[points.Count/2].X,points[points.Count/2].Y), GraphicsSettings.LabelPen, GraphicsSettings.EdgeBoxWidth);*/ } DrawArrow(g, this.lineComponent.EndPoint, this.lineComponent.ControlPoint2, ViewFactory.ArrowBrush, ViewFactory.ArrowPen, ViewFactory.ArrowLength); if (this.lineComponent.IsSelected) { DrawPoint(g, this.lineComponent.ControlPoint1, ViewFactory.EdgePen, ViewFactory.EdgeBoxWidth); DrawPoint(g, this.lineComponent.ControlPoint2, ViewFactory.EdgePen, ViewFactory.EdgeBoxWidth); } base.Draw(g); }
/* * 函数功能:DrawLine * 函数功能介绍:绘制线条 * 形参列表:points(PointF[],线条的屏幕坐标) * 返回值:void */ public BitmapImage DrawLine(PointF[] points, System.Drawing.Color color, int _width, int _heigh) { System.Drawing.Pen pen = new System.Drawing.Pen(new GDI.SolidBrush(color), (float)2); width = _width; height = _heigh; this.bitmap.Lock(); using (GDI.Bitmap backBufferBitmap = new GDI.Bitmap(width, height, this.bitmap.BackBufferStride, GDI.Imaging.PixelFormat.Format24bppRgb, this.bitmap.BackBuffer)) { using (GDI.Graphics backBufferGraphics = GDI.Graphics.FromImage(backBufferBitmap)) { backBufferGraphics.SmoothingMode = GDI.Drawing2D.SmoothingMode.HighSpeed; backBufferGraphics.CompositingQuality = GDI.Drawing2D.CompositingQuality.HighSpeed; pen = new System.Drawing.Pen(new GDI.SolidBrush(System.Drawing.Color.Red), (float)2); backBufferGraphics.DrawLines(pen, points); backBufferGraphics.Flush(); } } this.bitmap.AddDirtyRect(new Int32Rect(0, 0, width, height)); this.bitmap.Unlock(); Bitmap _bitmap = ConvertWriteableBitmapToBitmap(bitmap); //SaveXXX(); return(BitmapToBitmapImage(_bitmap)); }
public void DrawLines(Pen pen, PointD[] points) { if (pen == null) { throw new ArgumentNullException("pen"); } if (points == null) { throw new ArgumentNullException("points"); } lock (bitmapLock) { double maxX = 0.0d; double maxY = 0.0d; for (long i = 0L; i < points.LongLength; i++) { if (points[i].X > maxX) { maxX = points[i].X; } if (points[i].Y > maxY) { maxY = points[i].Y; } } TryExpand(0.0d, 0.0d, maxX, maxY, pen.Width); using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap)) { g.SmoothingMode = (Antialiasing) ? SmoothingMode.AntiAlias : SmoothingMode.None; g.DrawLines(pen, ToPointFArray(points)); } Texturize(); } }
/// <summary> /// Рисуем линию через все точки /// </summary> /// <param name="graphics"></param> public override void Draw(System.Drawing.Graphics graphics, Pen pen = null, Brush brush = null) { if (markers.Count < 2) { return; } graphics.DrawLines(pen ?? Pens.DarkMagenta, markers.Select(x => x.Location).ToArray()); }
public static void Render(Graphics graphics, LineString line, Pen pen, IViewport viewport) { if (line.Vertices.Count > 1) { var points = GeometryRenderer.WorldToScreenGDI(line, viewport); graphics.DrawLines(pen, points); } }
///<summary> /// Draw this Shape on graphics. /// </summary> /// <param name="graphics">Surfase for drawing.</param> public override void Draw(Graphics graphics) { graphics.DrawLines(new Pen(Color, penWidth), Points.Select(x => new Point(Position.X + x.X, Position.Y + x.Y)).ToArray()); graphics.DrawLine(new Pen(Color, penWidth), new Point(Position.X + Points[Points.Count-1].X, Position.Y + Points[Points.Count-1].Y), new Point(Position.X + Points[0].X, Position.Y + Points[0].Y)); }
public void DrawLine(Vector2D v1, Vector2D v2, Color penColor) { Point[] pt = TransformPoint(new Vector2D[] { v1, v2 }); System.Drawing.Graphics g = Graphics; Pen pen = new Pen(penColor); g.DrawLines(pen, pt); }
public void Draw(Graphics g) { if (PointCount <= 1) return; Point[] pointArray = Points.ToArray(); Pen mypen = new Pen(penColor, penWidth); g.DrawLines(mypen, pointArray); }
protected internal override void Paint(System.Drawing.Graphics gr) { //for now, no styles gr.SmoothingMode = SmoothingMode.AntiAlias; using (var pen = getContourPen(m_View.LineStyle)) { gr.DrawLines(pen, m_Points); } }
private void drawGraphLine(Graphics graphics, PointF[] points, Pen pen, float yScale, float xScale) { var matrix = new Matrix(); matrix.Scale(xScale, yScale); matrix.Translate(5, 5, MatrixOrder.Append); matrix.TransformPoints(points); graphics.DrawLines(pen, points); }
private void DrawPointer(Graphics g,int dx,int dy,Color color,string text) { int cx = 40; int cy = 40; Pen penWide = new Pen(color,2); Point[] apt = {new Point(16*cx/32,4*cy/8),new Point(20*cx/32,2*cy/8),new Point(24*cx/32,4*cy/8)}; Point[] apt1 = {new Point(20*cx/32,7*cy/8),new Point(20*cx/32,2*cy/8)}; penWide.LineJoin = LineJoin.Miter; g.TranslateTransform(dx,dy); g.DrawLines(penWide,apt); g.DrawLines(penWide,apt1); g.TranslateTransform(-dx,-dy); g.DrawString(text,new Font(FontFamily.GenericSansSerif,15,FontStyle.Bold),new SolidBrush(color),dx + 10,dy); }
public static void DoGrid(this WidgetMidiList widget, FloatRect grid, Graphics g) { var gs = g.Save(); using (g.Clip = new Region(grid)) { using (var p0 = new Pen(Color.Black)) foreach (var i in widget.GetHLines(4)) g.DrawLines(p0, new Point[] { new FloatPoint(i.XO, grid.Top), new FloatPoint(i.XO, grid.Bottom) }); using (var p1 = new Pen(Gray130)) foreach (var i in widget.GetHLines(Convert.ToInt32(Math.Pow(4, 2)))) g.DrawLines(p1, new Point[] { new FloatPoint(i.XO, grid.Top), new FloatPoint(i.XO, grid.Bottom) }); using (var p2 = new Pen(White)) foreach (var i in widget.GetHLines(Convert.ToInt32(Math.Pow(4, 3)))) g.DrawLines(p2, new Point[] { new FloatPoint(i.XO, grid.Top), new FloatPoint(i.XO, grid.Bottom) }); g.ResetClip(); } g.Restore(gs); }
protected internal override void Paint(Graphics gr) { //for now, no styles gr.SmoothingMode = SmoothingMode.AntiAlias; using(var pen = getContourPen(m_View.LineStyle)) { gr.DrawLines(pen, m_Points); } }
// Draws the complete stroke. // in: // graphics the drawing surface public void Draw(Graphics graphics) { if ((points.Count < 2) || (graphics == null)) { return; } Pen pen = new Pen(color, penWidth); graphics.DrawLines(pen, (Point[]) points.ToArray(typeof(Point))); }
/// <summary> /// draw a bunch of lines into pictureBox1 using a buffered bitmap /// </summary> /// <param name="nLines"></param> public int DrawSine() { // time how long this takes var watch = System.Diagnostics.Stopwatch.StartNew(); // seed the time offset (to make sine wave a function of system time) int offsetMillisecond = DateTimeOffset.Now.Minute * 60000 + DateTimeOffset.Now.Second * 1000 + DateTimeOffset.Now.Millisecond; // make image buffer and graphics object int width = pictureBox1.Width, height = pictureBox1.Height; Bitmap buffer = new Bitmap(width, height); System.Drawing.Graphics gfx = Graphics.FromImage(buffer); // prep the pen and RNG Pen blackPen = new Pen(Color.Black, (int)numericUpDown1.Value); // black pen width 1 Random rand = new Random(); // create the point array (each point is an X,Y pair) Point[] points = Enumerable.Repeat <Point>(new Point(0, 1), width).ToArray(); // fill the point away with data for (int x = 0; x < width; x++) { double t = ((double)offsetMillisecond / 50) + x; // seed with time (increase number to slow down translation) t /= (double)(width / 50); // divide it down (increase number to increase sine wave frequency) int y = (int)((Math.Sin(t) / 2.0 + .5) * height); points[x] = new Point(x, y); } // set anti-alias here if you wish if (checkBox1.Checked) { gfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; } else { gfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed; } // draw stuff on the buffered graphic gfx.DrawLines(blackPen, points); // apply the buffer to the picturebox pictureBox1.Image = buffer; // stop the timer and show how long it took watch.Stop(); //var elapsedMs = watch.ElapsedMilliseconds; //float sec = (float)DateTimeOffset.Now.Second; //sec += (float)DateTimeOffset.Now.Millisecond/1000; //textBox1.AppendText(String.Format("[{2:00.000}] drew {0} lines in {1} ms\n", width.ToString(), elapsedMs.ToString(), sec)); return((int)watch.ElapsedMilliseconds); }
public override void DrawRect(System.Drawing.RectangleF dirtyRect) { Graphics g = new Graphics(); g.Clear(Color.White); g.SmoothingMode = SmoothingMode.AntiAlias; // Create a pen object: Pen aPen = new Pen(Color.Blue, 2); // Create a brush object with a transparent red color: SolidBrush aBrush = new SolidBrush(Color.Red); HatchBrush hBrush = new HatchBrush(HatchStyle.Shingle, Color.Blue, Color.LightCoral); HatchBrush hBrush2 = new HatchBrush(HatchStyle.Cross, Color.Blue, Color.LightCoral); HatchBrush hBrush3 = new HatchBrush(HatchStyle.BackwardDiagonal, Color.Blue, Color.LightCoral); HatchBrush hBrush4 = new HatchBrush(HatchStyle.Sphere, Color.Blue, Color.LightCoral); // Draw a rectangle: g.DrawRectangle(aPen, 20, 20, 100, 50); // Draw a filled rectangle: g.FillRectangle(hBrush, 20, 90, 100, 50); // Draw ellipse: g.DrawEllipse(aPen, new Rectangle(20, 160, 100, 50)); // Draw filled ellipse: g.FillEllipse(hBrush2, new Rectangle(170, 20, 100, 50)); // Draw arc: g.DrawArc(aPen, new Rectangle(170, 90, 100, 50), -90, 180); // Draw filled pie pieces g.FillPie(aBrush, new Rectangle(170, 160, 100, 100), -90, 90); g.FillPie(hBrush4, new Rectangle(170, 160, 100, 100), -90, -90); // Create pens. Pen redPen = new Pen(Color.Red, 3); Pen greenPen = new Pen(Color.Green, 3); greenPen.DashStyle = DashStyle.DashDotDot; SolidBrush transparentBrush = new SolidBrush(Color.FromArgb(150, Color.Wheat)); // define point array to draw a curve: Point point1 = new Point(300, 250); Point point2 = new Point(350, 125); Point point3 = new Point(400, 110); Point point4 = new Point(450, 210); Point point5 = new Point(500, 300); Point[] curvePoints ={ point1, point2, point3, point4, point5}; // Draw lines between original points to screen. g.DrawLines(redPen, curvePoints); // Fill Curve g.FillClosedCurve(transparentBrush, curvePoints); // Draw closed curve to screen. g.DrawClosedCurve(greenPen, curvePoints); g.Dispose(); }
public override void Draw(Graphics drawingPane, IDictionary<string, ConstVector> anchorLocations) { float height = drawingPane.VisibleClipBounds.Height; Point[] points = Anchors .Select(a => new Point( (int)Math.Round(anchorLocations[a.Name].X), (int)(height - Math.Round(anchorLocations[a.Name].Y)))) .ToArray(); drawingPane.DrawLines(new Pen(Color.Orange, 3), points); }
public override void DrawSelf(Graphics gfx, Pen pen) { int x = pointsPassed.Count; foreach (var item in pointsPassed) { PointF a = new PointF(item.X + Width / 2, item.Y - Width / 2 / x); PointF b = new PointF(item.X + Width / 2, item.Y + Width / 2 / x); x--; gfx.DrawLines(pen, new PointF[2] { Calc.RotatePoint(item, a, Angle), Calc.RotatePoint(item, b, Angle) }); } }
public void DrawLines(Pen p, PointF[] list) { if (isD3D) { d3d.DrawLines(p, list); } else { gdi.DrawLines(p, list); } }
private void DrawArrow(Graphics g,float dx,float dy,Color color) { int cx = 20; int cy = 20; Pen penWide = new Pen(color,2); Point[] apt = {new Point(5*cx/32,3*cy/8),new Point(20*cx/32,0),new Point(20*cx/32,5*cy/8)}; penWide.LineJoin = LineJoin.Miter; g.TranslateTransform(dx,dy); g.DrawLines(penWide,apt); g.TranslateTransform(-dx,-dy); }
protected void DoPage(Graphics grfx, Color clr, int cx, int cy) { PointF[] aptf = new PointF[cx]; for( int i = 0; i < cx; i++ ) { aptf[i].X = i; aptf[i].Y = SupCarSignal(.3f, 1f, 1000f, 10000f, i); //cy / 2 * ( 1 - (float)Math.Sin(i * 2 * Math.PI / ( cx - 1 )) ); } grfx.DrawLines(new Pen(clr), aptf); }
public void DrawBox(Graphics g) { SolidBrush sb = new SolidBrush(boxColor); Pen myPen = new Pen(Color.Black, 3); g.DrawLine(myPen, 20 , box.Y+5, box.X, 105); g.DrawLine(myPen, 20 , box.Y+15, box.X, 115); g.FillRectangle(new SolidBrush(Color.Green), box); g.DrawRectangle(myPen, box); myPen.Width = 15; g.DrawLines(myPen, arrp); g.DrawString((" t = " + (DatTemp.ToString())+"*C"), f, new SolidBrush(Color.Red), box); }
/// <summary> /// Draws the complete stroke /// </summary> /// <param name="graphics">the form's graphics object</param> public void Draw(Graphics graphics) { Point[] pointArray = PointArray; if (pointArray.Length < 2) { return; } Pen pen = new Pen(Color, _penWidth); graphics.DrawLines(pen, pointArray); }
public static void DrawLineString2(Graphics g) { Pen pen = new Pen(Color.Red, 2); Point[] points = new Point[5]; points[0] = new Point(100, 100); points[1] = new Point(100, 200); points[2] = new Point(200, 200); points[3] = new Point(200, 100); points[4] = new Point(500, 500); g.DrawLines(pen, points); }
/// <summary> /// Draw a check of a checkbox on x, y coordinate. /// </summary> /// <param name="g">Graphics object where the check to be drawn.</param> /// <param name="x">X location of the check.</param> /// <param name="y">Y location of the check.</param> /// <param name="state">State of the check.</param> /// <param name="size">Size of the check.</param> /// <param name="enabled">Determine whether checkbox is enabled.</param> public static void DrawCheck(this System.Drawing.Graphics g, int x, int y, CheckState state = CheckState.Checked, int size = 8, bool enabled = true) { if (size > 4) { switch (state) { case CheckState.Checked: Point[] points = new Point[3]; points[0] = new Point(x + 1, y + (int)(size / 2.0)); points[1] = new Point(x + (int)(size / 2.0), y + size - 1); points[2] = new Point(x + size - 1, y + 1); if (enabled) { g.DrawLines(new Pen(Color.FromArgb(62, 106, 170), 2F), points); } else { g.DrawLines(new Pen(Color.DimGray, 2F), points); } break; case CheckState.Indeterminate: Rectangle innerRect = new Rectangle(x + 1, y + 1, size - 2, size - 2); LinearGradientBrush brush = null; if (enabled) { brush = new LinearGradientBrush(innerRect, Color.Chartreuse, Color.Green, 45); } else { brush = new LinearGradientBrush(innerRect, Color.Silver, Color.Gray, 45); } g.FillRectangle(brush, innerRect); brush.Dispose(); break; } } }
public void DrawLShapeLine(System.Drawing.Graphics g, int intMarginLeft, int intMarginTop, int intWidth, int intHeight) { Pen myPen = new Pen(Color.DarkGray); myPen.Width = 1; // Create array of points that define lines to draw. Point[] points = { new Point(intMarginLeft, intHeight + intMarginTop), new Point(intMarginLeft + intWidth, intMarginTop + intHeight), }; g.DrawLines(myPen, points); }
private void ShowHull(Hull hull) { // Create pen. Pen pen = new Pen(Color.Red, 1); //Draw lines to screen. List <PointF> pts = hull.ToList(); if (pts.Count == 1) { return; } g.DrawLines(pen, pts.ToArray()); }
public override void Dessine(Graphics g, int alpha, Point offsetPoint) { //Définir les couleurs en ARGB m_colTrait = Color.FromArgb(alpha, R, G, B); Point[] tabPAjust = new Point[this.tabPoints.Count]; for (int i = 0; i < this.tabPoints.Count; i++) { tabPAjust[i] = new Point(offsetPoint.X + this.tabPoints[i].X, offsetPoint.Y + this.tabPoints[i].Y); } Pen p = new Pen(m_colTrait, StrokeSize); if(this.tabPoints.Count>2) g.DrawLines(p, tabPAjust); }
protected override void OnPaintEtc(System.Drawing.Graphics g) { base.OnPaintEtc(g); if (mEntry != null && mEntry.Records.Count > 1) { int idx = 0; foreach (Record rec in mEntry.Records) { mPoints[idx++] = FromLatLngToLocal(rec.Location); } g.DrawLines(mRedPen, mPoints); if (mShowRange.IsValid) { idx = 0; for (int i = mShowRange.Min; i < mShowRange.Max; ++i) { mSelectedPoints[idx++] = mPoints[i]; } g.DrawLines(mSelectedPen, mSelectedPoints); } } }
public override void Paint(System.Drawing.Graphics g) { PointF[] ext; for (int k = 0; k < Points.Length - 1; k++) { if (Points[k] == Points[k + 1]) { continue; } //this is for the offset points if (k == 0 || k == Points.Length - 2) { g.DrawLine(Pen, Points[k], Points[k + 1]); continue; } //the first point needs to be the left most one PointF s = Points[k], e = Points[k + 1]; if (s.X > e.X) { PointF tmp = s; s = e; e = tmp; } PointF normal = PointF.Empty; double alpha = 0; ext = new PointF[2 + 2 * interpoints]; //two points for each intermediate line-piece if (s.X != e.X) { alpha = Math.Atan2(e.Y - s.Y, e.X - s.X); normal = new PointF((float)Math.Sin(alpha), -(float)Math.Cos(alpha)); } ext[0] = s; float step = 1F / (interpoints + 1); for (int m = 1; m <= interpoints; m++) { //use the convex intersection point plus/minus a delta of the normal of the line segment ext[2 * m - 1] = new PointF((float)((1 - m * step) * s.X + m * step * e.X - wi * normal.X), (float)((1 - m * step) * s.Y + m * step * e.Y - wi * normal.Y)); ext[2 * m] = new PointF((float)((1 - m * step) * s.X + m * step * e.X + wi * normal.X), (float)((1 - m * step) * s.Y + m * step * e.Y + wi * normal.Y)); } ext[2 + 2 * interpoints - 1] = e; g.DrawLines(Pen, ext); } //g.DrawLines(pen,this.mPoints); //g.DrawBeziers(pen,mPoints); }
private void DrawWavyLine(Graphics graphics, Point start, Point end) { if (end.X - start.X < 2) { graphics.DrawLine(Pen, start, end); return; } var offset = -1; var points = new List<Point>(); for (int i = start.X; i <= end.X; i += 2) { points.Add(new Point(i, start.Y + offset)); offset = -offset; } graphics.DrawLines(Pen, points.ToArray()); }
public void DrawPolylineFeature(Graphics g, System.Drawing.Point[] Points_array, int LinePattern, System.Drawing.Color LineColor, int LineWidth) { if (LinePattern == 2) { if (Points_array.GetLength(0) > 1) { g.DrawLines(new Pen(LineColor), Points_array); } } else { DrawDashedPolyline(g, Points_array, LinePattern, LineColor, LineWidth, 0); } }
internal override void doPaint(Graphics g) { var mid = Width/2; var points = new Point[] { new Point(mid - 7, mid - 7), new Point(mid + 7, mid - 10), new Point( mid, mid + 12), new Point( mid-5, mid + 10), new Point( mid - 7, mid - 7) }; g.DrawLines(LinePen, points); }
public override void DrLine(Graphics g) { //delta(); Brush brush = new SolidBrush(Color.Black); Font font = new Font("Times New Roman", 12, FontStyle.Regular); g.DrawString(TextLine, font, brush, PositionLineNachalo.X + deltaX, PositionLineNachalo.Y + deltaY); if (linePoints == null || linePoints.Length == 2) LineTwoPoints(); Pen pen = new Pen(Color.Black, 4); pen.EndCap = LineCap.ArrowAnchor; g.DrawLines(pen, linePoints); }
private void button5_Click(object sender, EventArgs e) { g.Clear(Color.Black); double j = 1; for (int i = 0; i < 2000; i += 8) { Point[] points = { new Point(440 - i, 260 + (int)j), new Point(540 - (int)j, 360 - i), new Point(440 + i, 460 - (int)j), new Point(340 + (int)j, 360 + i), new Point(440 - i, 260 + (int)j), }; //j = i*i*i/100 - i*i/10 + i ; j = -13 * i * i * i / 2137500 + 197 * i * i / 28500 - 539 * i / 855; g.DrawLines(pen1, points); } }
public override void Draw(System.Drawing.Graphics g) { base.Draw(g); AllPoints = CalcPoint(); if (AllPoints.Length > 0) { if (Closed) { g.DrawPolygon(LinePen.GetPen(), AllPoints); } else { g.DrawLines(LinePen.GetPen(), AllPoints); } } }
/// <summary> /// Paint me /// </summary> /// <param name="g"></param> protected override void OnPaint(System.Drawing.Graphics g) { //Draw Grid base.OnPaint(g); g.SmoothingMode = SmoothingMode.AntiAlias; Pen myPen; //Run through all series and draw for (int i = 0; i < ScreenPoints.Length; i++) { PointF[] p = ScreenPoints[i]; myPen = new Pen(this.GetColor(i), 1); g.DrawLines(myPen, p); } }
private static void AddLineString(drawing.Graphics graphics, SqlGeometry lineString, Func <Point, Point> transform, drawing.Pen pen, drawing.Brush brush) { int numberOfPoints = lineString.STNumPoints().Value; drawing.PointF[] points = new drawing.PointF[numberOfPoints]; //STPointN(index): index is between 1 and number of points for (int i = 0; i < numberOfPoints; i++) { var parsedPoint = transform(lineString.STPointN(i + 1).AsWpfPoint()); points[i] = new drawing.PointF((float)parsedPoint.X, (float)parsedPoint.Y); } graphics.DrawLines(pen, points); }
// Create a DrawingVisual that contains a rectangle. /* private DrawingVisual CreateDrawingVisualRectangle() * { * DrawingVisual drawingVisual = new DrawingVisual(); * * // Retrieve the DrawingContext in order to create new drawing content. * drawingContext = drawingVisual.RenderOpen(); * * // Create a rectangle and draw it in the DrawingContext. * // Draw a transparent background to set the render size * drawingContext.DrawRectangle(Brushes.Black, (Pen)null, new Rect(0,0,100,100)); * // Persist the drawing content. * // dc.Close(); * * pen = new System.Drawing.Pen( Brushes.Red, 2); * return drawingVisual; * }*/ private void panel1_Paint(object sender, PaintEventArgs e) { Panel p = (Panel)sender; System.Drawing.Graphics g = e.Graphics; g.FillRectangle(System.Drawing.Brushes.Black, p.DisplayRectangle); System.Drawing.Point[] points = new System.Drawing.Point[4]; points[0] = new System.Drawing.Point(0, 0); //points[1] = new System.Drawing.Point(0, p.Height); points[2] = new System.Drawing.Point(p.Width, p.Height); //points[3] = new System.Drawing.Point(p.Width, 0); g.DrawLines(pen, points); }
public static void DrawHollowwRectangle(System.Drawing.Graphics graphics, Rectangle rect, Color color) { PointF[] points = new PointF[3]; points[0] = new PointF( rect.X + rect.Width / 4.5f, rect.Y + rect.Height / 2.5f); points[1] = new PointF( rect.X + rect.Width / 2.5f, rect.Bottom - rect.Height / 3f); points[2] = new PointF( rect.Right - rect.Width / 4.0f, rect.Y + rect.Height / 4.5f); using (Pen pen = new Pen(color, 2F)) { graphics.DrawLines(pen, points); } }
private void DrawDecelerationCurve(System.Drawing.Graphics g, MotorCar car) { if (!car.Acceleration.Resistance) { // curve Point[] points = new Point[car.Acceleration.ImageWidth]; for (int x = 0; x < car.Acceleration.ImageWidth; x++) { double velocity = car.Acceleration.XtoVelocity(x); double acceleration = GetDeceleration(car, velocity); int y = (int)Math.Round(car.Acceleration.AccelerationToY(acceleration)); points[x] = new Point(x, y); } g.DrawLines(Pens.DimGray, points); } }
public void DrawLine(PointF[] points, System.Drawing.Color color) { System.Drawing.Pen pen = new System.Drawing.Pen(new GDI.SolidBrush(color), (float)0.5); this.bitmap.Lock(); using (GDI.Bitmap backBufferBitmap = new GDI.Bitmap(width, height, this.bitmap.BackBufferStride, GDI.Imaging.PixelFormat.Format24bppRgb, this.bitmap.BackBuffer)) { using (GDI.Graphics backBufferGraphics = GDI.Graphics.FromImage(backBufferBitmap)) { backBufferGraphics.SmoothingMode = GDI.Drawing2D.SmoothingMode.HighSpeed; backBufferGraphics.CompositingQuality = GDI.Drawing2D.CompositingQuality.HighSpeed; backBufferGraphics.DrawLines(pen, points); backBufferGraphics.Flush(); } } this.bitmap.AddDirtyRect(new Int32Rect(0, 0, width, height)); this.bitmap.Unlock(); }
/// <summary> /// Paints the bundle on the canvas /// </summary> /// <param name="g"></param> public override void Paint(System.Drawing.Graphics g) { g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; //the shadow switch (mCurveType) { case MultiPointType.Straight: g.DrawLines(ArtPallet.BlackPen, mPoints); break; case MultiPointType.Polygon: g.DrawPolygon(ArtPallet.BlackPen, mPoints); break; case MultiPointType.Curve: //note that you can specify a tension of the curve here (greater than 0.0F) g.DrawCurve(ArtPallet.BlackPen, mPoints); break; } }
protected override void OnPaint(PaintEventArgs e) { System.Drawing.Graphics g = e.Graphics; //Уровень //Line[] lines = m.GetLines(); //for (var i = 0; i < lines.Length; i++) //{ // g.DrawLine(Pens.Black, lines[i].p0.ToPoint, lines[i].p1.ToPoint); //} g.DrawLines(Pens.Red, testCountur.Points.Select(x => x.ToPoint).ToArray()); foreach (var item in OffsetList.Select(x => x.ToPoint).ToList()) { g.FillPie(Brushes.Black, new Rectangle((int)item.X - 5 / 2, (int)item.Y - 5 / 2, 5, 5), 0, 360); } //Видимость //if (TEstsss != null) //{ // g.FillPolygon(Brushes.Salmon, TEstsss.Points.Select(x => x.ToPoint).ToArray()); // // g.FillPolygon(Brushes.Salmon, con.Points.Select(x => x.ToPoint).ToArray()); // foreach (var item in TEstsss.Points.Select(x => x.ToPoint).ToList()) // { // g.FillPie(Brushes.Blue, new Rectangle((int)item.X - 5 / 2, (int)item.Y - 5 / 2, 5, 5), 0, 360); // } // foreach (var item in m.NovigationVertex.Select(x => x.ToPoint).ToList()) // { // g.FillPie(Brushes.Black, new Rectangle((int)item.X - 5 / 2, (int)item.Y - 5 / 2, 5, 5), 0, 360); // } //} // g.FillPolygon(Brushes.Salmon, con.Points.Select(x => x.ToPoint).ToArray()); //Другие объекты //foreach (SceneObject item in SceneObjects) //{ // item.Draw(g); //} }
public override void Draw(System.Drawing.Graphics g) { g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; //phải xét lại để trong quá trình MouseMove int width = Math.Abs(endPoint.X - startPoint.X); int height = Math.Abs(endPoint.Y - startPoint.Y); int spX = Math.Min(startPoint.X, endPoint.X); int spY = Math.Min(startPoint.Y, endPoint.Y); mRec = new Rectangle(spX, spY, width, height); center = new Point(mRec.Width / 2 + startPoint.X, mRec.Height / 2 + startPoint.Y); l = new List <Point> [4]; for (int i = 0; i < 4; i++) { l[i] = new List <Point>(); } DDA(); for (int i = 0; i < 4; i++) { g.DrawLines(p, l[i].ToArray()); } }