Skip to content

GameUI.Graphics ​

BoxGradientPaint 仅客户端 ​

命名空间 GameUI.Graphics

csharp
public class BoxGradientPaint : GradientPaint

表示在矩形区域内创建渐变的盒式渐变画笔,支持可选的圆角和羽化效果

  • rectangle — 渐变效果的矩形区域
  • cornerRadius — 圆角矩形效果的圆角半径。使用0表示尖角
  • feather — 控制渐变过渡柔和度的羽化距离
  • startColor — 渐变中心的颜色
  • endColor — 渐变边缘的颜色
备注

盒式渐变适用于创建柔和的矩形背景、按钮效果和边框面板。 渐变从指定矩形中心的起始颜色过渡到边缘的结束颜色。 当半径为0时,创建尖锐的矩形渐变。当半径>0时,创建圆角矩形渐变。

构造函数 ​

BoxGradientPaint 仅客户端 ​

csharp
public BoxGradientPaint(RectangleF rectangle, float cornerRadius, float feather, Color startColor, Color endColor)

表示在矩形区域内创建渐变的盒式渐变画笔,支持可选的圆角和羽化效果

  • rectangle — 渐变效果的矩形区域
  • cornerRadius — 圆角矩形效果的圆角半径。使用0表示尖角
  • feather — 控制渐变过渡柔和度的羽化距离
  • startColor — 渐变中心的颜色
  • endColor — 渐变边缘的颜色
备注

盒式渐变适用于创建柔和的矩形背景、按钮效果和边框面板。 渐变从指定矩形中心的起始颜色过渡到边缘的结束颜色。 当半径为0时,创建尖锐的矩形渐变。当半径>0时,创建圆角矩形渐变。

属性 ​

StartColor 仅客户端 ​

csharp
public override Color StartColor { get; }

获取渐变中心的颜色

EndColor 仅客户端 ​

csharp
public override Color EndColor { get; }

获取渐变边缘的颜色

Rectangle 仅客户端 ​

csharp
public RectangleF Rectangle { get; }

获取渐变效果的矩形区域

CornerRadius 仅客户端 ​

csharp
public float CornerRadius { get; }

获取圆角矩形效果的圆角半径

Feather 仅客户端 ​

csharp
public float Feather { get; }

获取控制渐变过渡柔和度的羽化距离

GeometryUtil 仅客户端 ​

命名空间 GameUI.Graphics

csharp
public static class GeometryUtil

提供几何计算和图形变换的实用工具方法

方法 ​

GetDistance 仅客户端 ​

csharp
public static float GetDistance(float x1, float y1, float x2, float y2)

计算两点之间的距离

  • x1 — 第一个点的X坐标
  • y1 — 第一个点的Y坐标
  • x2 — 第二个点的X坐标
  • y2 — 第二个点的Y坐标

返回: 两点之间的欧几里得距离

GetAngleAsDegrees 仅客户端 ​

csharp
public static float GetAngleAsDegrees(float x1, float y1, float x2, float y2)

计算从第一个点到第二个点的角度(以度为单位)

  • x1 — 第一个点的X坐标
  • y1 — 第一个点的Y坐标
  • x2 — 第二个点的X坐标
  • y2 — 第二个点的Y坐标

返回: 角度值(度)

DegreesToRadians 仅客户端 ​

csharp
public static float DegreesToRadians(float angle)

将角度从度转换为弧度

  • angle — 以度为单位的角度

返回: 以弧度为单位的角度

DegreesToRadians 仅客户端 ​

csharp
public static double DegreesToRadians(double angle)

将角度从度转换为弧度(双精度版本)

  • angle — 以度为单位的角度

返回: 以弧度为单位的角度

RadiansToDegrees 仅客户端 ​

csharp
public static float RadiansToDegrees(float angle)

将角度从弧度转换为度

  • angle — 以弧度为单位的角度

返回: 以度为单位的角度

RadiansToDegrees 仅客户端 ​

csharp
public static double RadiansToDegrees(double angle)

将角度从弧度转换为度(双精度版本)

  • angle — 以弧度为单位的角度

返回: 以度为单位的角度

RotatePoint 仅客户端 ​

csharp
public static PointF RotatePoint(PointF point, float angle)

围绕原点旋转点

  • point — 要旋转的点
  • angle — 旋转角度(度)

返回: 旋转后的点

RotatePoint 仅客户端 ​

csharp
public static PointF RotatePoint(PointF center, PointF point, float angle)

围绕指定中心点旋转点

  • center — 旋转中心点
  • point — 要旋转的点
  • angle — 旋转角度(度)

返回: 旋转后的点

GetSweep 仅客户端 ​

