From 1a1c8e71fcd14858f595029f089b2d4a00202b32 Mon Sep 17 00:00:00 2001
From: ogi <Administrator@S-OGI-PC>
Date: Fri, 05 Dec 2025 09:24:16 +0900
Subject: [PATCH] プロジェクトファイルを追加。
---
HotelPms.Share.Windows/GraphicsApi/Star.cs | 90 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 90 insertions(+), 0 deletions(-)
diff --git a/HotelPms.Share.Windows/GraphicsApi/Star.cs b/HotelPms.Share.Windows/GraphicsApi/Star.cs
new file mode 100644
index 0000000..40dd2a6
--- /dev/null
+++ b/HotelPms.Share.Windows/GraphicsApi/Star.cs
@@ -0,0 +1,90 @@
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+namespace HotelPms.Share.Windows.GraphicsApi
+{
+ public class Star
+ {
+ /// <summary>
+ /// 画五角星
+ /// </summary>
+ /// <param name="pointed">多少个角</param>
+ /// <param name="e">Graphics参数</param>
+ public static void Draw(int pointed, Graphics g, PointF center, int len1 = 100, int len2 = 50)
+ {
+ g.SmoothingMode = SmoothingMode.AntiAlias; //使绘图质量最高,即消除锯齿
+ //g.SmoothingMode = SmoothingMode.HighQuality;//对图片进行平滑处理
+ g.InterpolationMode = InterpolationMode.HighQualityBicubic; //设置图像呈现的质量
+ g.CompositingQuality = CompositingQuality.HighQuality;
+
+ Pen p = new Pen(Color.Red);//画笔的颜色
+ double[] angles1 = GetAngles(-Math.PI / 2, pointed);//五角星外围的点角度的一个数组
+ double[] angles2 = GetAngles(-Math.PI / 2 + Math.PI / pointed, pointed);//五角星内围的点角度的一个数组
+ PointF[] points1 = GetPoints(center, len1, angles1);//五角星外围的点的一个数组
+ PointF[] points2 = GetPoints(center, len2, angles2);//五角星内围的点的一个数组
+ PointF[] points = new PointF[points1.Length + points2.Length];//最终合成多边形所有点的数组
+ for (int i = 0, j = 0; i < points.Length; i += 2, j++)
+ {
+ points[i] = points1[j];
+ points[i + 1] = points2[j];
+ }
+ g.DrawPolygon(p, points);//画一个多边形
+ g.FillPolygon(Brushes.Gold, points);//填充颜色
+ }
+ /// <summary>
+ /// 获得所有角度的数组
+ /// </summary>
+ /// <param name="startAngle">开始的角度</param>
+ /// <param name="pointed">个数</param>
+ /// <returns></returns>
+ public static double[] GetAngles(double startAngle, int pointed)
+ {
+ double[] angles = new double[pointed];
+ angles[0] = startAngle;
+ for (int i = 1; i < angles.Length; i++)
+ {
+ angles[i] = angles[i - 1] + GetAngleLength(pointed);
+ }
+ return angles;
+ }
+ /// <summary>
+ /// 获得角度的增量
+ /// </summary>
+ /// <param name="pointed"></param>
+ /// <returns></returns>
+ public static double GetAngleLength(int pointed)
+ {
+ return 2 * Math.PI / pointed;
+ }
+
+
+ /// <summary>
+ /// 获得五角星的各个点
+ /// </summary>
+ /// <param name="ptCenter">中心点坐标</param>
+ /// <param name="length">距离中心点的长度</param>
+ /// <param name="angle">和水平方向的夹角</param>
+ /// <returns></returns>
+ public static PointF GetPoint(PointF ptCenter, double length, double angle)
+ {
+ return new PointF((float)(ptCenter.X + length * Math.Cos(angle)), (float)(ptCenter.Y + length * Math.Sin(angle)));
+ }
+ /// <summary>
+ /// 返回一个坐标的数组
+ /// </summary>
+ /// <param name="ptCenter">中心点</param>
+ /// <param name="length">距离中心点的长度</param>
+ /// <param name="angles">两点之间的夹角</param>
+ /// <returns></returns>
+ public static PointF[] GetPoints(PointF ptCenter, double length, params double[] angles)
+ {
+ PointF[] points = new PointF[angles.Length];
+ for (int i = 0; i < points.Length; i++)
+ {
+ points[i] = GetPoint(ptCenter, length, angles[i]);
+ }
+ return points;
+ }
+ }
+}
--
Gitblit v1.10.0