Exemple #1
0
        public override IPoint GetPoint(double t)
        {
            IPoint p = new Point();
            double x = (1 - t) * a.GetX() + t * b.GetX();
            double y = (1 - t) * a.GetY() + t * b.GetY();

            p.SetX(x);
            p.SetY(y);

            return(p);
        }
Exemple #2
0
        public override IPoint GetPoint(double t)
        {
            IPoint p = new Point();
            double x = 0, y = 0;

            x = Math.Pow((1 - t), 3) * a.GetX() + 3 * t * Math.Pow((1 - t), 2) * b.GetX() + 3 * Math.Pow(t, 2) * (1 - t) * c.GetX() + Math.Pow(t, 3) * d.GetX();
            y = Math.Pow((1 - t), 3) * a.GetY() + 3 * t * Math.Pow((1 - t), 2) * b.GetY() + 3 * Math.Pow(t, 2) * (1 - t) * c.GetY() + Math.Pow(t, 3) * d.GetY();

            p.SetX(x);
            p.SetY(y);

            return(p);
        }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            //---draw Line
            IPoint start = new Geometry.Point();

            start.SetX(50);
            start.SetY(350);
            IPoint startForFragment = new Geometry.Point();

            startForFragment.SetX(50);
            startForFragment.SetY(320);
            IPoint finish = new Geometry.Point();

            finish.SetX(300);
            finish.SetY(100);
            IPoint finishForFragment = new Geometry.Point();

            finishForFragment.SetX(300);
            finishForFragment.SetY(80);

            ICurve curveL      = new Line(start, finish);
            ICurve curveLforFr = new Line(startForFragment, finishForFragment);
            //Fragment fr = new Fragment(1, 0, curveLforFr);
            Fragment fr = new Fragment(1, 0.5, curveLforFr);

            VisualCurve vCurveL      = new VisualCurve(curveL);
            VisualCurve vCurveLforFr = new VisualCurve(fr);
            //---draw Line in Form
            Drawer drawer = new Drawer(gr, (Brush)Brushes.Blue);
            //vCurveL.Draw(drawer);

            //---print to Console values
            Writer writer = new Writer();

            vCurveL.Draw(writer);

            //---draw shadow by decorator
            Drawer          shadowDrawer     = new Drawer(gr, (Brush)Brushes.Gray);
            DecoratorShadow decoratorShadowL = new Visual.DecoratorShadow(vCurveL, shadowDrawer);

            decoratorShadowL.Draw(drawer);

            DecoratorShadow decoratorShadowLforFr = new Visual.DecoratorShadow(vCurveLforFr, shadowDrawer);

            decoratorShadowLforFr.Draw(drawer);

            //-----------------

            //---draw Bezier
            IPoint a = new Geometry.Point();

            a.SetX(150);
            a.SetY(400);
            IPoint b = new Geometry.Point();

            b.SetX(450);
            b.SetY(150);
            IPoint c = new Geometry.Point();

            c.SetX(100);
            c.SetY(50);
            IPoint d = new Geometry.Point();

            d.SetX(350);
            d.SetY(400);

            ICurve curveB = new Bezier(a, b, c, d);

            VisualCurve vCurveB = new VisualCurve(curveB);

            //vCurveB.Draw(drawer);

            //---print to Console values
            vCurveB.Draw(writer);

            //---draw shadow by decorator
            DecoratorShadow decoratorShadowB = new Visual.DecoratorShadow(vCurveB, shadowDrawer);

            decoratorShadowB.Draw(drawer);
            //-----------------
        }