csharp
public static float GetSweep(float angle1, float angle2, bool clockwise)

计算弧形扫描角度

  • angle1 — 起始角度
  • angle2 — 结束角度
  • clockwise — 是否顺时针方向

返回: 扫描角度

PolarToPoint 仅客户端 ​

csharp
public static PointF PolarToPoint(float angleInRadians, float fx, float fy)

将极坐标转换为笛卡尔坐标点

  • angleInRadians — 角度(弧度)
  • fx — X轴缩放因子
  • fy — Y轴缩放因子

返回: 转换后的点

EllipseAngleToPoint 仅客户端 ​

csharp
public static PointF EllipseAngleToPoint(float x, float y, float width, float height, float angleInDegrees)

获取椭圆上对应于给定角度的点

  • x — 边界矩形的X位置
  • y — 边界矩形的Y位置
  • width — 边界矩形的宽度
  • height — 边界矩形的高度
  • angleInDegrees — 角度(度)

返回: 椭圆上的点

GetOppositePoint 仅客户端 ​

csharp
public static PointF GetOppositePoint(PointF pivot, PointF oppositePoint)

获取相对于枢轴点的对称点

  • pivot — 枢轴点
  • oppositePoint — 要获取对称点的点

返回: 对称点

IsLineIntersectingLine 仅客户端 ​

csharp
public static bool IsLineIntersectingLine(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3)

检查两条线段是否相交

  • x0 — 第一条线段起点的X坐标
  • y0 — 第一条线段起点的Y坐标
  • x1 — 第一条线段终点的X坐标
  • y1 — 第一条线段终点的Y坐标
  • x2 — 第二条线段起点的X坐标
  • y2 — 第二条线段起点的Y坐标
  • x3 — 第二条线段终点的X坐标
  • y3 — 第二条线段终点的Y坐标

返回: 如果两条线段相交则返回true

GetFactor 仅客户端 ​

csharp
public static float GetFactor(float aMin, float aMax, float aValue)

计算在给定范围内某个值的比例因子

  • aMin — 最小值
  • aMax — 最大值
  • aValue — 当前值

返回: 比例因子(0.0到1.0之间)

GetLinearValue 仅客户端 ​

csharp
public static float GetLinearValue(float aMin, float aMax, float aFactor)

根据比例因子在给定范围内计算线性值

  • aMin — 最小值
  • aMax — 最大值
  • aFactor — 比例因子(0.0到1.0之间)

返回: 计算得出的线性值

字段 ​

Epsilon 仅客户端 ​

csharp
public const float Epsilon

用于浮点数比较的精度常量

DegreesToRadiansConstant 仅客户端 ​

csharp
public const float DegreesToRadiansConstant

角度转弧度的转换常量 (π/180)

RadiansToDegreesConstant 仅客户端 ​

csharp
public const float RadiansToDegreesConstant

弧度转角度的转换常量 (180/π)

GradientPaint 仅客户端 ​

命名空间 GameUI.Graphics

csharp
public abstract class GradientPaint : Paint

表示在多种颜色之间过渡的渐变画笔的抽象基类

备注

渐变画笔创建平滑的颜色过渡,用于高级视觉效果。 派生类包括LinearGradientPaint、RadialGradientPaint和BoxGradientPaint。

构造函数 ​

GradientPaint 仅客户端 ​

csharp
protected GradientPaint()

属性 ​

StartColor 仅客户端 ​

csharp
public abstract Color StartColor { get; }

获取渐变的起始颜色

EndColor 仅客户端 ​

csharp
public abstract Color EndColor { get; }

获取渐变的结束颜色

方法 ​

Apply 仅客户端 ​

csharp
public void Apply(Canvas canvas, PaintApply apply)

将此渐变画笔应用到指定的画布上进行填充或描边操作

  • canvas — 要应用渐变的画布
  • apply — 指定是将渐变应用于填充还是描边操作

LinearGradientPaint 仅客户端 ​

命名空间 GameUI.Graphics

csharp
public class LinearGradientPaint : GradientPaint

表示沿着由起点和终点定义的直线进行颜色过渡的线性渐变画笔

  • startPoint — 线性渐变的起始点
  • endPoint — 线性渐变的结束点
  • startColor — 渐变起始点的颜色
  • endColor — 渐变结束点的颜色

构造函数 ​

LinearGradientPaint 仅客户端 ​

csharp
public LinearGradientPaint(PointF startPoint, PointF endPoint, Color startColor, Color endColor)

表示沿着由起点和终点定义的直线进行颜色过渡的线性渐变画笔

  • startPoint — 线性渐变的起始点
  • endPoint — 线性渐变的结束点
  • startColor — 渐变起始点的颜色
  • endColor — 渐变结束点的颜色

