Example #1
0
        public void BaGua()
        {
            var pointf = new PointF(500, 500);
            var ba     = new BaguaCoordinateSystem(pointf, 300);

            ba.CreateBaGuaImage("CreateBaGuaImage.png");
        }
Example #2
0
        public void CircleBuaGuaByPointF(Graphics graph, PointF o, int r, int taiji = 250, bool istaiji = true, bool isXian = true)
        {
            var ba        = new BaguaCoordinateSystem(o, r);
            var listColor = new List <Color>()
            {
                Color.White, Color.Black, Color.Red, Color.Yellow, Color.Blue, Color.Gold
            };

            if (istaiji)
            {
                TaiJi taiJi = new TaiJi();


                var r1 = new Random();
                var c1 = r1.Next(0, 100);

                taiJi.CreateTaiJiImage(o, graph, listColor[c1 % 5], listColor[c1 % 5 + 1], taiji);
            }

            if (isXian)
            {
                for (int i = 0; i < ba.XianTianBaGuYaoRectangleF.Count; i++)
                {
                    graph.FillPolygon(new SolidBrush(listColor[i % 6]), ba.XianTianBaGuYaoRectangleF[i].FillPolygonPointF, FillMode.Alternate);
                }
            }
            else
            {
                for (int i = 0; i < ba.HoutTianBaGuaYaoRectangleF.Count; i++)
                {
                    graph.FillPolygon(new SolidBrush(listColor[i % 6]), ba.HoutTianBaGuaYaoRectangleF[i].FillPolygonPointF, FillMode.Alternate);
                }
            }
        }
