Files
esengine/packages/components/src/TextComponent.ts

47 lines
1.0 KiB
TypeScript
Raw Normal View History

import { Component, ECSComponent, Serializable, Serialize } from '@esengine/ecs-framework';
/**
*
*/
export enum TextAlignment {
Left = 'left',
Center = 'center',
Right = 'right'
}
/**
* -
*/
@ECSComponent('Text')
@Serializable({ version: 1, typeId: 'Text' })
export class TextComponent extends Component {
/** 文本内容 */
@Serialize() public text: string = '';
/** 字体 */
@Serialize() public font: string = 'Arial';
/** 字体大小 */
@Serialize() public fontSize: number = 16;
/** 颜色 */
@Serialize() public color: string = '#ffffff';
/** 对齐方式 */
@Serialize() public alignment: TextAlignment = TextAlignment.Left;
/** 行高 */
@Serialize() public lineHeight: number = 1.2;
/** 是否加粗 */
@Serialize() public bold: boolean = false;
/** 是否斜体 */
@Serialize() public italic: boolean = false;
constructor(text: string = '') {
super();
this.text = text;
}
}