属性 ​

StartPoint 仅客户端 ​

csharp
public PointF StartPoint { get; }

获取线性渐变的起始点

EndPoint 仅客户端 ​

csharp
public PointF EndPoint { get; }

获取线性渐变的结束点

StartColor 仅客户端 ​

csharp
public override Color StartColor { get; }

获取渐变起始点的颜色

EndColor 仅客户端 ​

csharp
public override Color EndColor { get; }

获取渐变结束点的颜色

Paint 仅客户端 ​

命名空间 GameUI.Graphics

csharp
public abstract class Paint

表示可用于填充形状的不同类型画笔的抽象基类

备注

Paint用于Canvas.Fill和Canvas.Stroke方法,而Brush用于控件。

构造函数 ​

Paint 仅客户端 ​

csharp
protected Paint()

属性 ​

IsTransparent 仅客户端 ​

csharp
public virtual bool IsTransparent { get; }

获取一个值,指示此画笔是否具有透明区域

备注

派生类应重写此属性以正确指示其透明度。

方法 ​

implicit operator 仅客户端 ​

csharp
public static Paint implicit operator(Color color)

提供从Color到Paint的隐式转换

  • color — 要转换的颜色

返回: 使用指定颜色的SolidPaint实例

PathF 仅客户端 ​

命名空间 GameUI.Graphics

csharp
public class PathF

表示一个2D图形路径,支持直线、曲线、圆弧等多种路径元素的构建和操作。 该类提供了创建复杂几何形状、路径变换、边界计算等功能。

构造函数 ​

PathF 仅客户端 ​

csharp
public PathF(PathF path)

通过复制现有路径创建新的PathF实例

  • path — 要复制的路径

PathF 仅客户端 ​

csharp
public PathF(PointF point)

使用指定起始点创建PathF实例

  • point — 起始点坐标

PathF 仅客户端 ​

csharp
public PathF(float x, float y)

使用指定起始坐标创建PathF实例

  • x — 起始点X坐标
  • y — 起始点Y坐标

PathF 仅客户端 ​

csharp
public PathF()

创建空的PathF实例

属性 ​

SubPathCount 仅客户端 ​

csharp
public int SubPathCount { get; }

获取子路径的数量

Closed 仅客户端 ​

csharp
public bool Closed { get; }

获取路径是否已闭合

FirstPoint 仅客户端 ​

csharp
public PointF FirstPoint { get; }

获取路径的第一个点

LastPoint 仅客户端 ​

csharp
public PointF LastPoint { get; }

获取路径的最后一个点

Count 仅客户端 ​

csharp
public int Count { get; }

获取路径中点的总数

OperationCount 仅客户端 ​

csharp
public int OperationCount { get; }

获取路径操作的总数

SegmentCountExcludingOpenAndClose 仅客户端 ​

csharp
public int SegmentCountExcludingOpenAndClose { get; }

获取排除开始和结束操作后的路径段数量

备注

该属性返回路径中除Move和Close操作之外的操作数量,主要用于计算实际的绘制段数。

SegmentTypes 仅客户端 ​

csharp
public IEnumerable<PathOperation> SegmentTypes { get; }

获取路径操作序列(移动、直线、曲线等)

Points 仅客户端 ​

csharp
public IEnumerable<PointF> Points { get; }

获取路径中的所有点坐标

LastPointIndex 仅客户端 ​

csharp
public int LastPointIndex { get; }

获取路径中最后一个点的索引

Bounds 仅客户端 ​

csharp
public RectangleF Bounds { get; }

获取路径的边界矩形

方法 ​

SetPoint 仅客户端 ​

csharp
public void SetPoint(int index, float x, float y)

设置路径中的点

  • index — 点的索引
  • x — 点的X坐标
  • y — 点的Y坐标

SetPoint 仅客户端 ​

csharp
public void SetPoint(int index, PointF point)

设置路径中的点

  • index — 点的索引
  • point — 点的坐标

GetSegmentType 仅客户端 ​

csharp
public PathOperation GetSegmentType(int aIndex)

获取路径操作序列(移动、直线、曲线等)

GetArcAngle 仅客户端 ​

csharp
public float GetArcAngle(int aIndex)

获取圆弧角度

  • aIndex — 圆弧索引

返回: 圆弧角度

SetArcAngle 仅客户端 ​

csharp
public void SetArcAngle(int aIndex, float aValue)

设置圆弧角度

  • aIndex — 圆弧索引
  • aValue — 新的圆弧角度

SetArcRadius 仅客户端 ​

