跳到主要内容

线条样式对象

在 HiEasyX 中,线条样式对象指的是 HXLineStyle 对象:HXLineStyle 对象定义在 include/impl/hex_impl.h 下。大致定义如下:

HX_IMPL_API struct HXLineStyle {
HXColInt Thickness = 1;
HXLineShapeStyle Shape = HXLineShapeStyle::Solid;
};
变量含义默认取值
Thickness线条的粗细,值越大,线条越粗,否则反之1
Shape线条的形状,值为 HXLineShapeStyle 枚举类HXLineShapeStyle::Solid

线条形状枚举类

HXLineShapeStyle 枚举类的定义如下:

enum class HXLineShapeStyle {
Solid, Dash, Dotted, DashDotted
};
含义
Solid填充的正常线条
Dash虚线条
Dotted点状线条
DashDotted点、虚线交替的线条

示例代码

以下代码展示了不同形状的直线的具体视觉效果:

HXLineStyle style;
style.Thickness = 3;
style.Shape = HXLineShapeStyle::Solid;
Painter->DrawLineStyled({0, 0 * 4}, {60, 30 * 4}, HXColor{255, 255, 255, 255}, style);
style.Shape = HXLineShapeStyle::Dash;
Painter->DrawLineStyled({0, 20 * 4}, {60, 50 * 4}, HXColor{255, 255, 255, 255}, style);
style.Shape = HXLineShapeStyle::Dotted;
Painter->DrawLineStyled({0, 40 * 4}, {60, 70 * 4}, HXColor{255, 255, 255, 255}, style);
style.Shape = HXLineShapeStyle::DashDotted;
Painter->DrawLineStyled({0, 60 * 4}, {60, 90 * 4}, HXColor{255, 255, 255, 255}, style);

运行结果如下图,从上到下分别 HXLineShapeStyle::SolidHXLineShapeStyle::DashHXLineShapeStyle::DottedHXLineShapeStyle::DashDotted