Text 文本
Text 是节点的一种,它包含了一段文字,这样可以把每段文字都当做一个对象进行处理。
1
| auto text = gcnew Text("Hello Easy2D!");
|
Text 支持节点的所有通用属性,例如坐标、缩放、旋转角度、不透明度等
1 2 3 4 5 6
| text->setRotation(30);
text->setScale(2);
text->setOpacity(0.5f);
|
文字样式
TextStyle
结构体提供了字体、对齐方式等文字样式设定。
1 2 3 4 5 6 7 8 9 10 11 12 13
| TextStyle style; style.font = Font("宋体"); style.alignment = TextAlign::Left; style.wrapping = true; style.wrappingWidth = 70; style.lineSpacing = 10; style.hasUnderline = true; style.hasStrikethrough = true;
auto text = gcnew Text("Hello Easy2D!"); text->setTextStyle(style);
|
Font 文字控制文字的字体、字号、粗细等等,详情请参阅
Font 字体。
可以单独设置某一项样式,例如文字比较多,你可以设置它自动换行:
1 2 3
| auto text = gcnew Text("Hello Easy2D!"); text->setWordWrappingEnable(true); text->setWordWrappingWidth(70);
|
绘图样式
Text
支持设置 DrawingStyle
绘图样式,以设置文字填充颜色、描边颜色等,详情请参阅 DrawingStyle。
1 2 3 4 5 6 7 8 9 10 11
| DrawingStyle style; style.mode = DrawingStyle::Mode::Solid; style.fillColor = Color::White; style.strokeColor = Color::Red; style.strokeWidth = 2.0; style.lineJoin = LineJoin::Miter;
auto text = gcnew Text("Hello Easy2D!"); text->setDrawingStyle(style);
|