csharp
public void SetArcRadius(int aIndex, float aValue)

设置圆弧半径

  • aIndex — 圆弧索引
  • aValue — 新的圆弧半径

GetArcRadius 仅客户端 ​

csharp
public float GetArcRadius(int aIndex)

获取圆弧半径

  • aIndex — 圆弧索引

返回: 圆弧半径

GetLineLength 仅客户端 ​

csharp
public float GetLineLength(int aIndex)

获取线段长度

  • aIndex — 线段索引

返回: 线段长度

SetLineLength 仅客户端 ​

csharp
public void SetLineLength(int aIndex, float aValue)

设置线段长度

  • aIndex — 线段索引
  • aValue — 新的线段长度

GetArcClockwise 仅客户端 ​

csharp
public bool GetArcClockwise(int aIndex)

获取圆弧方向

  • aIndex — 圆弧索引

返回: 圆弧方向(顺时针或逆时针)

SetArcClockwise 仅客户端 ​

csharp
public void SetArcClockwise(int aIndex, bool aValue)

设置圆弧方向

  • aIndex — 圆弧索引
  • aValue — 新的圆弧方向

MoveTo 仅客户端 ​

csharp
public PathF MoveTo(float x, float y)

移动到指定坐标(开始新的子路径)

  • x — 目标X坐标
  • y — 目标Y坐标

返回: 当前PathF实例,支持链式调用

MoveTo 仅客户端 ​

csharp
public PathF MoveTo(PointF point)

移动到指定坐标(开始新的子路径)

  • point — 目标点坐标

返回: 当前PathF实例,支持链式调用

Close 仅客户端 ​

csharp
public void Close()

闭合当前子路径

Open 仅客户端 ​

csharp
public void Open()

打开当前子路径

LineTo 仅客户端 ​

csharp
public PathF LineTo(float x, float y)

从当前位置绘制直线到指定坐标

  • x — 目标X坐标
  • y — 目标Y坐标

返回: 当前PathF实例,支持链式调用

LineTo 仅客户端 ​

csharp
public PathF LineTo(PointF point)

从当前位置绘制直线到指定坐标

  • point — 目标点坐标

返回: 当前PathF实例,支持链式调用

InsertLineTo 仅客户端 ​

csharp
public PathF InsertLineTo(PointF point, int index)

在指定位置插入直线到路径

  • point — 要插入的点
  • index — 插入位置

返回: 当前PathF实例,支持链式调用

AddEllipseArc 仅客户端 ​

csharp
public PathF AddEllipseArc(PointF center, float radiusX, float radiusY, float rotation, float startAngle, float endAngle, bool clockwise)

添加椭圆弧到路径

  • center — 椭圆中心点
  • radiusX — X轴半径
  • radiusY — Y轴半径
  • rotation — 椭圆旋转角度(度)
  • startAngle — 起始角度(度)
  • endAngle — 结束角度(度)
  • clockwise — 是否顺时针方向

返回: 当前PathF实例,支持链式调用

AddCircleArc 仅客户端 ​

csharp
public PathF AddCircleArc(PointF center, float radius, float startAngle, float endAngle, bool clockwise)

添加圆弧到路径

  • center — 圆心
  • radius — 半径
  • startAngle — 起始角度(度)
  • endAngle — 结束角度(度)
  • clockwise — 是否顺时针方向

返回: 当前PathF实例,支持链式调用

ArcTo 仅客户端 ​

csharp
public PathF ArcTo(PointF controlPoint1, PointF controlPoint2, float radius)

从当前位置绘制圆弧到指定位置

  • controlPoint1 — 第一个控制点
  • controlPoint2 — 第二个控制点
  • radius — 圆弧半径

返回: 当前PathF实例,支持链式调用

QuadTo 仅客户端 ​

csharp
public PathF QuadTo(float cx, float cy, float x, float y)

绘制二次贝塞尔曲线

  • cx — 控制点X坐标
  • cy — 控制点Y坐标
  • x — 终点X坐标
  • y — 终点Y坐标

返回: 当前PathF实例,支持链式调用

QuadTo 仅客户端 ​

csharp
public PathF QuadTo(PointF controlPoint, PointF point)

绘制二次贝塞尔曲线

  • controlPoint — 控制点
  • point — 终点

返回: 当前PathF实例,支持链式调用

InsertQuadTo 仅客户端 ​

csharp
public PathF InsertQuadTo(PointF controlPoint, PointF point, int index)

在指定位置插入二次贝塞尔曲线到路径

  • controlPoint — 控制点
  • point — 终点
  • index — 插入位置

返回: 当前PathF实例,支持链式调用

CurveTo 仅客户端 ​

