Exemplo n.º 1
0
        private void BezierRatioDrawer_MouseMove(object sender, MouseEventArgs e)
        {
            float x = e.X, y = e.Y;

            if (x < 0)
            {
                x = 0;
            }
            if (x > this.Width)
            {
                x = this.Width;
            }
            if (y < 0)
            {
                y = 0;
            }
            if (y > this.Height)
            {
                y = this.Height;
            }

            var mousepos = new PointF(x, y);

            if (selected != null)
            {
                if (selected == bcps[0])
                {
                    var f  = new PointF(mousepos.X - selected.Second.X, mousepos.Y - selected.Second.Y);
                    var nv = BezierCaliculate.GetNormalizePoint(f);
                    selected.ThirdDirection = nv;
                    selected.ThirdLength    = GetLength(f);
                    IsLinear = false;
                    DrawandRefresh();
                }
                else if (selected == bcps[1])
                {
                    var f  = new PointF(mousepos.X - selected.Second.X, mousepos.Y - selected.Second.Y);
                    var nv = BezierCaliculate.GetNormalizePoint(f);
                    selected.FirstDirection = nv;
                    selected.FirstLength    = GetLength(f);
                    IsLinear = false;
                    DrawandRefresh();
                }
            }
        }
Exemplo n.º 2
0
        private PointF GetNormalizePoint(PointF p1, PointF p2)
        {
            var temp = new PointF(p1.X + p2.X, p1.Y + p2.Y);

            return(BezierCaliculate.GetNormalizePoint(temp));
        }