Exemplo n.º 1
0
        public GradientDemo()
        {
            //solid brush
            _solidBrush = new SolidBrush(Color.Blue);

            //1. linear gradient
            _linearGrBrush = new LinearGradientBrush(
                new PointF(0, 0), new PointF(200, 200),
                new ColorStop[]
            {
                new ColorStop(0.0f, Drawing.Color.Black),
                new ColorStop(0.20f, Drawing.Color.Red),
                new ColorStop(0.50f, Drawing.KnownColors.OrangeRed),
                new ColorStop(0.75f, Drawing.Color.Yellow)
            });


            //2. circular gradient
            _circularGrBrush = new RadialGradientBrush(
                new PointF(50, 20), new PointF(300, 20),
                new ColorStop[]
            {
                //for test different colors
                new ColorStop(0.0f, Drawing.Color.Yellow),
                new ColorStop(0.25f, Drawing.Color.Blue),
                new ColorStop(0.50f, Drawing.Color.Green),
                new ColorStop(0.75f, Drawing.Color.Yellow),
            });



            //3. polygon gradient: this version, just a simple rect

            //PolygonGradientBrush.ColorVertex2d[] vertices = new PolygonGradientBrush.ColorVertex2d[]
            // {
            //        new PolygonGradientBrush.ColorVertex2d(5,50,KnownColors.OrangeRed),
            //        new PolygonGradientBrush.ColorVertex2d(50,50,Color.Black),
            //        new PolygonGradientBrush.ColorVertex2d(50,5,Color.Yellow),
            //        new PolygonGradientBrush.ColorVertex2d(5,5,Color.Blue),
            // };
            //PolygonGradientBrush.ColorVertex2d[] vertices = new PolygonGradientBrush.ColorVertex2d[]
            //{
            //        new PolygonGradientBrush.ColorVertex2d(5,300,KnownColors.OrangeRed),
            //        new PolygonGradientBrush.ColorVertex2d(300,300,Color.Black),
            //        new PolygonGradientBrush.ColorVertex2d(300,5,Color.Yellow),
            //        new PolygonGradientBrush.ColorVertex2d(5,5,Color.Blue),
            //};
            //PolygonGradientBrush.ColorVertex2d[] vertices = new PolygonGradientBrush.ColorVertex2d[]
            //{
            //    new PolygonGradientBrush.ColorVertex2d(5,5,Color.Blue),
            //    new PolygonGradientBrush.ColorVertex2d(220,5,Color.Yellow),
            //    new PolygonGradientBrush.ColorVertex2d(220,100,Color.Black),
            //    new PolygonGradientBrush.ColorVertex2d(5,220,KnownColors.OrangeRed),
            //};
            PolygonGradientBrush.ColorVertex2d[] vertices = new PolygonGradientBrush.ColorVertex2d[]
            {
                new PolygonGradientBrush.ColorVertex2d(0, 0, Color.Blue),
                new PolygonGradientBrush.ColorVertex2d(300, 0, Color.Yellow),
                new PolygonGradientBrush.ColorVertex2d(300, 300, Color.Black),
                new PolygonGradientBrush.ColorVertex2d(0, 300, KnownColors.OrangeRed),
            };
            _polygonGradientBrush = new PolygonGradientBrush(vertices);

            using (Tools.BorrowVxs(out var v1, out var v2))
                using (Tools.BorrowPathWriter(v1, out PathWriter p))
                {
                    p.MoveTo(0, 0);
                    p.LineTo(50, 20);
                    p.LineTo(10, 100);
                    p.CloseFigure();

                    AffineMat aff1 = AffineMat.GetScaleMat(2);
                    _triangleVxs = v1.CreateTrim(aff1);

                    AffineMat tx = AffineMat.GetTranslateMat(200, 220);
                    _triangleVxs2 = tx.TransformToVxs(_triangleVxs, v2).CreateTrim();
                }
        }
Exemplo n.º 2
0
 public override void Init()
 {
     //actualImage2 = LoadImage(RootDemoPath.Path + "\\plain01.png");
     _memBmp = LoadImage(RootDemoPath.Path + "\\02.jpg");
     _mat    = AffineMat.GetTranslateMat(50, 50);
 }