csharp
public PathF CurveTo(float c1X, float c1Y, float c2X, float c2Y, float x, float y)

绘制三次贝塞尔曲线

  • c1X — 第一个控制点X坐标
  • c1Y — 第一个控制点Y坐标
  • c2X — 第二个控制点X坐标
  • c2Y — 第二个控制点Y坐标
  • x — 终点X坐标
  • y — 终点Y坐标

返回: 当前PathF实例,支持链式调用

CurveTo 仅客户端 ​

csharp
public PathF CurveTo(PointF controlPoint1, PointF controlPoint2, PointF point)

绘制三次贝塞尔曲线

  • controlPoint1 — 第一个控制点
  • controlPoint2 — 第二个控制点
  • point — 终点

返回: 当前PathF实例,支持链式调用

InsertCurveTo 仅客户端 ​

csharp
public PathF InsertCurveTo(PointF controlPoint1, PointF controlPoint2, PointF point, int index)

在指定位置插入三次贝塞尔曲线到路径

  • controlPoint1 — 第一个控制点
  • controlPoint2 — 第二个控制点
  • point — 终点
  • index — 插入位置

返回: 当前PathF实例,支持链式调用

AddRectangle 仅客户端 ​

csharp
public PathF AddRectangle(float x, float y, float w, float h)

添加矩形到路径

  • x — 矩形左上角X坐标
  • y — 矩形左上角Y坐标
  • w — 矩形宽度
  • h — 矩形高度

返回: 当前PathF实例,支持链式调用

AddRoundedRectangle 仅客户端 ​

csharp
public PathF AddRoundedRectangle(float x, float y, float w, float h, float cornerRadius)

添加圆角矩形到路径

  • x — 矩形左上角X坐标
  • y — 矩形左上角Y坐标
  • w — 矩形宽度
  • h — 矩形高度
  • cornerRadius — 圆角半径

返回: 当前PathF实例,支持链式调用

AddCircle 仅客户端 ​

csharp
public PathF AddCircle(PointF center, float radius)

添加圆形到路径

  • center — 圆心
  • radius — 半径

返回: 当前PathF实例,支持链式调用

AddEllipse 仅客户端 ​

csharp
public PathF AddEllipse(PointF center, float radiusX, float radiusY)

添加椭圆到路径

  • center — 椭圆中心点
  • radiusX — X轴半径
  • radiusY — Y轴半径

返回: 当前PathF实例,支持链式调用

GetSegmentPointIndex 仅客户端 ​

csharp
public int GetSegmentPointIndex(int index)

获取路径中点的索引

  • index — 路径操作索引

返回: 点的索引

GetSegmentInfo 仅客户端 ​

csharp
public PathOperation GetSegmentInfo(int segmentIndex, out int pointIndex, out int arcAngleIndex, out int arcRadiusIndex, out int lineLengthIndex, out int arcClockwiseIndex)

获取路径操作信息

  • segmentIndex — 路径操作索引
  • pointIndex — 点索引
  • arcAngleIndex — 圆弧角度索引
  • arcRadiusIndex — 圆弧半径索引
  • lineLengthIndex — 线段长度索引
  • arcClockwiseIndex — 圆弧方向索引

返回: 路径操作类型

GetSegmentForPoint 仅客户端 ​

csharp
public int GetSegmentForPoint(int pointIndex)

获取路径中点的索引

  • pointIndex — 点的索引

返回: 路径操作索引

GetPointsForSegment 仅客户端 ​

csharp
public PointF[]? GetPointsForSegment(int segmentIndex)

获取路径中点的集合

  • segmentIndex — 路径操作索引

返回: 点的集合

RemoveAllSegmentsAfter 仅客户端 ​

csharp
public void RemoveAllSegmentsAfter(int segmentIndex)

移除路径中指定索引后的所有操作和点

  • segmentIndex — 路径操作索引

RemoveSegment 仅客户端 ​

csharp
public void RemoveSegment(int segmentIndex)

移除路径中指定索引的操作和点

  • segmentIndex — 路径操作索引

Rotate 仅客户端 ​

csharp
public PathF Rotate(float angleAsDegrees, PointF pivot)

旋转路径

  • angleAsDegrees — 旋转角度(度)
  • pivot — 旋转中心点

返回: 旋转后的路径

GetRotatedPoint 仅客户端 ​

csharp
public PointF GetRotatedPoint(int pointIndex, PointF pivotPoint, float angle)

获取旋转后的点

  • pointIndex — 点的索引
  • pivotPoint — 旋转中心点
  • angle — 旋转角度(度)

返回: 旋转后的点

Transform 仅客户端 ​

csharp
public void Transform(Matrix3x2 transform)

