private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { Point cur = e.Location; if (e.Button == MouseButtons.Left) { path.Reset(); path.AddEllipse(new Rectangle(prev.X, prev.Y, cur.X - prev.X, cur.Y - prev.Y)); pictureBox1.Refresh(); } }
void GenerateAustPlusRandomEllipses(int count) { subjects.Clear(); //load map of Australia from resource ... System.IO.Stream polyStream = Alt.IO.VirtualFile.OpenRead("AltData/Clipper/aust.bin"); int len = (int)polyStream.Length; byte[] b = new byte[len]; polyStream.Read(b, 0, len); int polyCnt = BitConverter.ToInt32(b, 0); int k = 4; for (int i = 0; i < polyCnt; ++i) { int vertCnt = BitConverter.ToInt32(b, k); k += 4; Polygon pg = new Polygon(vertCnt); for (int j = 0; j < vertCnt; ++j) { float x = BitConverter.ToSingle(b, k) * scale; float y = BitConverter.ToSingle(b, k + 4) * scale; k += 8; pg.Add(new IntPoint((int)x, (int)y)); } subjects.Add(pg); } clips.Clear(); Random rand = new Random(); GraphicsPath path = new GraphicsPath(); PointI pt = new PointI(); const int ellipse_size = 100, margin = 10; for (int i = 0; i < count; ++i) { int w = WorkArea.Width - ellipse_size - margin * 2; int h = WorkArea.Height - ellipse_size - margin * 2; pt.X = rand.Next(w) + margin; pt.Y = rand.Next(h) + margin; int size = rand.Next(ellipse_size - 20) + 20; path.Reset(); path.AddEllipse(pt.X, pt.Y, size, size); path.Flatten(); Polygon clip = new Polygon(path.PathPoints.Length);//Count()); foreach (Point p in path.PathPoints) { clip.Add(new IntPoint((int)(p.X * scale), (int)(p.Y * scale))); } clips.Add(clip); } }
private void SetSelection(Rectangle rectangle) { selectionRegion.MakeEmpty(); selectionPath.Reset(); if (!rectangle.IsEmpty) { selectionPath.AddRectangle(rectangle); selectionRegion.Union(selectionPath); } }
//--------------------------------------------------------------------- private void GenerateAustPlusRandomEllipses(int count) { subjects.Clear(); //load map of Australia from resource ... _assembly = Assembly.GetExecutingAssembly(); polyStream = _assembly.GetManifestResourceStream("GuiDemo.aust.bin"); int len = (int)polyStream.Length; byte[] b = new byte[len]; polyStream.Read(b, 0, len); int polyCnt = BitConverter.ToInt32(b, 0); int k = 4; for (int i = 0; i < polyCnt; ++i) { int vertCnt = BitConverter.ToInt32(b, k); k += 4; Polygon pg = new Polygon(vertCnt); for (int j = 0; j < vertCnt; ++j) { float x = BitConverter.ToSingle(b, k) * scale; float y = BitConverter.ToSingle(b, k + 4) * scale; k += 8; pg.Add(new IntPoint((int)x, (int)y)); } subjects.Add(pg); } clips.Clear(); Random rand = new Random(); GraphicsPath path = new GraphicsPath(); Point pt = new Point(); const int ellipse_size = 100, margin = 10; for (int i = 0; i < count; ++i) { int w = pictureBox1.ClientRectangle.Width - ellipse_size - margin * 2; int h = pictureBox1.ClientRectangle.Height - ellipse_size - margin * 2 - statusStrip1.Height; pt.X = rand.Next(w) + margin; pt.Y = rand.Next(h) + margin; int size = rand.Next(ellipse_size - 20) + 20; path.Reset(); path.AddEllipse(pt.X, pt.Y, size, size); path.Flatten(); Polygon clip = new Polygon(path.PathPoints.Count()); foreach (PointF p in path.PathPoints) { clip.Add(new IntPoint((int)(p.X * scale), (int)(p.Y * scale))); } clips.Add(clip); } }
private void Form1_MouseMove(object sender, MouseEventArgs e) { path.Reset(); if (e.Button == MouseButtons.Left) { c = e.Location; path.AddLine(p.X, p.Y, c.X - p.X, c.Y - p.Y); p = c; } Refresh(); }
/// <summary> /// Overridden. See <see cref="PNode.Paint">PNode.Paint</see>. /// </summary> protected override void Paint(PPaintContext paintContext) { Graphics g = paintContext.Graphics; float x = X; float y = Y; float width = Width; float height = Height; float[] elements = g.Transform.Elements; float magX = elements[0]; float magY = elements[3]; float dx = (float)(1.0 / magX); float dy = (float)(1.0 / magY); g.FillRectangle(Brush, Bounds); path.Reset(); path.AddLine((float)(x + width), (float)y, (float)x, (float)y); path.AddLine((float)x, (float)y, (float)x, (float)(y + height)); pen.Color = topLeftOuterColor; g.DrawPath(pen, path); path.Reset(); path.AddLine((float)(x + width), (float)(y + dy), (float)(x + dx), (float)(y + dy)); path.AddLine((float)(x + dx), (float)(y + dy), (float)(x + dx), (float)(y + height)); pen.Color = topLeftInnerColor; g.DrawPath(pen, path); path.Reset(); path.AddLine((float)(x + width), (float)(y), (float)(x + width), (float)(y + height)); path.AddLine((float)(x + width), (float)(y + height), (float)(x), (float)(y + height)); pen.Color = bottomRightOuterColor; g.DrawPath(pen, path); path.Reset(); path.AddLine((float)(x + width - dx), (float)(y + dy), (float)(x + width - dx), (float)(y + height - dy)); path.AddLine((float)(x + width - dx), (float)(y + height - dy), (float)(x), (float)(y + height - dy)); pen.Color = bottomRightInnerColor; g.DrawPath(pen, path); }
internal void UpdateGraphicsPath() { if (graphicsPath == null) { graphicsPath = new GraphicsPath(); } else { try { graphicsPath.Reset(); } catch { } } { for (int i = 0; i < LocalPoints.Count; i++) { try { GPoint p2 = LocalPoints[i]; if (i == 0) { graphicsPath.AddLine(p2.X, p2.Y, p2.X, p2.Y); } else { System.Drawing.PointF p = graphicsPath.GetLastPoint(); graphicsPath.AddLine(p.X, p.Y, p2.X, p2.Y); } } catch (Exception) { continue; } } } }
/// <summary> /// Initialize a new dialog with defaults /// </summary> public CropImageDialog() { InitializeComponent(); selectionRegion = new Region(); selectionRegion.MakeEmpty(); selectionPath = new GraphicsPath(); selectionPath.Reset(); handles = new List <SelectionHandle>(); moveState = MoveState.None; }
public static bool IsInside(Point inputponint, PointF[] pointfs) { GraphicsPath myGraphicsPath = new GraphicsPath(); Region myRegion = new Region(); myGraphicsPath.Reset(); myGraphicsPath.AddPolygon(pointfs); myRegion.MakeEmpty(); myRegion.Union(myGraphicsPath); return(myRegion.IsVisible(inputponint)); }
private void Form1_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left && isVisible) { a = e.Location.X - r; b = e.Location.Y - r; gp.Reset(); brush.Color = Color.Green; gp.AddEllipse(new Rectangle(a, b, 2 * r, 2 * r)); Refresh(); } }
public void updateGraphicsPath(GraphicsPath gp, int scale, int xofs, int yofs) { //todo: much optimization gp.Reset(); Selection sHorz = new Selection(r.Width, r.Height * 2); Selection sVert = new Selection(r.Width * 2, r.Height); int xo = r.Left * scale; int yo = r.Top * scale; for (int y = 0; y < r.Height; y++) { for (int x = 0; x < r.Width; x++) { if (getPoint(x + r.Left, y + r.Top)) { if (!getPoint(x - 1 + r.Left, y + r.Top)) { gp.StartFigure(); gp.AddLine(x * scale + xofs, y * scale + yofs, x * scale + xofs, y * scale + scale + yofs); gp.CloseFigure(); } //sVert.setPoint(x*2,y,true); if (!getPoint(x + 1 + r.Left, y + r.Top)) { gp.StartFigure(); gp.AddLine(x * scale + scale + xofs, y * scale + yofs, x * scale + scale + xofs, y * scale + scale + yofs); gp.CloseFigure(); } //sVert.setPoint(x*2+1,y,true); if (!getPoint(x + r.Left, y - 1 + r.Top)) { gp.StartFigure(); gp.AddLine(x * scale + xofs, y * scale + yofs, x * scale + scale + xofs, y * scale + yofs); gp.CloseFigure(); } // sHorz.setPoint(x,y*2,true); if (!getPoint(x + r.Left, y + 1 + r.Top)) { gp.StartFigure(); gp.AddLine(x * scale + xofs, y * scale + scale + yofs, x * scale + scale + xofs, y * scale + scale + yofs); gp.CloseFigure(); } // sHorz.setPoint(x,y*2+1,true); } } } Matrix m = new Matrix(); m.Translate((float)xo, (float)yo); gp.Transform(m); }
public void UpdateGraphicsPath() { if (graphicsPath == null) { graphicsPath = new GraphicsPath(); } else { graphicsPath.Reset(); } { if (LocalPoints.Count == 0) { return; } // inside or within the current view var minx = Points.Min(a => a.Lng); var maxx = Points.Max(a => a.Lng); var miny = Points.Min(a => a.Lat); var maxy = Points.Max(a => a.Lat); Bounds = RectLatLng.FromLTRB(minx, maxy, maxx, miny); List <Point> pnts = new List <Point>(); var last = Point.Empty; for (int i = 0; i < LocalPoints.Count; i++) { Point p2 = new Point((int)LocalPoints[i].X, (int)LocalPoints[i].Y); if (p2 == last) { continue; } pnts.Add(p2); last = p2; } //close it pnts.Add(new Point((int)LocalPoints[LocalPoints.Count - 1].X, (int)LocalPoints[LocalPoints.Count - 1].Y)); if (pnts.Count > 2) { graphicsPath.AddPolygon(pnts.ToArray()); } else if (pnts.Count == 2) { graphicsPath.AddLines(pnts.ToArray()); } } }
private bool IsInRegion(Point input, Point[] points) { GraphicsPath myGraphicsPath = new GraphicsPath(); Region myRegion = new Region(); myGraphicsPath.Reset(); myGraphicsPath.AddPolygon(points); myRegion.MakeEmpty(); myRegion.Union(myGraphicsPath); //返回判断点是否在多边形里 return(myRegion.IsVisible(input)); }
public void Draw(Renderer renderer) { var r = radius * renderer.ScaleCoef / renderer.Scale; path.Reset(); path.AddEllipse(new RectangleF(Position.X - r, Position.Y - r, r * 2, r * 2)); using (var brush = new SolidBrush(Color)) { renderer.Graphics.FillPath(brush, path); } }
internal static void FillRegion(Graphics GraphicsObj = null) { AppendToLinePath = Settings.AppendCurrent; if (!AppendToLinePath) { LinePath.FillMode = FillMode.Winding; LinePath.CloseAllFigures(); GraphicsObj.FillPath(FillBrush, LinePath); GraphicsObj.DrawPath(TurtlePen, LinePath); LinePath.Reset(); } }
private void MakePath(ref GraphicsPath pth, Rectangle rc, int rad) { pth.Reset(); pth.AddArc(rc.X, rc.Y, rad, rad, 180f, 90f); checked { pth.AddArc(rc.Right - rad, rc.Y, rad, rad, 270f, 90f); pth.AddArc(rc.Right - rad, rc.Bottom - rad, rad, rad, 0f, 90f); pth.AddArc(rc.X, rc.Bottom - rad, rad, rad, 90f, 90f); pth.CloseFigure(); } }
public virtual void DrawPoints(Graphics g) {//显示热点 myGraphicsPath.Reset(); if (ReDianVisible && Parent == null)//只有顶层元素才显示热点。 { foreach (CBase Redian in ReDians) { Redian.Draw(g); } } }
internal void CreateData(RectangleF bounds, float innerRadius, float outerRadius, float startAngle, float sweepAngle) { path.Reset(); path.StartFigure(); path.AddArc(bounds, startAngle, sweepAngle); float d = outerRadius - innerRadius; bounds.Inflate(d, d); path.AddArc(bounds, startAngle + sweepAngle, -sweepAngle); path.CloseFigure(); }
public override void Berechnung() { for (int i = 0; i < 2; i++) { Matrix matrix = new Matrix(); matrix.Translate(_knoten.Position.X, _knoten.Position.Y); matrix.Rotate(-_gleise[i].GetDirection(_knoten) * 45); graphicsPathLinien[i].Reset(); graphicsPathLinien[i].AddLine(0, 0, (int)(0.7 * Zoom), 0); graphicsPathLinien[i].Transform(matrix); } graphicsPathUntergrung.Reset(); graphicsPathUntergrung.AddRectangle(graphicsPathLinien[1].GetBounds()); graphicsPathUntergrung.AddRectangle(graphicsPathLinien[0].GetBounds()); RectangleF r = graphicsPathUntergrung.GetBounds(); r.Inflate(2, 2); graphicsPathUntergrung.Reset(); graphicsPathUntergrung.AddRectangle(r); }
private void RenderWave(Graphics g, Channel channel, int triggerPoint, Pen pen, Brush brush, PointF[] points, GraphicsPath path, double fillBase) { // And the initial sample index var leftmostSampleIndex = triggerPoint - channel.ViewWidthInSamples / 2; float xOffset = channel.Bounds.Left; float xScale = (float)channel.Bounds.Width / channel.ViewWidthInSamples; float yOffset = channel.Bounds.Top + channel.Bounds.Height * 0.5f; float yScale = -channel.Bounds.Height * 0.5f; for (int i = 0; i < channel.ViewWidthInSamples; ++i) { var sampleValue = channel.GetSample(leftmostSampleIndex + i, false); points[i].X = xOffset + i * xScale; points[i].Y = yOffset + sampleValue * yScale; } if (channel.Clip) { for (int i = 0; i < channel.ViewWidthInSamples; ++i) { points[i].Y = Math.Min(Math.Max(points[i].Y, channel.Bounds.Top), channel.Bounds.Bottom); } } if (channel.SmoothLines) { // Enable anti-aliased lines g.SmoothingMode = SmoothingMode.HighQuality; } else { g.SmoothingMode = SmoothingMode.None; } // Then draw them all in one go... if (pen != null) { // TODO: this is expensive g.DrawLines(pen, points); } if (brush != null) { // We need to add points to complete the path // We compute the Y position of this line. -0.5 scales -1..1 to bottom..top. var baseY = (float)(yOffset + channel.Bounds.Height * -0.5 * fillBase); path.Reset(); path.AddLine(points[0].X, baseY, points[0].X, points[0].Y); path.AddLines(points); path.AddLine(points[points.Length - 1].X, points[points.Length - 1].Y, points[points.Length - 1].X, baseY); g.FillPath(brush, path); } }
private void MyMouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if (_useROI) { _drawRect = new Rectangle(0, 0, 0, 0); _drawRect.X = e.X; _drawRect.Y = e.Y; _drawRect.Width = 0; _drawRect.Height = 0; _originPoint = new Point(e.X, e.Y); _mousePath.Reset(); _mousePath.AddRectangle(_drawRect); // Draw the path to the screen. _graph = _viewer.CreateGraphics(); _graph.DrawPath(_myDrawPen, _mousePath); _startDrawing = true; } }
public void Move() { y += 10; if (y == 300) { y = 0; } calls++; gp1.Reset(); gp1.AddEllipse(x - 10, y - 10, 20, 20); }
private void DrawTextFunc(Graphics g, int ptX = 0, int ptY = 0) { //Setup Text Brushes Brush br = new SolidBrush(Color.FromArgb((int)(_gTextTransp), TextColor)); //Brush brs = new SolidBrush(Color.FromArgb(_gTextShadower.ShadowTransp,gTextShadowColor)); if (_gTextFade == FadeMode.Linear) { br = new LinearGradientBrush( new Rectangle(ptX + 3, ptY + 3, (int)(_gTextBoxArea.Width), (int)(_gTextBoxArea.Height + 3)), TextColor, Color.Transparent, LinearGradientMode.Horizontal); //brs = new LinearGradientBrush( // new Rectangle(0, 0, (int)(_gTextBoxArea.Width), (int)(_gTextBoxArea.Height + 3)), // Color.FromArgb(_gTextShadower.ShadowTransp,gTextShadowColor), // Color.Transparent, LinearGradientMode.Horizontal); } else if (_gTextFade == FadeMode.Path) { GraphicsPath gp = new GraphicsPath(); gp.AddRectangle(new Rectangle(ptX + 3, ptY + 3, (int)(_gTextBoxArea.Width), (int)(_gTextBoxArea.Height + 3))); br = new PathGradientBrush(gp); (br as PathGradientBrush).CenterColor = TextColor; (br as PathGradientBrush).SurroundColors = new Color[] { Color.Transparent }; gp.Reset(); gp.AddRectangle(new Rectangle(0, 0, (int)(_gTextBoxArea.Width), (int)(_gTextBoxArea.Height + 3))); //brs = new PathGradientBrush(gp); //(brs as PathGradientBrush).CenterColor = Color.FromArgb(_gTextShadower.ShadowTransp,gTextShadowColor); //(brs as PathGradientBrush).SurroundColors = new Color() {Color.Transparent}; gp.Dispose(); } //if (_gTextShadow) //{ // //If shadow is requested setup and use the TextShadower // throw new Exception("Not Implemented!"); // //WithgTextShadower // // .Font =gFont // // .TextBrush = br // // .ShadowBrush = brs // // .Alignment =gTextAlignment // // .ShadowTheText(g, New Rectangle(ptX + 3, ptY + 3, (int)(_gTextBoxArea.Width), (int)(_gTextBoxArea.Height + 3)),gText) // //End With // } //else { g.TextRenderingHint = TextRenderingHint.AntiAlias; g.DrawString(_gText, Font, br, new Rectangle(ptX + 3, ptY + 3, (int)(_gTextBoxArea.Width), (int)(_gTextBoxArea.Height + 3)), sf); } br.Dispose(); //brs.Dispose(); }
void Fusion_PaintHook(PaintEventArgs e) { Fusion_Path = new GraphicsPath(); Fusion_Blend = new ColorBlend(); Fusion_Blend.Colors = new Color[] { Color.Transparent, Color.FromArgb(60, 60, 63), Color.Transparent }; Fusion_Blend.Positions = new float[] { 0f, 0.5f, 1f }; G.DrawRectangle(Fusion_P1, ClientRectangle); Fusion_Path.Reset(); Fusion_Path.AddLines(new Point[] { new Point(2, 0), new Point(Width - 3, 0), new Point(Width - 1, 2), new Point(Width - 1, Height - 3), new Point(Width - 3, Height - 1), new Point(2, Height - 1), new Point(0, Height - 3), new Point(0, 2), new Point(2, 0) }); G.SetClip(Fusion_Path); G.Clear(Fusion_C1); DrawGradient(Fusion_C2, Fusion_C3, 0, 0, 16, Height); DrawGradient(Fusion_C2, Fusion_C3, Width - 16, 0, 16, Height); DrawText(Fusion_B1, HorizontalAlignment.Left, 12, 0); Fusion_RT1 = new Rectangle(12, 34, Width - 24, Height - 34 - 12); G.FillRectangle(Fusion_B2, Fusion_RT1); DrawBorders(Fusion_P2, Fusion_RT1, 1); DrawBorders(Fusion_P3, Fusion_RT1); DrawBorders(Fusion_P4, 1); DrawGradient(Fusion_Blend, 1, 1, Width - 2, 2, 0f); G.ResetClip(); G.DrawPath(Fusion_P5, Fusion_Path); }
private void DrawCube(Graphics g, float w, float h, float d, Point xy1) { Point point = Point.Empty; float height = g.VisibleClipBounds.Height; GraphicsPath path = new GraphicsPath(); d *= 0.7f; Graphics graphics = g; using (SolidBrush brush = new SolidBrush(Color.LightGray)) { graphics.FillRectangle(brush, (float)xy1.X, height - xy1.Y, w, h); } point.X = (int)Math.Round((double)(xy1.X + (d * Math.Cos(0.52356020942408377)))); point.Y = (int)Math.Round((double)(xy1.Y + (d * Math.Sin(0.52356020942408377)))); Point point2 = point; point2.Offset((int)Math.Round((double)w), 0); Point point3 = xy1; point3.Offset((int)Math.Round((double)w), 0); PointF[] thePolygon = new PointF[] { xy1, point, point2, point3 }; this.ReverseY(ref thePolygon, height); path.AddLines(thePolygon); using (PathGradientBrush brush2 = new PathGradientBrush(path)) { brush2.CenterPoint = new PointF(2f * w, height); brush2.CenterColor = Color.SteelBlue; graphics.FillPath(brush2, path); } point = point3; point3 = point2; point3.Offset(0, (int)Math.Round((double)-h)); Point point4 = point; point4.Offset(0, (int)Math.Round((double)-h)); thePolygon = new PointF[] { point, point2, point3, point4 }; this.ReverseY(ref thePolygon, height); path.Reset(); path.AddLines(thePolygon); using (PathGradientBrush brush3 = new PathGradientBrush(path)) { brush3.CenterPoint = new PointF(2f * w, height); brush3.CenterColor = Color.SlateGray; graphics.FillPath(brush3, path); } goto DIS; DIS: graphics = null; }
/// <summary> /// Расчёт размерного прямоугольника для отсутствующих рёбер внешнего контура /// </summary> /// <param name="list"></param> /// <param name="line"></param> /// <param name="point"></param> /// <returns></returns> private Rectangle GetEdgeLine(List <Edge> list, Line line, Point point) { using (var grp = new GraphicsPath()) { grp.AddLine(line.Point1, line.Point2); var full = Rectangle.Ceiling(grp.GetBounds()); if (full.Width == 0) { full.Width = 4; full.Offset(-2, 0); } else if (full.Height == 0) { full.Height = 4; full.Offset(0, -2); } using (var fr = new Region(full)) { foreach (var edge in list) { grp.Reset(); grp.AddLine(edge.Node1.Offset, edge.Node2.Offset); var rect = Rectangle.Ceiling(grp.GetBounds()); if (rect.Width == 0) { rect.Width = 4; rect.Offset(-2, 0); } else if (rect.Height == 0) { rect.Height = 4; rect.Offset(0, -2); } using (var rg = new Region(rect)) fr.Exclude(rg); } using (var image = new Bitmap(Area.Width, Area.Height)) using (var gr = Graphics.FromImage(image)) { foreach (var rect in fr.GetRegionScans(new Matrix())) { if (rect.Contains(point)) { return(Rectangle.Ceiling(rect)); } } } } } return(Rectangle.Empty); }
private void drawFigure(PaintEventArgs e, PointF[] points) { GraphicsPath path = new GraphicsPath(); Corners r = new Corners(points, 5); r.Execute(path); path.CloseFigure(); Matrix matrix = new Matrix(); matrix.Translate(3, 3); path.Transform(matrix); Color c = (this.imageList3.Images[0] as Bitmap).GetPixel(this.imageList3.Images[0].Width - 5, this.imageList3.Images[0].Height / 2); drawPath(e, path, c); path.Reset(); r = new Corners(points, 5); r.Execute(path); path.CloseFigure(); matrix = new Matrix(); matrix.Translate(0, 0); path.Transform(matrix); c = (this.imageList3.Images[0] as Bitmap).GetPixel(this.imageList3.Images[0].Width / 2, this.imageList3.Images[0].Height / 2); if (treeView1 == null) { } else { if (c.Name == "0") { } else { treeView1.BackColor = c; } } panelbutton.BackColor = c; drawPath(e, path, c); path.Dispose(); }
/// <summary> /// Make Brushes /// </summary> public void MakeBrushes() { #region Glass shadow // If the rectangle is empty, skip if (ClientRectangle.IsEmpty) { return; } // Create a path which encapsulates the control. _glassShadowPath.Reset(); _glassShadowPath.AddEllipse(ClientRectangle); // Dispose of any old brush if (_glassShadowBrush != null) { _glassShadowBrush.Dispose(); } // Create a new brush _glassShadowBrush = new PathGradientBrush(_glassShadowPath); // And set its gradient colors if (_glassShadowColorBlend.Colors.Length > 1) { _glassShadowBrush.InterpolationColors = _glassShadowColorBlend; } #endregion #region Glass reflection // Dispose of any old brush if (GlassReflectionBrush != null) { GlassReflectionBrush.Dispose(); } // Create the linear gradient GlassReflectionBrush = new LinearGradientBrush(ClientRectangle, Color.White, Color.White, 85, false); if (_glassReflectionColorBlend.Colors.Length > 1) { GlassReflectionBrush.InterpolationColors = _glassReflectionColorBlend; } // Set the rectangle for drawing the reflection GlassReflectionRectangle = new RectangleF(Convert.ToSingle(Width * 0.15), Convert.ToSingle(Height * 0.02), Convert.ToSingle(Width * 0.7), Convert.ToSingle(Height * 0.58)); #endregion }
private void FindWord_Resize(object sender, EventArgs e) { path.Reset(); if (this.Region != null) { this.Region.Dispose(); this.Region = null; } path.AddEllipse(0, 0, this.ClientSize.Width, this.ClientSize.Height); this.Region = new Region(path); }
void PaintWidenPolygon(Graphics g, Point start, Size size, int i) { invPath.Reset(); var shape = new VectorShape( new Vector(start.ToXwt(), (start + size).ToXwt())); invPath.AddLine(shape.Start.ToGdi(), shape.End.ToGdi()); pathPen.EndCap = LineCap.ArrowAnchor; g.DrawPath(pathPen, invPath); var count = shape[Anchor.MostLeft].ToGdi(); g.DrawString(i.ToString(), SD.SystemFonts.StatusFont, SystemBrushes.Control, count); invPath.Reset(); invPath.AddPolygon(GetHull(shape, Camera.Matrix, 2)); var save = g.Transform; g.Transform = new SD.Drawing2D.Matrix(); g.DrawPath(pathPen, invPath); g.Transform = save; }
public static void Main () { Bitmap bmp = new Bitmap (600, 300); Graphics dc = Graphics.FromImage (bmp); Font fnt = new Font ("Arial", 8); Font fnttitle = new Font ("Arial", 8, FontStyle.Underline); Matrix matrix = new Matrix (); GraphicsPath patha = new GraphicsPath (); GraphicsPath pathb = new GraphicsPath (); Pen redPen = new Pen (Color.Red, 2); Region rgn1; Region rgn2; int x = 0; SolidBrush whiteBrush = new SolidBrush (Color.White); dc.DrawString ("Region samples using GraphicsPath", fnttitle, whiteBrush, 5, 5); /* First*/ patha.AddLine (60, 40, 90, 90); patha.AddLine (90, 90, 10, 90); patha.AddLine (10, 90, 60, 40); dc.DrawPath (redPen, patha); pathb.AddEllipse(30, 55, 60, 60); dc.DrawPath(redPen, pathb); rgn1 = new Region (patha); rgn2 = new Region (pathb); rgn1.Complement (rgn2); dc.FillRegion (Brushes.Blue, rgn1); dc.DrawString ("Complement (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 10, 140); dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix)); x += 110; /* Second*/ patha.Reset (); pathb.Reset (); patha.AddLine (60+x, 40, 90+x, 90); patha.AddLine (90+x, 90, 10+x, 90); patha.AddLine (10+x, 90, 60+x, 40); dc.DrawPath (redPen, patha); pathb.AddEllipse (30+x, 55, 60, 60); dc.DrawPath(redPen, pathb); rgn1 = new Region (patha); rgn2 = new Region (pathb); rgn1.Exclude (rgn2); dc.FillRegion (Brushes.Blue, rgn1); dc.DrawString ("Exclude (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 140, 140); dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix)); x += 110; /* Third*/ patha.Reset (); pathb.Reset (); patha.AddLine (60+x, 40, 90+x, 90); patha.AddLine (90+x, 90, 10+x, 90); patha.AddLine (10+x, 90, 60+x, 40); dc.DrawPath (redPen, patha); pathb.AddEllipse (30+x, 55, 60, 60); dc.DrawPath (redPen, pathb); rgn1 = new Region (patha); rgn2 = new Region (pathb); rgn1.Intersect (rgn2); dc.FillRegion (Brushes.Blue, rgn1); dc.DrawString ("Intersect (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 270, 140); dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix)); x += 110; /* Four*/ patha.Reset (); pathb.Reset (); patha.AddLine (60+x, 40, 90+x, 90); patha.AddLine (90+x, 90, 10+x, 90); patha.AddLine (10+x, 90, 60+x, 40); dc.DrawPath (redPen, patha); pathb.AddEllipse (30+x, 55, 60, 60); dc.DrawPath (redPen, pathb); rgn1 = new Region (patha); rgn2 = new Region (pathb); rgn1.Xor (rgn2); dc.FillRegion(Brushes.Blue, rgn1); dc.DrawString ("Xor (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 380, 140); dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix)); x += 110; /* Fifth */ patha.Reset (); pathb.Reset (); patha.AddLine (60+x, 40, 90+x, 90); patha.AddLine (90+x, 90, 10+x, 90); patha.AddLine (10+x, 90, 60+x, 40); dc.DrawPath (redPen, patha); pathb.AddEllipse (30+x, 55, 60, 60); dc.DrawPath (redPen, pathb); rgn1 = new Region (patha); rgn2 = new Region (pathb); rgn1.Union (rgn2); dc.FillRegion(Brushes.Blue, rgn1); dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix)); dc.DrawString ("Union (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 490, 140); bmp.Save("regionsgp.bmp", ImageFormat.Bmp); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { int intRate = 0; e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; Color UseFillColor = new Color(); Color UseBorderColor = new Color(); GraphicsPath ShapePath = new GraphicsPath(); float ptx; float pty; StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; pty = (this.Height - (RadiusOuter * 2)) / 2; intRate = 0; while (!(intRate == MaxRating)) { ptx = intRate * (RadiusOuter * 2 + ShapeGap) + Padding.Left + (ShapeGap / 2); if (PaintRating > intRate) { if (!IsPainting & HighlightRateFill & (PaintRating != intRate + 1)) { UseFillColor = ShapeColorHover; UseBorderColor = ShapeBorderHoverColor; } else if (IsPainting & HighlightRateHover & (PaintRating == intRate + 1)) { UseFillColor = ShapeColorFill; UseBorderColor = ShapeBorderFilledColor; } else { UseFillColor = PaintColor; UseBorderColor = PaintBorderColor; } } else { UseFillColor = ShapeColorEmpty; UseBorderColor = ShapeBorderEmptyColor; } ShapePath.Reset(); Point[] pts; switch (Shape) { case eShape.Star: ShapePath = DrawStar(ptx, pty); break; case eShape.Heart: ShapePath = DrawHeart(ptx, pty); break; case eShape.Square: ShapePath.AddRectangle(new Rectangle((int)ptx, (int)pty, (int)(RadiusOuter * 2), (int)(RadiusOuter * 2))); break; case eShape.Circle: ShapePath.AddEllipse(ptx, pty, RadiusOuter * 2, RadiusOuter * 2); break; case eShape.Diamond: pts = new Point[] { new Point((int)(ptx + RadiusOuter), (int)pty), new Point((int)(ptx + RadiusOuter * 2), (int)(pty + RadiusOuter)), new Point((int)(ptx + RadiusOuter), (int)(pty + RadiusOuter * 2)), new Point((int)ptx, (int)(pty + RadiusOuter)) }; ShapePath.AddPolygon(pts); break; case eShape.Triangle: pts = new Point[] { new Point((int)(ptx + RadiusOuter), (int)pty), new Point((int)(ptx + RadiusOuter * 2), (int)(pty + RadiusOuter * 2)), new Point((int)ptx, (int)(pty + RadiusOuter * 2)) }; ShapePath.AddPolygon(pts); break; } e.Graphics.FillPath(new SolidBrush(UseFillColor), ShapePath); e.Graphics.DrawPath(new Pen(UseBorderColor, ShapeBorderWidth), ShapePath); if (ShapeNumberShow != eShapeNumberShow.None) { if (ShapeNumberShow == eShapeNumberShow.All | (ShapeNumberShow == eShapeNumberShow.RateOnly & PaintRating == intRate + 1)) { e.Graphics.DrawString((intRate + 1).ToString(), ShapeNumberFont, new SolidBrush(ShapeNumberColor), new RectangleF(ShapeNumberIndent.X + ptx, ShapeNumberIndent.Y + pty, RadiusOuter * 2, RadiusOuter * 2), sf); } } intRate += 1; } if (LabelShow) { int R_x = (int)(((RadiusOuter * 2) * (MaxRating)) + LabelIndent + ((ShapeGap) * MaxRating) + Padding.Left); if (IsPainting) { RateLabel.Text = GetLabelText(LabelTypeHover); } else { RateLabel.Text = GetLabelText(LabelTypeText); } RateLabel.Width = (this.Width - R_x); RateLabel.Height = (this.Height); RateLabel.Location = new Point(R_x, 0); } }