Beispiel #1
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);
                }
            }
        }
Beispiel #2
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();
        }
Beispiel #3
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);
        }
Beispiel #4
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();
        }
Beispiel #5
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);
        }
Beispiel #6
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();
        }
Beispiel #7
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);
        }
Beispiel #8
0
        public void TaiJi()
        {
            var taiji = new TaiJi();

            taiji.CreateTaiJiImage();
        }
Beispiel #9
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();
        }