使用变换矩阵对路径进行变换

  • transform — 3x2变换矩阵

Separate 仅客户端 ​

csharp
public List<PathF> Separate()

分离路径

返回: 分离后的路径集合

Reverse 仅客户端 ​

csharp
public PathF Reverse()

反转路径

返回: 反转后的路径

AppendEllipse 仅客户端 ​

csharp
public void AppendEllipse(RectangleF rect)

添加椭圆形状到路径

  • rect — 椭圆的边界矩形

AppendEllipse 仅客户端 ​

csharp
public void AppendEllipse(float x, float y, float w, float h)

添加椭圆形状到路径

  • x — 椭圆边界框左上角X坐标
  • y — 椭圆边界框左上角Y坐标
  • w — 椭圆边界框宽度
  • h — 椭圆边界框高度

AppendCircle 仅客户端 ​

csharp
public void AppendCircle(PointF center, float r)

添加圆形到路径

  • center — 圆心坐标
  • r — 半径

AppendCircle 仅客户端 ​

csharp
public void AppendCircle(float cx, float cy, float r)

添加圆形到路径

  • cx — 圆心X坐标
  • cy — 圆心Y坐标
  • r — 半径

AppendRectangle 仅客户端 ​

csharp
public void AppendRectangle(RectangleF rect, bool includeLast = false)

添加矩形到路径

  • rect — 矩形区域
  • includeLast — 是否包含最后一条边

AppendRectangle 仅客户端 ​

csharp
public void AppendRectangle(float x, float y, float w, float h, bool includeLast = false)

添加矩形到路径

  • x — 矩形左上角X坐标
  • y — 矩形左上角Y坐标
  • w — 矩形宽度
  • h — 矩形高度
  • includeLast — 是否包含最后一条边

AppendRoundedRectangle 仅客户端 ​

csharp
public void AppendRoundedRectangle(RectangleF rect, float cornerRadius, bool includeLast = false)

添加圆角矩形到路径

  • rect — 矩形区域
  • cornerRadius — 圆角半径
  • includeLast — 是否包含最后一条边

AppendRoundedRectangle 仅客户端 ​

csharp
public void AppendRoundedRectangle(float x, float y, float w, float h, float cornerRadius, bool includeLast = false)

添加圆角矩形到路径

  • x — 矩形左上角X坐标
  • y — 矩形左上角Y坐标
  • w — 矩形宽度
  • h — 矩形高度
  • cornerRadius — 圆角半径
  • includeLast — 是否包含最后一条边

AppendRoundedRectangle 仅客户端 ​

csharp
public void AppendRoundedRectangle(RectangleF rect, float topLeftCornerRadius, float topRightCornerRadius, float bottomLeftCornerRadius, float bottomRightCornerRadius, bool includeLast = false)

添加圆角矩形到路径

  • rect — 矩形区域
  • topLeftCornerRadius — 左上角圆角半径
  • topRightCornerRadius — 右上角圆角半径
  • bottomLeftCornerRadius — 左下角圆角半径
  • bottomRightCornerRadius — 右下角圆角半径
  • includeLast — 是否包含最后一条边

AppendRoundedRectangle 仅客户端 ​

csharp
public void AppendRoundedRectangle(RectangleF rect, float xCornerRadius, float yCornerRadius)

添加圆角矩形到路径

  • rect — 矩形区域
  • xCornerRadius — X方向圆角半径
  • yCornerRadius — Y方向圆角半径

AppendRoundedRectangle 仅客户端 ​

csharp
public void AppendRoundedRectangle(float x, float y, float w, float h, float topLeftCornerRadius, float topRightCornerRadius, float bottomLeftCornerRadius, float bottomRightCornerRadius, bool includeLast = false)

添加圆角矩形到路径

  • x — 矩形左上角X坐标
  • y — 矩形左上角Y坐标
  • w — 矩形宽度
  • h — 矩形高度
  • topLeftCornerRadius — 左上角圆角半径
  • topRightCornerRadius — 右上角圆角半径
  • bottomLeftCornerRadius — 左下角圆角半径
  • bottomRightCornerRadius — 右下角圆角半径
  • includeLast — 是否包含最后一条边

IsSubPathClosed 仅客户端 ​

csharp
public bool IsSubPathClosed(int subPathIndex)

检查指定子路径是否已闭合

  • subPathIndex — 子路径的索引

返回: 如果指定子路径已闭合则返回true,否则返回false

Invalidate 仅客户端 ​

csharp
public void Invalidate()

使路径无效

Move 仅客户端 ​

csharp
public void Move(float x, float y)

移动路径

  • x — X方向移动量
  • y — Y方向移动量

