Beispiel #1
0
        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            var graphics = e.Graphics;

            graphics.SmoothingMode = SmoothingMode.AntiAlias;

            foreach (var vector in vectors)
            {
                graphics.DrawEllipse(Pens.Red, (float)vector.X - 3, (float)vector.Y - 3, 6, 6);
            }

            if (vectors.Count > 2)
            {
                var curve = CatmullRomSpline.Calculate(vectors.ToArray(), (float)trackBar1.Value / 100, trackBar2.Value, checkBox1.Checked);
                for (var i = 0; i < curve.Length - 1; ++i)
                {
                    graphics.DrawLine(Pens.Blue, (float)curve[i].X, (float)curve[i].Y, (float)curve[i + 1].X, (float)curve[i + 1].Y);
                }
                for (var i = 0; i < curve.Length; ++i)
                {
                    graphics.DrawEllipse(Pens.Blue, (float)curve[i].X - 1, (float)curve[i].Y - 1, 2, 2);
                }
            }
        }