private void btn_generate_Click(object sender, EventArgs e) { m_gp = Graphics.FromImage(pB_display.Image); m_gp.FillRectangle(Brushes.White, 0, 0, pB_display.Width, pB_display.Height); m_pen.Color = Color.Red; int count = Int32.Parse(tB_approxPoints.Text); List <PointF> exactPath = MyCurve.CreateExactPath(m_pathPoints, Int32.Parse(tB_exactPathMin.Text), Int32.Parse(tB_exactPathMax.Text)); //PointF one = new PointF(exactPath[0].X, exactPath[0].Y); //PointF two = new PointF(exactPath[1].X, exactPath[1].Y); //PointF last = new PointF(exactPath[exactPath.Count - 1].X, exactPath[exactPath.Count - 1].Y); //PointF beforeLast = new PointF(exactPath[exactPath.Count - 2].X, exactPath[exactPath.Count - 2].Y); //exactPath.Insert(0, new PointF(one.X - (two.X - one.X), one.Y - (two.Y - one.Y))); //exactPath.Add(new PointF(last.X + (last.X - beforeLast.X), last.Y + (last.Y - beforeLast.Y))); List <PointF> generated = MyCurve.GenerateFalseCurve(exactPath); //List<PointF> generated = MyCurve.GenerateCurve(exactPath); //List<PointF> bezierCurve = MyCurve.CreateBezierCurve(m_pathPoints); List <PointF> approxPoints = MyCurve.ApproximateWithPoints(generated, count); if (cB_originalCurve.Checked) { DrawLine(m_pathPoints, m_pen, true); } if (cB_curvePoints.Checked) { DrawLine(m_pathPoints, new Pen(Brushes.Yellow, 4), false); } //if (cB_bezierCurve.Checked) // DrawLine(bezierCurve, new Pen(Brushes.Blue, 2), true); if (cB_generated.Checked) { DrawLine(generated, new Pen(Brushes.Blue, 4), false); } if (cB_exactPath.Checked) { DrawLine(exactPath, new Pen(Brushes.Black, 4), false); } if (cB_approxPoints.Checked) { DrawLine(approxPoints, new Pen(Brushes.Green, 2), true); } pB_display.Invalidate(); m_gp.Dispose(); }
private void RedrawAll() { m_gp = Graphics.FromImage(pB_display.Image); m_gp.FillRectangle(Brushes.White, 0, 0, pB_display.Width, pB_display.Height); m_pen.Color = Color.Red; int count = Int32.Parse(tB_approxPoints.Text); List <PointF> bezierCurve = MyCurve.CreateBezierCurve(m_pathPoints); List <PointF> approxPoints = MyCurve.ApproximateWithPoints(m_pathPoints, count); List <PointF> exactPath = MyCurve.CreateExactPath(m_pathPoints, Int32.Parse(tB_exactPathMin.Text), Int32.Parse(tB_exactPathMax.Text)); if (cB_originalCurve.Checked) { DrawLine(m_pathPoints, m_pen, true); DrawLine(m_pathPoints, new Pen(Brushes.Black, 8), false); } if (cB_curvePoints.Checked) { DrawLine(m_pathPoints, new Pen(Brushes.Yellow, 4), false); } if (cB_bezierCurve.Checked) { DrawLine(bezierCurve, new Pen(Brushes.Blue, 2), true); } if (cB_approxPoints.Checked) { DrawLine(approxPoints, new Pen(Brushes.Green, 6), false); } if (cB_exactPath.Checked) { DrawLine(exactPath, new Pen(Brushes.Black, 4), false); } pB_display.Invalidate(); m_gp.Dispose(); }