MovePoint 仅客户端 ​

csharp
public void MovePoint(int index, float dx, float dy)

移动路径中的点

  • index — 点的索引
  • dx — X方向移动量
  • dy — Y方向移动量

Equals 仅客户端 ​

csharp
public override bool Equals(object? obj)

比较路径是否相等

  • obj — 要比较的对象

返回: 是否相等

GetHashCode 仅客户端 ​

csharp
public override int GetHashCode()

获取路径的哈希码

返回: 哈希码

Equals 仅客户端 ​

csharp
public bool Equals(object obj, float epsilon)

比较路径是否相等

  • obj — 要比较的对象
  • epsilon — 比较精度

返回: 是否相等

GetBoundsByFlattening 仅客户端 ​

csharp
public RectangleF GetBoundsByFlattening(float flatness = 0.001f)

获取路径的边界矩形

  • flatness — 扁平化精度,值越小越精确

返回: 边界矩形

GetFlattenedPath 仅客户端 ​

csharp
public PathF GetFlattenedPath(float flatness = 0.001f, bool includeSubPaths = false)

将路径扁平化为直线段序列

  • flatness — 扁平化精度,值越小越精确
  • includeSubPaths — 是否包含所有子路径

返回: 扁平化后的路径

索引器 ​

this[] 仅客户端 ​

csharp

获取或设置指定索引位置的点坐标

  • index — 点的索引

返回: 指定索引位置的点坐标,如果索引无效则返回默认值

RadialGradientPaint 仅客户端 ​

命名空间 GameUI.Graphics

csharp
public class RadialGradientPaint : GradientPaint

表示从中心点向外扩散进行颜色过渡的径向渐变画笔

  • centerPoint — 径向渐变的中心点
  • startRadius — 渐变的起始半径(内半径)
  • endRadius — 渐变的结束半径(外半径)
  • startColor — 渐变中心(起始半径)处的颜色
  • endColor — 渐变边缘(结束半径)处的颜色

构造函数 ​

RadialGradientPaint 仅客户端 ​

csharp
public RadialGradientPaint(PointF centerPoint, float startRadius, float endRadius, Color startColor, Color endColor)

表示从中心点向外扩散进行颜色过渡的径向渐变画笔

  • centerPoint — 径向渐变的中心点
  • startRadius — 渐变的起始半径(内半径)
  • endRadius — 渐变的结束半径(外半径)
  • startColor — 渐变中心(起始半径)处的颜色
  • endColor — 渐变边缘(结束半径)处的颜色

属性 ​

CenterPoint 仅客户端 ​

csharp
public PointF CenterPoint { get; }

获取径向渐变的中心点

StartRadius 仅客户端 ​

csharp
public float StartRadius { get; }

获取渐变的起始半径(内半径)

EndRadius 仅客户端 ​

csharp
public float EndRadius { get; }

获取渐变的结束半径(外半径)

StartColor 仅客户端 ​

csharp
public override Color StartColor { get; }

获取渐变中心(起始半径)处的颜色

EndColor 仅客户端 ​

csharp
public override Color EndColor { get; }

获取渐变边缘(结束半径)处的颜色

SolidPaint 仅客户端 ​

命名空间 GameUI.Graphics

csharp
public class SolidPaint : Paint

表示使用纯色填充形状的画笔

  • color — 用于填充形状的颜色
备注

使用指定颜色初始化SolidPaint类的新实例。

构造函数 ​

SolidPaint 仅客户端 ​

csharp
public SolidPaint(Color color)

表示使用纯色填充形状的画笔

  • color — 用于填充形状的颜色
备注

使用指定颜色初始化SolidPaint类的新实例。

属性 ​

Color 仅客户端 ​

csharp
public Color Color { get; set; }

获取或设置用于填充形状的颜色

IsTransparent 仅客户端 ​

csharp
public override bool IsTransparent { get; }

获取一个值,指示此画笔是否具有透明区域

备注

当纯色画笔颜色的alpha值小于255时,被认为是透明的。

方法 ​

ToString 仅客户端 ​

csharp
public override string ToString()

返回此纯色画笔的字符串表示形式

返回: 包含类型名称和颜色信息的字符串

implicit operator 仅客户端 ​

csharp
public static SolidPaint implicit operator(Color color)

将Color隐式转换为SolidPaint

  • color — 要转换的颜色

返回: 使用指定颜色的新SolidPaint实例

TextMetrics 仅客户端 ​

命名空间 GameUI.Graphics

csharp
public readonly struct TextMetrics

文本度量信息,包含字体的排版尺寸数据

备注