Example #3
0
        public void WordMatrix(RotateFlipType rotateFlipType, string fileName)
        {
            Bitmap image = new Bitmap(1000, 1000);
            var    o     = new PointF()
            {
                X = 500, Y = 500
            };
            var      ba    = new BaguaCoordinateSystem(o, 300);
            Graphics graph = Graphics.FromImage(image);
            //底色填充为白色
            Brush white = new SolidBrush(Color.White);

            graph.FillRectangle(white, new Rectangle(0, 0, image.Width, image.Height));

            for (int i = 0; i <= 90; i += 10)
            {
                Font   font   = new Font("宋体", 50, GraphicsUnit.Pixel);
                var    pointF = new PointF(0, 0).CirclePointF(i, 200);
                Matrix matrix = graph.Transform;
                SizeF  sf     = graph.MeasureString("中", font); // 计算出来文字所占矩形区域
                matrix.RotateAt(i, new PointF(pointF.X + sf.Width / 2, pointF.Y + sf.Height / 2));

                //matrix.Rotate(i);
                graph.DrawLine(Pens.Black, 0, 0, 800, 0);
                graph.DrawString("中", font, Brushes.Red, new RectangleF(800, 0, sf.Width, sf.Height));
                //graph.TranslateTransform(500, 500);

                graph.Transform = matrix;
            }
            image.RotateFlip(rotateFlipType);
            image.Save(fileName + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
        }
Example #4
0
        public void MatrixTest()
        {
            Bitmap image = new Bitmap(1000, 1000);
            var    o     = new PointF()
            {
                X = 500, Y = 500
            };
            var      ba         = new BaguaCoordinateSystem(o, 300);
            Graphics graph      = Graphics.FromImage(image);
            var      leftSPoint = o;

            var guaList = new List <DanGua>()
            {
                new Xun(leftSPoint),
                new Kan(leftSPoint),
                new Gen(leftSPoint),
                new Kun(leftSPoint),
                new Zhen(leftSPoint),
                new Li(leftSPoint),
                new Dui(leftSPoint),
                new Qian(leftSPoint),
            };



            for (int i = 0; i < 8; i++)
            {
                Matrix matrix = graph.Transform;


                Font  font   = new Font("宋体", 100, GraphicsUnit.Pixel);
                var   pointF = new PointF(500, 500).CirclePointF(90, 200);
                SizeF sf     = graph.MeasureString(guaList[i].Name, font); // 计算出来文字所占矩形区域
                                                                           //matrix.RotateAt(45, pointF);
                graph.FillEllipse(Brushes.Red, new RectangleF(new PointF(0, 0), new SizeF()
                {
                    Width = 10, Height = 10
                }));
                graph.FillEllipse(Brushes.Blue, new RectangleF(o, new SizeF(10, 10)));
                matrix.RotateAt(45, new PointF()
                {
                    X = 500, Y = 500
                });
                graph.Transform = matrix;
                var rf = new RectangleF(500 - sf.Width / 2, 100 - sf.Height / 2, sf.Width, sf.Height);
                graph.FillRectangle(Brushes.Gray, rf);
                graph.DrawLine(Pens.Red, 500, 500, 500, 100);
                graph.DrawString(guaList[i].Name, font, Brushes.Red, new RectangleF(500 - sf.Width / 2, 100 - sf.Height / 2, sf.Width, sf.Height));
            }



            //graph.TranslateTransform(500, 500);



            image.Save("mat.bmp");
        }
Example #5
0
        public void BaGuaTest()
        {
            var o = new PointF()
            {
                X = 500, Y = 500
            };
            var ba = new BaguaCoordinateSystem(o, 300);

            TaiJi taiJi = new TaiJi();

            Bitmap image = new Bitmap(1000, 1000);

            Graphics graph = Graphics.FromImage(image);
            //µ×É«Ìî³äΪ°×É«
            Brush white = new SolidBrush(Color.Green);

            graph.FillRectangle(white, new Rectangle(0, 0, image.Width, image.Height));

            taiJi.CreateTaiJiImage(o, graph, Color.White, Color.Black, 250);
            var angle = 45;

            //for (int i = 0; i < ba.XianTianBaGua.Count; i++)
            //{
            //    var dg = ba.XianTianBaGua[i];
            //    graph.DrawString(dg.Name, new Font("ËÎÌå", 25), Brushes.Red, o.CirclePointF((8 - i) * angle, 200));
            //}


            List <RectangleF> rList = new List <RectangleF>();

            for (int i = 0; i < ba.XianTianBaGua.Count; i++)
            {
                var dg = ba.XianTianBaGua[i];
                rList.AddRange(dg.RectangleList);
                graph.DrawString(dg.Name, new Font("ËÎÌå", 25), Brushes.Red, o.CirclePointF((8 - i) * angle, 250));
            }


            //foreach (var item in ba.XianTianBaGua)
            //{
            //    rList.AddRange(item.RectangleList);
            //}
            Pen pen = new Pen(Brushes.Red);

            //graph.DrawEllipse(pen, 500, 500, 200, 200);//»­ÍÖÔ²µÄ·½·¨£¬x×ø±ê¡¢y×ø±ê¡¢¿í¡¢¸ß£¬Èç¹ûÊÇ100£¬Ôò°ë¾¶Îª50
            graph.DrawRectangles(pen, rList.ToArray());
            graph.FillRectangles(Brushes.Red, rList.ToArray());
            //graph.DrawString(danGua.Name, new Font("ËÎÌå", 12), Brushes.Red, new PointF(danGua.GuaRectangle.Width + 20, danGua.GuaRectangle.Height / 2));
            image.Save("graph_" + "BaGua" + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
            graph.Clear(Color.Azure);

            graph.Dispose();
        }
Example #6
0
        public void Angle()
        {
            Bitmap   image = new Bitmap(1000, 1000);
            Graphics graph = Graphics.FromImage(image);
            Brush    white = new SolidBrush(Color.White);

            graph.FillRectangle(white, new Rectangle(0, 0, image.Width, image.Height));

            var o = new PointF()
            {
                X = 500, Y = 500
            };
            var ba    = new BaguaCoordinateSystem(o, 200);
            var angle = 45;

            //µ×É«Ìî³äΪ°×É«
            graph.FillRectangle(white, new Rectangle(0, 0, image.Width, image.Height));

            var leftSPoint = new PointF(880, 400);

            TaiJi taiJi = new TaiJi();

            taiJi.CreateTaiJiImage(o, graph, Color.YellowGreen, Color.YellowGreen, 450);
            taiJi.CreateTaiJiImage(o, graph, Color.BlanchedAlmond, Color.BlanchedAlmond, 300);

            var temprec = new RectangleF(leftSPoint, new SizeF(30, 200));

            temprec          = ba.XianTianBaGua[0].GuaRectangle;
            temprec.Location = leftSPoint;
            for (int i = 0; i < ba.XianTianBaGua.Count; i++)
            {
                //if (i == 0) continue;

                var ang = (8 - i) * angle;

                var ps = o.RectangularRotationForCircleCentPointF(ang, temprec);

                graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

                graph.FillPolygon(Brushes.Red, ps, FillMode.Alternate);
                graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;

                var dg = ba.XianTianBaGua[i];

                graph.DrawString(dg.Name, new Font("ËÎÌå", 25), Brushes.Red, o.CirclePointF((8 - i) * angle, 350));
            }

            image.Save("graph_ang.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
        }
Example #7
0
        public void CircleBuGuaTest()
        {
            Bitmap image = new Bitmap(4000, 4000);
            var    o     = new PointF()
            {
                X = 2000, Y = 2000
            };
            var      ba    = new BaguaCoordinateSystem(o, 300);
            Graphics graph = Graphics.FromImage(image);
            //底色填充为白色
            Brush white = new SolidBrush(Color.Green);

            graph.FillRectangle(white, new Rectangle(0, 0, image.Width, image.Height));

            CircleBuaGuaByPointF(graph, o, 500, 450);


            for (int i = 0; i < 8; i++)
            {
                var pointF = o.CirclePointF((8 - i) * 45, 1000);

                CircleBuaGuaByPointF(graph, pointF, 300, 250, i % 2 == 0, i % 2 == 1);

                //graph.DrawString(ba.XianTianBaGua[i].Name, new Font("宋体", 25), Brushes.Red, o.CirclePointF((8 - i) * 45, 350));
            }

            CircleBuaGuaByPointF(graph, o, 1500, 250, false, false);
            CircleBuaGuaByPointF(graph, o, 1600, 250, false);
            CircleBuaGuaByPointF(graph, o, 1700, 250, false);
            CircleBuaGuaByPointF(graph, o, 1800, 250, false, false);

            //for (int i = 0; i < ba.HoutTianBaGuaYaoRectangleF.Count; i++)
            //{

            //    graph.FillPolygon(new SolidBrush(listColor[i % 6]), ba.HoutTianBaGuaYaoRectangleF[i].FillPolygonPointF, FillMode.Alternate);
            //}

            //for (int i = 0; i < bah.XianTianBaGuYaoRectangleF.Count; i++)
            //{

            //    graph.FillPolygon(new SolidBrush(listColor[i % 6]), bah.XianTianBaGuYaoRectangleF[i].FillPolygonPointF, FillMode.Alternate);
            //}



            image.Save("graph_CircleTest123.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
        }
Example #8
0
        private static void CreateTaijiBaGuaByColor(int imageWidth, Color color, Color leftColor, Color rightColor, string fileName = "graph_" + "BaGua")
        {
            var o = new Point()
            {
                X = imageWidth / 2, Y = imageWidth / 2
            };
            var ba = new BaguaCoordinateSystem(o, imageWidth / 3);

            TaiJi taiJi = new TaiJi();

            Bitmap image = new Bitmap(imageWidth, imageWidth);

            Graphics graph = Graphics.FromImage(image);
            //底色填充为白色
            Brush white = new SolidBrush(color);

            graph.FillRectangle(white, new Rectangle(0, 0, image.Width, image.Height));

            taiJi.CreateTaiJiImage(o, graph, leftColor, rightColor, imageWidth / 4);


            List <RectangleF> rList = new List <RectangleF>();

            foreach (var item in ba.XianTianBaGua)
            {
                rList.AddRange(item.RectangleList);
            }

            Pen pen = new Pen(new SolidBrush(leftColor));

            //graph.DrawEllipse(pen, 500, 500, 200, 200);//画椭圆的方法,x坐标、y坐标、宽、高,如果是100,则半径为50
            graph.DrawRectangles(pen, rList.ToArray());
            graph.FillRectangles(new SolidBrush(rightColor), rList.ToArray());
            //graph.DrawString(danGua.Name, new Font("宋体", 12), Brushes.Red, new PointF(danGua.GuaRectangle.Width + 20, danGua.GuaRectangle.Height / 2));
            image.Save(fileName + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
            graph.Clear(Color.Azure);

            graph.Dispose();
        }
Example #9
0
        public void BaGuaCircle()
        {
            Bitmap image = new Bitmap(1500, 1500);
            var    o     = new PointF()
            {
                X = 750, Y = 750
            };
            var      ba    = new BaguaCoordinateSystem(o, 300);
            var      bah   = new BaguaCoordinateSystem(o, 400);
            var      angle = 45;
            Graphics graph = Graphics.FromImage(image);
            //µ×É«Ìî³äΪ°×É«
            Brush white = new SolidBrush(Color.Green);

            graph.FillRectangle(white, new Rectangle(0, 0, image.Width, image.Height));
            TaiJi taiJi = new TaiJi();

            taiJi.CreateTaiJiImage(o, graph, Color.Black, Color.White, 250);

            var listColor = new List <Color>()
            {
                Color.White, Color.Black, Color.Red, Color.Yellow, Color.Blue, Color.Gold
            };

            for (int i = 0; i < ba.HoutTianBaGuaYaoRectangleF.Count; i++)
            {
                graph.FillPolygon(new SolidBrush(listColor[i % 6]), ba.HoutTianBaGuaYaoRectangleF[i].FillPolygonPointF, FillMode.Alternate);
            }

            for (int i = 0; i < bah.XianTianBaGuYaoRectangleF.Count; i++)
            {
                graph.FillPolygon(new SolidBrush(listColor[i % 6]), bah.XianTianBaGuYaoRectangleF[i].FillPolygonPointF, FillMode.Alternate);
            }



            image.Save("graph_CircleTest123.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
        }
Example #10
0
        public void BaGuaTest()
        {
            var o = new Point()
            {
                X = 500, Y = 500
            };
            var ba = new BaguaCoordinateSystem(o, 300);

            TaiJi taiJi = new TaiJi();

            Bitmap image = new Bitmap(1000, 1000);

            Graphics graph = Graphics.FromImage(image);
            //底色填充为白色
            Brush white = new SolidBrush(Color.Green);

            graph.FillRectangle(white, new Rectangle(0, 0, image.Width, image.Height));

            taiJi.CreateTaiJiImage(o, graph, Color.White, Color.Black, 250);


            List <RectangleF> rList = new List <RectangleF>();

            foreach (var item in ba.XianTianBaGua)
            {
                rList.AddRange(item.RectangleList);
            }
            Pen pen = new Pen(Brushes.Red);

            //graph.DrawEllipse(pen, 500, 500, 200, 200);//画椭圆的方法,x坐标、y坐标、宽、高,如果是100,则半径为50
            graph.DrawRectangles(pen, rList.ToArray());
            graph.FillRectangles(Brushes.Red, rList.ToArray());
            //graph.DrawString(danGua.Name, new Font("宋体", 12), Brushes.Red, new PointF(danGua.GuaRectangle.Width + 20, danGua.GuaRectangle.Height / 2));
            image.Save("graph_" + "BaGua" + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
            graph.Clear(Color.Azure);

            graph.Dispose();
        }
Example #11
0
        public void CircleTest()
        {
            Bitmap image = new Bitmap(1000, 1000);
            var    o     = new PointF()
            {
                X = 500, Y = 500
            };
            var      ba    = new BaguaCoordinateSystem(o, 300);
            var      angle = 45;
            Graphics graph = Graphics.FromImage(image);
            //µ×É«Ìî³äΪ°×É«
            Brush white = new SolidBrush(Color.Green);

            graph.FillRectangle(white, new Rectangle(0, 0, image.Width, image.Height));

            for (int i = 0; i < ba.XianTianBaGua.Count; i++)
            {
                var dg = ba.XianTianBaGua[i];
                graph.DrawString(dg.Name, new Font("ËÎÌå", 25), Brushes.Red, o.CirclePointF((8 - i) * angle, 250));
            }

            image.Save("graph_CircleTest.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
        }
Example #12
0
        public void WordBuguaTest()
        {
            Bitmap image = new Bitmap(1000, 1000);
            var    o     = new PointF()
            {
                X = 500, Y = 500
            };
            var      ba    = new BaguaCoordinateSystem(o, 300);
            Graphics graph = Graphics.FromImage(image);
            //底色填充为白色
            Brush white = new SolidBrush(Color.Green);

            graph.FillRectangle(white, new Rectangle(0, 0, image.Width, image.Height));

            //CircleBuaGuaByPointF(graph, o, 500, 450);



            //SizeF sf = graph.MeasureString("中国", font); // 计算出来文字所占矩形区域

            //var aa = o.CirclePointF(225, 350);
            //matrix.RotateAt(45+90+180, new PointF(aa.X + sf.Width / 2, aa.Y + sf.Height / 2));
            //graph.Transform = matrix;

            //graph.DrawString("中国", font, new SolidBrush(Color.Black), aa);


            var    pointF = o.CirclePointF(0, 350);
            SizeF  sf     = graph.MeasureString(ba.XianTianBaGua[0].Name, new Font("宋体", 25)); // 计算出来文字所占矩形区域
            var    rf     = new RectangleF(o.CirclePointF(0, 350), sf);
            Matrix matrix = graph.Transform;

            //matrix.RotateAt(0, new PointF(pointF.X + sf.Width / 2, pointF.Y + sf.Height / 2));
            //////matrix.RotateAt(i * 45, );
            //graph.Transform = matrix;

            //graph.FillRectangle(Brushes.Blue, rf);
            //graph.DrawString(ba.XianTianBaGua[0].Name, new Font("宋体", 25), Brushes.Red, rf);


            //pointF = o.CirclePointF(45, 350);
            //sf = graph.MeasureString(ba.XianTianBaGua[8 - 1].Name, new Font("宋体", 25)); // 计算出来文字所占矩形区域
            //rf = new RectangleF(o.CirclePointF(45, 350), sf);
            //matrix = graph.Transform;

            //matrix.RotateAt(90 + 45, new PointF(pointF.X + sf.Width / 2, pointF.Y + sf.Height / 2));
            //////matrix.RotateAt(i * 45, );
            //graph.Transform = matrix;

            //graph.FillRectangle(Brushes.Blue, rf);
            //graph.DrawString(ba.XianTianBaGua[8 - 1].Name, new Font("宋体", 25), Brushes.Red, rf);

            //pointF = o.CirclePointF(135, 350);
            //sf = graph.MeasureString(ba.XianTianBaGua[8 - 2].Name, new Font("宋体", 25)); // 计算出来文字所占矩形区域
            //rf = new RectangleF(o.CirclePointF(60, 350), sf);
            matrix = graph.Transform;

            matrix.RotateAt(45 * 2, new PointF(pointF.X + sf.Width / 2, pointF.Y + sf.Height / 2));
            ////matrix.RotateAt(i * 45, );
            graph.Transform = matrix;

            graph.FillRectangle(Brushes.Blue, rf);
            graph.DrawString(ba.XianTianBaGua[0].Name, new Font("宋体", 25), Brushes.Red, rf);


            //pointF = o.CirclePointF(, 350);
            //var pointF = o.CirclePointF(45, 100);
            //AddText(graph, pointF, 25, ba.XianTianBaGua[8 - 3].Name, 20);

            // pointF = o.CirclePointF(90, 100);
            //AddText(graph, pointF, 25, ba.XianTianBaGua[8 - 5].Name, 20);

            // pointF = o.CirclePointF(120, 100);
            //AddText(graph, pointF, 25, ba.XianTianBaGua[8 - 6].Name, 20);



            //var pointF = o.CirclePointF((8 - 2) * 45, 300);
            var leftSPoint = pointF;
            var guaList    = new List <DanGua>()
            {
                new Qian(leftSPoint),
                new Xun(leftSPoint),
                new Kan(leftSPoint),
                new Gen(leftSPoint),
                new Kun(leftSPoint),
                new Zhen(leftSPoint),
                new Li(leftSPoint),
                new Dui(leftSPoint),
            };

            //for (int i = 0; i < 2; i++)
            //{
            //    Matrix matrix = graph.Transform;
            //    AddText(graph, pointF, 25, guaList[i].Name, matrix, i * 45);
            //    graph.Transform = matrix;

            //}

            //for (int i = 1; i <= 8; i++)
            //{
            //    //var pointF = o.CirclePointF((8 - i) * 45, 1000);
            //    //Font font = new Font("宋体", 25);
            //    SizeF sf = graph.MeasureString(ba.XianTianBaGua[i-1].Name, new Font("宋体", 25)); // 计算出来文字所占矩形区域

            //    var aa = o.CirclePointF(i*45f, 350);
            //    Matrix matrix = graph.Transform;

            //    //matrix.RotateAt(i*45+135, new PointF(aa.X + sf.Width / 2, aa.Y + sf.Height / 2));
            //    matrix.RotateAt(i*45, aa);

            //    graph.Transform = matrix;

            //    //CircleBuaGuaByPointF(graph, pointF, 300, 250, i % 2 == 0, i % 2 == 1);
            //    var rf = new RectangleF(aa, new SizeF(40, 40));
            //    graph.FillRectangle(Brushes.Blue, rf);
            //    var ss = new StringFormat();
            //    graph.DrawString(ba.XianTianBaGua[i-1].Name, new Font("宋体", 25), Brushes.Red, rf, ss);
            //}

            image.Save("graph_CircleTest123456.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
        }
Example #13
0
        public void AngleRectangle()
        {
            Bitmap   image = new Bitmap(1000, 1000);
            Graphics graph = Graphics.FromImage(image);
            Brush    white = new SolidBrush(Color.White);

            graph.FillRectangle(white, new Rectangle(0, 0, image.Width, image.Height));

            var o = new PointF()
            {
                X = 500, Y = 500
            };
            var ba = new BaguaCoordinateSystem(o, 350);

            //µ×É«Ìî³äΪ°×É«
            graph.FillRectangle(white, new Rectangle(0, 0, image.Width, image.Height));
            TaiJi taiJi = new TaiJi();

            taiJi.CreateTaiJiImage(o, graph, Color.Yellow, Color.Green, 180);

            var leftSPoint = new PointF(450, 250);

            var guaList = new List <DanGua>()
            {
                new Qian(leftSPoint),
                new Xun(leftSPoint),
                new Kan(leftSPoint),
                new Gen(leftSPoint),
                new Kun(leftSPoint),
                new Zhen(leftSPoint),
                new Li(leftSPoint),
                new Dui(leftSPoint),
            };

            for (int i = 1; i <= 8; i++)
            {
                var ang = i * 45 + 135;
                var dg  = guaList[i - 1];
                foreach (var item in dg.RectangleList)
                {
                    var ps = o.RectangularRotationForCircleCentPointF(ang, item);
                    graph.DrawLine(new Pen(Brushes.Red), ps[0], ps[1]);
                    graph.DrawLine(new Pen(Brushes.Black), ps[1], ps[2]);
                    graph.DrawLine(new Pen(Brushes.Blue), ps[2], ps[3]);
                    graph.DrawLine(new Pen(Brushes.Blue), ps[3], ps[0]);
                    graph.FillPolygon(Brushes.Red, ps, FillMode.Alternate);
                }
            }

            for (int i = 0; i < 8; i++)
            {
                graph.DrawString(ba.XianTianBaGua[i].Name, new Font("ËÎÌå", 25), Brushes.Red, o.CirclePointF((8 - i) * 45, 350));
            }


            //var qian = ba.XianTianBaGua;


            //var ps = o.RectangularRotationForCircleCentPointF(45, temprec);
            //var re = ba.XianTianBaGua[0].RectangleList[0];
            //graph.DrawRectangles(new Pen(Brushes.Red), ba.XianTianBaGua[0].RectangleList.ToArray());
            //graph.DrawRectangle(new Pen(Brushes.Red), re.X, re.Y, re.Width, re.Height);

            //graph.DrawLine(new Pen(Brushes.Red), ps[0], ps[1]);
            //graph.DrawLine(new Pen(Brushes.Black), ps[1], ps[2]);
            //graph.DrawLine(new Pen(Brushes.Blue), ps[2], ps[3]);
            //graph.DrawLine(new Pen(Brushes.Blue), ps[3], ps[0]);

            //graph.DrawLines(new Pen(Brushes.Red), ps);

            graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;



            //graph.FillPolygon(Brushes.Red, ps, FillMode.Alternate);
            graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;

            image.Save("graph_ang2.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
        }
Example #14
0
        private static void CreateTaijiBaGuaByColor(int imageWidth, Color color, Color leftColor, Color rightColor, string sFileName = "FW.png", string fileName = "graph_BaGua", bool IXH = true, bool ISS = true)
        {
            var o = new PointF()
            {
                X = imageWidth / 2, Y = imageWidth / 2
            };
            var ba = new BaguaCoordinateSystem(o, imageWidth / 3, ISS);

            TaiJi taiJi = new TaiJi();

            Bitmap image = new Bitmap(imageWidth, imageWidth);

            Graphics graph = Graphics.FromImage(image);
            //µ×É«Ìî³äΪ°×É«
            Brush white = new SolidBrush(color);

            //graph.FillRectangle(white, new Rectangle(0, 0, image.Width, image.Height));
            if (!string.IsNullOrWhiteSpace(sFileName))
            {
                Bitmap bitmap = new Bitmap(sFileName);
                graph.DrawImage(bitmap, new RectangleF(0, 0, image.Width, image.Height));
            }


            taiJi.CreateTaiJiImage(o, graph, leftColor, rightColor, imageWidth / 12);

            var angle = 45;
            List <RectangleF> rList = new List <RectangleF>();

            var dgList = IXH ? ba.XianTianBaGua : ba.HouTianBaGua;

            for (int i = 0; i < dgList.Count; i++)
            {
                var dg = dgList[i];
                rList.AddRange(dg.RectangleList);
                graph.DrawString(dg.Name, new Font("ËÎÌå", 25), Brushes.Red, o.CirclePointF((8 - i) * angle, imageWidth / 4));
                if (IXH)
                {
                    graph.DrawString(dg.InnateNumber.ToString(), new Font("ËÎÌå", 25), Brushes.Red, o.CirclePointF((8 - i) * angle, imageWidth / 5));
                    // graph.DrawString(dg.InnateOrientation.GetDescription().ToString(), new Font("ËÎÌå", 25), Brushes.Red, o.CirclePointF((8 - i) * angle, (float)(imageWidth / 4)));
                }
                else
                {
                    graph.DrawString(dg.NumbersAcquired.ToString(), new Font("ËÎÌå", 25), Brushes.Red, o.CirclePointF((8 - i) * angle, imageWidth / 5));
                    //graph.DrawString(dg.AcquiredAzimuth.GetDescription().ToString(), new Font("ËÎÌå", 25), Brushes.Red, o.CirclePointF((8 - i) * angle, (float)(imageWidth / 4)));
                }
            }

            Pen pen = new Pen(new SolidBrush(leftColor));

            //graph.DrawEllipse(pen, 500, 500, 200, 200);//»­ÍÖÔ²µÄ·½·¨£¬x×ø±ê¡¢y×ø±ê¡¢¿í¡¢¸ß£¬Èç¹ûÊÇ100£¬Ôò°ë¾¶Îª50
            graph.DrawRectangles(pen, rList.ToArray());
            graph.FillRectangles(new SolidBrush(rightColor), rList.ToArray());
            //graph.DrawString(danGua.Name, new Font("ËÎÌå", 12), Brushes.Red, new PointF(danGua.GuaRectangle.Width + 20, danGua.GuaRectangle.Height / 2));
            //Bitmap bitmap = new Bitmap("FW.png");
            //image.alphaImage(bitmap, 100);
            //image.RotateFlip(RotateFlipType.Rotate180FlipNone);
            image.Save(fileName + ".png", System.Drawing.Imaging.ImageFormat.Png);

            graph.Clear(Color.Azure);

            graph.Dispose();
        }