/// <summary> /// 创建六十四卦方圆图 /// </summary> /// <returns></returns> public Bitmap CreateLiuSiGuaRectangleCircelBitmap(Bitmap sourceBitmap, float r) { //计算圆心 var o = new PointF(sourceBitmap.Width / 2, sourceBitmap.Height / 2); var NB = o.CirclePointfForZBC(r) * 2; var fGuaWidth = ((NB / 8) * 4) / 5; var fGuaHeigth = (NB / 8) / 15; var fGuaMidWidth = fGuaWidth / 10; var circleR = r + 6 * fGuaHeigth; CreateLiuSiGuaCircleBitmap(sourceBitmap, (int)fGuaWidth / 2, (int)fGuaMidWidth / 2, (int)fGuaHeigth / 2, (int)circleR); var bitmapRectangle = new Bitmap((int)NB, (int)NB + 20); var rectanglePoint = o.CirclePointF(-135, r); CreateLiuSiguaRectangleBitmap(bitmapRectangle, (int)fGuaWidth, (int)fGuaMidWidth, (int)fGuaHeigth); var graph = Graphics.FromImage(sourceBitmap); graph.DrawImage(bitmapRectangle, rectanglePoint); return(sourceBitmap); }
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(); }
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); }
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); }
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); }
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); }
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); }
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(); }