提供字体的基本度量信息,用于精确的文本布局和对齐。 所有度量值均以像素为单位,相对于当前字体大小。

构造函数 ​

TextMetrics 仅客户端 ​

csharp
public TextMetrics(float ascender, float descender, float lineHeight)

创建文本度量信息实例

  • ascender — 字体基线以上的高度
  • descender — 字体基线以下的深度(通常为负值)
  • lineHeight — 推荐的行高

属性 ​

Ascender 仅客户端 ​

csharp
public float Ascender { get; }

获取字体基线以上的高度(上伸部分)

备注

Ascender 表示字符从基线向上延伸的最大距离。 例如大写字母 'H' 或 'd' 的上半部分高度。 此值通常为正数。

Descender 仅客户端 ​

csharp
public float Descender { get; }

获取字体基线以下的深度(下伸部分)

备注

Descender 表示字符从基线向下延伸的最大距离。 例如小写字母 'g' 或 'p' 的下半部分深度。 此值通常为负数(表示基线以下)。

LineHeight 仅客户端 ​

csharp
public float LineHeight { get; }

获取推荐的行高

备注

LineHeight 是字体设计者推荐的行与行之间的垂直距离。 通常等于 Ascender - Descender 加上一些额外的行间距。 此值用于多行文本的垂直排版。

TotalHeight 仅客户端 ​

csharp
public float TotalHeight { get; }

获取字体的总高度(Ascender 的绝对值 + Descender 的绝对值)

备注

表示字符从最高点到最低点的总高度。 等于 Ascender + |Descender|。

方法 ​

Deconstruct 仅客户端 ​

csharp
public void Deconstruct(out float ascender, out float descender, out float lineHeight)

解构方法,支持元组解构语法

  • ascender — 字体基线以上的高度
  • descender — 字体基线以下的深度
  • lineHeight — 推荐的行高

ToString 仅客户端 ​

csharp
public override string ToString()

返回文本度量信息的字符串表示

LineCap 仅客户端 ​

命名空间 GameUI.Graphics.Enum

csharp
public enum LineCap

定义线条端点的样式

备注

线条端点样式决定了线条两端的形状外观。 不同的端点样式适用于不同的设计需求: Butt: 适用于精确的技术图形和简洁的线条 Round: 适用于柔和的设计和艺术图形 Square: 适用于需要加强端点视觉重量的场合

枚举值 ​

  • Butt — 平头端点 - 线条在端点处平齐截止
  • Round — 圆形端点 - 线条端点为半圆形
  • Square — 方形端点 - 线条端点为方形,向外延伸线条宽度的一半

LineJoin 仅客户端 ​

命名空间 GameUI.Graphics.Enum

csharp
public enum LineJoin

定义线条连接处的样式

备注

线条连接样式决定了两条线段相交时连接点的外观。 不同的连接样式适用于不同的设计需求: Miter: 适用于需要锐利边角的技术图形和建筑设计 Round: 适用于柔和的艺术设计和有机形状 Bevel: 适用于需要控制尖角长度或创建现代简洁效果的场合 连接样式与MiterLimit属性配合使用,可以精确控制连接效果。

枚举值 ​

  • Miter = 4 — 斜接连接 - 线条在连接处以尖角相接
  • Round = 1 — 圆形连接 - 线条在连接处以圆弧相接
  • Bevel = 3 — 斜切连接 - 线条在连接处以平角相接

PaintApply 仅客户端 ​

命名空间 GameUI.Graphics.Enum

csharp
public enum PaintApply

定义画笔的应用方式

枚举值 ​

  • Fill — 填充 - 将画笔应用于形状的内部填充
  • Stroke — 描边 - 将画笔应用于形状的轮廓线条

PathOperation 仅客户端 ​

命名空间 GameUI.Graphics.Enum

csharp
public enum PathOperation

定义路径中可以执行的各种操作类型

备注

路径操作枚举定义了构建复杂路径时可以使用的所有基本操作。 这些操作可以组合使用来创建各种复杂的几何形状和曲线。 路径通常以Move操作开始,然后通过各种绘制操作来构建形状,最后可选择性地使用Close操作闭合路径。

枚举值 ​

  • Move — 移动操作
  • Line — 直线操作
  • Quad — 二次贝塞尔曲线操作
  • Cubic — 三次贝塞尔曲线操作
  • Arc — 圆弧操作
  • AddRectangle — 添加矩形操作
  • AddRoundedRectangle — 添加圆角矩形操作
  • AddCircle — 添加圆形操作
  • AddEllipse — 添加椭圆操作
  • AddCircleArc — 添加圆弧操作
  • AddEllipseArc — 添加椭圆弧操作
  • Close — 闭合路径操作