// ****** Очистка PictureBox1 цветом, созданным пользователем ** private void Clear_PictureBox(object sender, EventArgs e) { g.Clear(Color.FromArgb(224, 224, 224)); }
//Here comes Drawing private void DrawBitmap(bool justClip = false) { Cursor.Current = Cursors.WaitCursor; try { GenerateFigures(textBox1.Text, textBox2.Text); using (Graphics newgraphic = Graphics.FromImage(mybitmap)) using (GraphicsPath path = new GraphicsPath()) { newgraphic.SmoothingMode = SmoothingMode.AntiAlias; newgraphic.Clear(Color.White); path.FillMode = FillMode.Winding; float scale = trackBar1.Value; PointF[] pts = PolygonToPointFArray(figure1, scale); path.AddPolygon(pts); pts = null; //draw subjects ... using (Pen myPen = new Pen(Color.FromArgb(196, 0xC3, 0xC9, 0xCF), (float)0.6)) using (SolidBrush myBrush = new SolidBrush(Color.FromArgb(127, 0xDD, 0xDD, 0xF0))) { newgraphic.FillPath(myBrush, path); newgraphic.DrawPath(myPen, path); path.Reset(); //draw clips ... path.FillMode = FillMode.Winding; pts = PolygonToPointFArray(figure2, scale); path.AddPolygon(pts); pts = null; myPen.Color = Color.FromArgb(196, 0xEF, 0xBE, 0xA6); myBrush.Color = Color.FromArgb(127, 0xEF, 0xE0, 0xE0); newgraphic.FillPath(myBrush, path); newgraphic.DrawPath(myPen, path); //Minkovski w/ Timer if (numericUpDown1.Value != 0) { solution = Clipper.MinkowskiSum(figure1, figure2, false); for (int i = 0; i < numericUpDown1.Value; i++) { solution = Clipper.SimplifyPolygons(solution); solution = Clipper.MinkowskiSum(figure2, solution, true); } path.FillMode = FillMode.Winding; foreach (Polygon poly in solution) { pts = PolygonToPointFArray(poly, scale); path.AddPolygon(pts); pts = null; } } myPen.Color = Color.FromArgb(196, 0xF9, 0xBE, 0xA6); myBrush.Color = Color.FromArgb(127, 0xFE, 0x04, 0x00); newgraphic.FillPath(myBrush, path); newgraphic.DrawPath(myPen, path); path.Reset(); //Convert Obs to ints int count = Convert.ToInt32(numericUpDown2.Value); cubes = GenerateRandomCubes(count); foreach (Polygon poly in cubes) { pts = PolygonToPointFArray(poly, scale); path.AddPolygon(pts); pts = null; } myPen.Color = Color.FromArgb(196, 0x00, 0x00, 0x00); myBrush.Color = Color.FromArgb(255, 0xFF, 0xFF, 0xFF); newgraphic.FillPath(myBrush, path); newgraphic.DrawPath(myPen, path); path.Reset(); /*------ * Polygons filler = new Polygons(); * Clipper d = new Clipper(); * d.AddPaths(cubes, PolyType.ptSubject, true); * d.AddPaths(cubes, PolyType.ptClip, true); * path.FillMode = FillMode.Winding; * d.Execute(ClipType.ctIntersection, filler, PolyFillType.pftEvenOdd, PolyFillType.pftEvenOdd); * * foreach (Polygon poly in filler) * { * pts = PolygonToPointFArray(poly, scale); * path.AddPolygon(pts); * pts = null; * } * myPen.Color = Color.FromArgb(255, 0xFF, 0xFF, 0xFF); * myBrush.Color = Color.FromArgb(255, 0xFF, 0xFF, 0xFF); * newgraphic.FillPath(myBrush, path); * newgraphic.DrawPath(myPen, path); * path.Reset(); */ //----- Polygons solution_2 = new Polygons(); Clipper c = new Clipper(); c.AddPaths(solution, PolyType.ptSubject, true); c.AddPaths(cubes, PolyType.ptClip, true); path.FillMode = FillMode.Winding; c.Execute(ClipType.ctIntersection, solution_2, PolyFillType.pftEvenOdd, PolyFillType.pftEvenOdd); foreach (Polygon poly in solution_2) { pts = PolygonToPointFArray(poly, scale); path.AddPolygon(pts); pts = null; } myPen.Color = Color.FromArgb(196, 0x00, 0x00, 0x00); myBrush.Color = Color.FromArgb(255, 0xFF, 0x00, 0xFF); newgraphic.FillPath(myBrush, path); newgraphic.DrawPath(myPen, path); path.Reset(); //------- } } pictureBox1.Image = mybitmap; } finally { Cursor.Current = Cursors.Default; } }
private void button2_Click(object sender, EventArgs e) { g.Clear(Color.Black); pontok.Clear(); }
private void Bt_2man_Click(object sender, EventArgs e) { grs.Clear(panel1.BackColor); crChess.ManVsMan(grs); }